【发布时间】:2015-05-28 18:08:33
【问题描述】:
我使用的是 OpenCV 2.4.10 版。
调试时出现断点错误:未加载 wkernelbase.pdb。
此外,我在 Visual Studio 的输出中收到此错误:
First-chance exception at 0x7543C42D in Perspective.exe: Microsoft C++ exception: cv::Exception at memory location 0x003FEDDC.
Unhandled exception at 0x7543C42D in Perspective.exe: Microsoft C++ exception: cv::Exception at memory location 0x003FEDDC.
在我的应用程序中,命令行会打印出来:
OpenCV Error: Assertion failed <0 <= contourIdx< <int>last> in cv::drawContours, file...\..\..\..\opencv\imgproc\src\contours.cpp, line 1810
关于如何处理这个问题有什么建议吗?这是我的代码:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"
using namespace cv;
using namespace std;
int main()
{
Mat image;
image = imread("shape.jpg", 1);
namedWindow("Display window", CV_WINDOW_AUTOSIZE);
imshow("Display window", image);
Mat gray;
cvtColor(image, gray, CV_BGR2GRAY);
Canny(gray, gray, 100, 200, 3);
/// Find contours
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
RNG rng(12345);
findContours(gray, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
/// Draw contours
Mat drawing = Mat::zeros(gray.size(), CV_8UC3);
for (int i = 0; i < contours.size(); i++)
{
Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
drawContours(drawing, contours, i, color, 2, 8, hierarchy, 0, Point());
}
imshow("Result window", drawing);
waitKey(0);
return 0;
}
我知道我的图片也在正确的目录中。
【问题讨论】:
-
请再看看你正在链接的 opencv 库。不要混合调试和发布库,或将发布库与调试版本一起使用,或以其他方式。
-
您好,berak,感谢您的快速响应。我刚刚检查了它们,并且我使用了正确的库(我目前正在通过调试运行它)。
-
您是否链接到 Visual Studio 2013 库。这些应该在 vc12 文件夹中。是 vc12 = Visual Studio 2013。
-
我之前已经将它链接到 vc10 库,但是当我更改它时,错误仍然是一样的......在应用程序中,命令行有同样的错误并给了我一个新的:“OpenCV 错误:断言失败 vv.size> in cv::_InputArray::getMat, file ...\opencv\modules\core\src\matrix.cpp,第 977 行“
-
更新:我没有打破它,而是决定按继续,它给了我这个:“调试断言失败!表达式:向量下标超出范围”我的代码有什么问题吗?
标签: c++ visual-studio-2010 opencv visual-studio-2012