If I don't do anything (that is, don't change the color detection HSV via a Controls Window), the app runs fine. However if I change the HSV values when the app is running, I get the following errors. I have tested the code without Hough, it runs fine.
The CPU Error -
Unhandled exception at 0x00007FF9ECA64388 (ucrtbase.dll) in HoughFinder.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
This is my code -
VideoCapture capture(0); // 0 is my webcam
...
capture.read(displayOriginal))
...(Code to detect colors for extra accuracy)
cudaCanny->detect(imgThresholded, imgCanny);
vector<Vec2f> lines;
//Ptr<HoughLinesDetector> hough = createHoughLinesDetector(1, CV_PI / 180, 100); CUDA code...
//hough->detect(imgCanny, lines); CUDA code...
HoughLines(displayCanny, lines, 1, CV_PI / 180, 100, 0, 0); // CPU code...
for (size_t i = 0; i < lines.size(); i++)
{
float rho = lines[i][0], theta = lines[i][1];
Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + 1000 * (-b));
pt1.y = cvRound(y0 + 1000 * (a));
pt2.x = cvRound(x0 - 1000 * (-b));
pt2.y = cvRound(y0 - 1000 * (a));
line(displayHough, pt1, pt2, Scalar(0, 0, 255), 3, CV_AA);
}
imshow("Hough", displayHough);
imshow("Live Video", displayOriginal);
Extra Info -
If I use CUDA code to use Hough, I get this error -
Unhandled exception at 0x00007FF9F561A1C8 in HoughFinder.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000A75E81EB70.
App Error (Don't get this error while using CPU code) -
OpenCV Error: Assertion failed (d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0)) in cv::_OutputArray::create, file OPENCV_DIR\opencv-sources\modules\core\src\matrix.cpp, line 2363
Can anyone help? If either the CPU or CUDA code is fixed, its fine, but I would more prefer the CUDA error to be fixed (As CUDA has extra speed).
WITH_QTand USEWITH_CUDAin CMake Options. - FadedCoder