Error occurred during running time. cvHoughLines2

asked 2015-08-05 02:42:47 -0500

Ryang gravatar image
   I want to find lines using cvHoughLines2 function. but when I run the program there are some error like below.

root@nvidia:~/sampleCode/4_captureOpenCV# ./captureOpenCV -vt 10sad

  1. Create NvMedia capture

  2. Create NvMedia device

  3. Create NvMedia mixer(s) and output(s) and bind them

  4. Check that the device is enabled (initialized)

Query check - Output Info - Enabled:1 displayId:0 type:b302 width:480 height:272 refresh:59.940060 type:D

Used output - Output Info - Enabled:1 displayId:0 type:b302 width:480 height:272 refresh:59.940060 type:D

  1. Open output file(s)

  2. Create vip pool(s), queue(s), fetch threads and stream start/done semaphores

wait for ADV7182 ... one second

  1. Kickoff

  2. Control Thread

timeNotCount

frame= 0, time=0.000001000[s]

  1. Wait for completion

frame= 1, time=0.059011000[s]

frame= 2, time=0.092225000[s]

frame= 3, time=0.125588000[s]

frame= 4, time=0.159008000[s]

frame= 5, time=0.192591000[s]

OpenCV Error: Bad argument (The source image must be 8-bit, single-channel) in cvHoughLines2, file /root2

terminate called after throwing an instance of 'cv::Exception' what(): /root/opencv-2.4.9/modules/imgproc/src/hough.cpp:712: error: (-5) The source image must be 8-2

here is my source code.

I don't know why my program quit in short time. I set the running time at 10 sec.

   //CV_HOUGH_PROBABILISTIC 
CvSeq* lines = 0; 
cvHoughLines2( imgOrigin, lines, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 50, 50, 5 );

for( i = 0; i < 1; i++ )
{      CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i); 
       cvLine( imgOrigin, line[0], line[1], CV_RGB(255,0,0), 3, 8, 0 );
}
sprintf(fileName, "captureImage/imgOrigin%d.png", i);
    cvSaveImage(fileName, imgOrigin, 0);

    // ---------------------------------------------------------------------
edit retag flag offensive close merge delete

Comments

please, you must use opencv's c++ api , not the deprecated c-api !

try again with the tutorial, and make sure you have a grayscale(binary) image as input.

berak gravatar imageberak ( 2015-08-05 03:39:49 -0500 )edit