我想尝试 Canny 边缘检测器,但是当我尝试启动时收到未处理的异常:
canny_project.exe 中 0x00007FF97F6C8B9C 处未处理的异常:Microsoft C++ 异常:内存位置 0x0000002485D89860 处的 cv::Exception
下面是我在 VS2012 中实现的代码。
#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);
cv::Mat frame; cv::Mat out; cv::Mat out2;
while (1) {
frame = cvQueryFrame(capture);
GaussianBlur(frame, out, Size(5, 5), 0, 0);
cvtColor(out, out2, CV_BGR2GRAY); // produces out2, a one-channel image (CV_8UC1)
Canny(out2, out2, 100, 200, 3); // the result goes to out2 again,but since it is still one channel it is fine
if (!frame.data) break;
imshow("Edges", out2);
char c = cvWaitKey(33);
if (c == 'c') break;
}
return 0;
}
提前致谢