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**)
{
VideoCapture stream1(0);
if(!stream1.isOpened()){
cout << "cannot open camera" << endl;
}
while (true) {
Mat cannyImage;
Mat cameraFrame;
Mat houghImage;
stream1.read(cameraFrame);
imshow("Source Input", cameraFrame);
cvtColor(cameraFrame, cannyImage, CV_BGR2GRAY);
Canny( cannyImage, cannyImage, 100, 200, 3 );
imshow("Canny", cannyImage);
vector<Vec4i> lines;
HoughLinesP(cannyImage, lines, 1, CV_PI/180, 50, 10, 10 );
if (waitKey(30) >= 0)
break;
}
return 0;
}
I have been googleing and searching around to no avail. Anyone have an pointers?
You haven't release the resource of the camera(cvCaptureFromCAM and cvQueryFrame are c api, you need to deal with resource by yourself), please use c++ api(VideoCapture) instead of c api.Try your best to stick with c++ api rather than c api, this could save you from a lot of headaches.
Alright. Thanks! I changed my code, however I am still getting the same windows breakpoint error. Code posted above.