[英]Debug error - R6025 pure virtual function call (No virtual called)
我是C ++的新手,正在嘗試瀏覽我在網上找到的一些OpenCV教程。 我完全按照Visual Studio 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;
}
}
}
我已經嘗試從main函數中刪除參數並完成上面引用中提供的調試過程。 但是,它只調用此crt0msg.c文件並突出顯示#ifdef _DEBUG部分的案例1。
任何幫助解決這個問題將不勝感激。
使用導致問題的靜態或全局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中的一個開放缺陷(尚未修復)。 嘗試將您的開放式CV更新到最新版本,缺陷記錄提及可能有助於您解決此問題的部分修復。
Mat image;
Mat processedImage;
那個全球宣言就是問題所在。 呼叫
image.release();
processedImage.release();
之前
return 0;
在主要。 這個問題似乎與最近的opencv3.0有關(我曾經使用過alpha和beta版本,RC1版本並沒有給出任何此類錯誤)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.