我是C++的新手,我正在尝试浏览一些我在网上找到的OpenCV教程。我生成的代码与在Visual 2013中找到的完全一样,并且能够正确运行代码。但是,我一直收到一个错误:
(按“重试”调试应用程序)调试错误! 程序:...rface_Basics\x64\Debug\OpenCV_Basics_CPP_Interface_Basics.exe R6025 -纯虚函数调用 (按“重试”以调试应用程序)
我读到了关于纯虚拟函数的文章,听起来好像您至少必须声明一个虚拟函数才会发生这个错误,这只会导致更多的混乱。下面是我的代码:
#include <opencv2\opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
//main functions
void processImage();
void displayGraphics();
//images
Mat image;
Mat processedImage;
int main(int argc, char *argv[])
{
//create a window
namedWindow("Image");
namedWindow("ProcessedImage");
//load the image
if (argc > 1)
image = imread(argv[1]);
else
image = imread("lena.jpg");
if (image.empty())
exit(1);
processImage();
displayGraphics();
waitKey(0);
return 0;
}
void displayGraphics()
{
//display both images
imshow("Image", image);
imshow("ProcessedImage", processedImage);
}
void processImage()
{
int x, y;
Vec3b pixel;
unsigned char R, G, B;
processedImage = image.clone();
for (y = 0; y < processedImage.rows; y++)
{
for (x = 0; x < processedImage.cols; x++)
{
// Get the pixel at (x,y)
pixel = processedImage.at<Vec3b>(y, x);
// Get the separate colors
B = pixel[0];
G = pixel[1];
R = pixel[2];
// Assign the complement of each color
pixel[0] = 255 - B;
pixel[1] = 255 - G;
pixel[2] = 255 - R;
// Write the pixel back to the image
processedImage.at<Vec3b>(y, x) = pixel;
}
}
}我尝试从主函数中删除参数,并完成上面引号中提供的调试过程。但是,它只调用这个crt0msg.c文件,并突出显示#ifdef _DEBUG部分的案例1。
如能帮助解决这一问题,将不胜感激。
发布于 2015-07-14 05:57:54
使用静态或全局Mat导致问题。
我发现了问题
> MatAllocator* Mat::getStdAllocator() {
> static StdMatAllocator allocator;//it's static. but mat's destructor need >it. so when that's have a static or global mat, can not be guaranteed this >allocator's destructor after that static or global mat.
> return allocator;
> }来源:http://code.opencv.org/issues/3355
这是OpenCV中的一个公开缺陷(尚未修复)。试着将你的公开简历更新到最新版本,缺陷记录中提到了部分修复,这可能会帮助你克服这个问题。
发布于 2015-07-31 21:23:33
Mat image;
Mat processedImage;全球宣言才是问题所在。打电话
image.release();
processedImage.release(); 在
return 0;主要是。这个问题似乎与最近的opencv3.0有关(我同时使用了alpha和beta,以及RC1版本,它们没有给出任何这样的错误)。
https://stackoverflow.com/questions/31397482
复制相似问题