Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hough Transform on Live Video

I am trying to run a hough transform on live video input. It runs fine on what seems to be the first frame then it throws this:

The thread 'Win32 Thread' (0x12b0) has exited with code 1950154752 (0x743d0000).
HEAP[openCV.exe]: Invalid address specified to RtlFreeHeap( 01DC0000, 041EC660 )
Windows has triggered a breakpoint in openCV.exe.

This may be due to a corruption of the heap, which indicates a bug in openCV.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while openCV.exe has focus.

The output window may have more diagnostic information.
The program '[900] openCV.exe: Native' has exited with code 0 (0x0).

And the code:

    #include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
using namespace cv;

int main(int, char**)
{
    namedWindow( "Edges", CV_WINDOW_NORMAL ); 
    CvCapture* capture = cvCaptureFromCAM(-1);

    Mat frame; 
    Mat out; 
    Mat out2;
    Mat canny;
    Mat hough;
    while(1) {
        frame = cvQueryFrame( capture );
        imshow("Source",frame);
        GaussianBlur( frame, out, Size(5, 5), 0, 0 );
        cvtColor( out ,out2, CV_BGR2GRAY ); // produces out2, a one-channel image (CV_8UC1)
     Canny( out2, canny, 100, 200, 3 ); // the result goes to out2 again,but since it is still one channel it is fine
     imshow( "Canny", canny );



      vector<Vec4i> lines;
  HoughLinesP(canny, lines, 1, CV_PI/180, 50, 10, 10 );
  for( size_t i = 0; i < lines.size(); i++ )
  {
    Vec4i l = lines[i];
    line( canny, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
  }

  imshow("Hough", canny);



        if( !frame.data ) break;


        char c = cvWaitKey(33);
        if( c == 'c' ) break;
    }
    return 0;
}

I have been googleing and searching around to no avail. Anyone have an pointers?

Hough Transform on Live Video

I am trying to run a hough transform on live video input. It runs fine on what seems to be the first frame then it throws this:

The thread 'Win32 Thread' (0x12b0) has exited with code 1950154752 (0x743d0000).
HEAP[openCV.exe]: Invalid address specified to RtlFreeHeap( 01DC0000, 041EC660 )
Windows has triggered a breakpoint in openCV.exe.

This may be due to a corruption of the heap, which indicates a bug in openCV.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while openCV.exe has focus.

The output window may have more diagnostic information.
The program '[900] openCV.exe: Native' has exited with code 0 (0x0).

And the code:

 #include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
using namespace cv;

int main(int, char**)
{
    namedWindow( "Edges", CV_WINDOW_NORMAL ); 
    CvCapture* capture = cvCaptureFromCAM(-1);

VideoCapture stream1(0);
    if(!stream1.isOpened()){
    cout << "cannot open camera" << endl;
    }

    while (true) {
        Mat frame; 
cannyImage;
        Mat out; 
cameraFrame;
        Mat out2;
    Mat canny;
    Mat hough;
    while(1) {
        frame = cvQueryFrame( capture );
        imshow("Source",frame);
        GaussianBlur( frame, out, Size(5, 5), 0, 0 );
        cvtColor( out ,out2, CV_BGR2GRAY ); // produces out2, a one-channel image (CV_8UC1)
houghImage;
    stream1.read(cameraFrame);
    imshow("Source Input", cameraFrame);

        cvtColor(cameraFrame, cannyImage, CV_BGR2GRAY);
         Canny( out2, canny, cannyImage, cannyImage, 100, 200, 3 ); // the result goes to out2 again,but since it is still one channel it is fine
     imshow( "Canny", canny );
          imshow("Canny", cannyImage);

         vector<Vec4i> lines;
  HoughLinesP(canny, HoughLinesP(cannyImage, lines, 1, CV_PI/180, 50, 10, 10 );
  for( size_t i = 0; i < lines.size(); i++ )
  {
    Vec4i l = lines[i];
    line( canny, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);



        if (waitKey(30) >= 0)
            break;

        }

  imshow("Hough", canny);



        if( !frame.data ) break;


        char c = cvWaitKey(33);
        if( c == 'c' ) break;
    }
    return 0;
}

I have been googleing and searching around to no avail. Anyone have an pointers?