C ++ OpenCV 2.4.11 HouchCircles Visual Studio:未处理的异常

时间:2016-01-12 13:25:03

标签: c++ visual-studio-2010 opencv

Windows 10 64-Bit
Microsoft Visual Studio 2010
OpenCV 2.4.11

我的程序应该使用HoughCircles功能在图像中找到圆圈 随着OpenCV-Version 2.3在这个位置没有错误 当我通过调试器访问代码时,错误发生在第二个参数(圆圈),此错误消息

Unbehandelte Ausnahme(engl.:Unhandled Exception) bei(engl.:at) 0x5478c3d7 in src_d.exe: 0xC00000FD: Stack overflow.

代码:

#include <opencv\cv.h>
#include <opencv\highgui.h>

#include <iostream>

void HoughDetection(cv::Mat& src_gray, cv::Mat& src_display, int     cannyThreshold, int accumulatorThreshold){
// will hold the results of the detection
std::vector<cv::Vec3f> circles;
// runs the actual detection
cv::HoughCircles(src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, cannyThreshold, accumulatorThreshold, 0, 20);

// clone the colour, input image for displaying purposes
cv::Mat display = src_display.clone();
for( size_t i = 0; i < circles.size(); i++ )
{
    cv::Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
    int radius = cvRound(circles[i][2]);
    // circle center
    circle( display, center, 3, cv::Scalar(0,255,0), -1, 8, 0 );
    // circle outline
    circle( display, center, radius, cv::Scalar(0,0,255), 3, 8, 0 );
}

// shows the results
imshow("Window", display);
cv::waitKey(0);
}


int CircleDetection(std::string& pathToFile){
cv::Mat src, src_gray;

// Read the image
src = cv::imread(pathToFile, 1 );

if( src.empty() )
{
    return -1;
}

medianBlur(src, src, 9);

// Convert it to gray
cvtColor(src, src_gray, cv::COLOR_BGR2GRAY);

// Reduce the noise so we avoid false circle detection
GaussianBlur(src_gray, src_gray, cv::Size(9, 9), 2, 2);

HoughDetection(src_gray, src, 35, 35);

return 0;
}

0 个答案:

没有答案