OpenCV 3.0 tldDetector.cpp - Kernel Run Error!!!

asked 2015-08-28 07:54:17 -0500

Zura gravatar image

updated 2015-08-31 01:47:28 -0500

Hello I'm trying to run tracking example and all trackers run fine "MIL", "BOOSTING", "MEDIANFLOW", but "TLD" tracker crashes and prints - "Kernel Run Error!!!" I think there is a problem with OpenCL...

  • OS: Centos 7 64bit
  • gcc: 4.8.3
  • Video Card: Nvidia GTX660TI
  • Video Card Driver: 346.46

---EDIT--- Quick solution is to disable OpenCL while compiling OpenCV: cmake -WITH_OPENCL=OFF

Here is the code:

#include <opencv2/video/tracking.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/tracking/tracker.hpp>
#include <iostream>

using namespace cv;
using namespace std;

static Mat image;
static cv::Rect2d boundingBox;
static bool paused;
static bool selectObject   = false;
static bool startSelection = false;

static void onMouse( int event, int x, int y, int, void* )
{
    if( !selectObject )
    {
        switch ( event )
        {
        case EVENT_LBUTTONDOWN:
            //set origin of the bounding box
            startSelection = true;
            boundingBox.x = x;
            boundingBox.y = y;
            break;
        case EVENT_LBUTTONUP:
            boundingBox.width = std::abs( x - boundingBox.x );
            boundingBox.height = std::abs( y - boundingBox.y );
            paused = false;
            selectObject = true;
            break;
        case EVENT_MOUSEMOVE:
            if( startSelection && !selectObject )
            {
                Mat currentFrame;
                image.copyTo( currentFrame );
                rectangle( currentFrame, Point( boundingBox.x, boundingBox.y ), Point( x, y ), Scalar( 255, 0, 0 ), 2, 1 );
                imshow( "Tracking API", currentFrame );
            }
            break;
        }
    }
}

int main( int argc, char** argv )
{
    String tracker_algorithm ;

    cv::VideoCapture cap(0);
    tracker_algorithm = "TLD";

    if( !cap.isOpened() )
    {
        cout << "Could not initialize capturing...\n";
        return -1;
    }

    Mat frame;
    paused = true;
    namedWindow( "Tracking API", 1 );
    setMouseCallback( "Tracking API", onMouse, 0 );

    Ptr<Tracker> tracker = Tracker::create( tracker_algorithm );
    if( tracker == NULL )
    {
        cout << "***Error in the instantiation of the tracker...***\n";
        return -1;
    }

    cap >> frame;
    frame.copyTo( image );
    imshow( "Tracking API", image );

    bool initialized = false;
    for ( ;; )
    {
        if( !paused )
        {
            cap >> frame;
            frame.copyTo( image );

            if( !initialized && selectObject )
            {
                //initializes the tracker
                if( !tracker->init( frame, boundingBox ) )
                {
                    cout << "***Could not initialize tracker...***\n";
                    return -1;
                }
                initialized = true;
            }
            else if( initialized )
            {
                //updates the tracker
                if( tracker->update( frame, boundingBox ) )
                {
                    rectangle( image, boundingBox, Scalar( 255, 0, 0 ), 2, 1 );
                }
            }
            imshow( "Tracking API", image );
        }

        char c = (char) waitKey( 2 );
        if( c == 'q' )
            break;
        if( c == 'p' )
            paused = !paused;
    }
    return 0;
}

and cmake data:

cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../ -DWITH_CUDA=ON -DCUDA_ARCH_BIN="3.0" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_CCTESTS=OFF ..
-- Detected version of GNU GCC: 48 (408)
-- Found ZLIB: /lib64/libz.so (found suitable version "1.2.7", minimum required is "1.2.3") 
-- Could NOT find TIFF (missing:  TIFF_LIBRARY TIFF_INCLUDE_DIR) 
-- Could NOT find Jasper (missing:  JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- Found ZLIB: /lib64/libz.so (found version "1.2.7") 
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- found IPP (ICV version): 8.2.1 [8.2.1]
-- at: /home/darkman/Downloads/opencv-3.0.0/3rdparty/ippicv/unpack/ippicv_lnx
-- CUDA detected: 7.0
-- CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass ...
(more)
edit retag flag offensive close merge delete

Comments

can you try to disable opencl at runtime ?

int main( int argc, char** argv )
{
   setUseOpenCL(false);
   ...
berak gravatar imageberak ( 2015-08-28 08:14:42 -0500 )edit

I've tried setUseOpenCL(false); the same error Kernel Run Error!!!

Zura gravatar imageZura ( 2015-08-28 11:52:30 -0500 )edit

oook, sorry.

berak gravatar imageberak ( 2015-08-28 11:54:21 -0500 )edit