调试错误-R6025纯虚拟函数调用(未调用虚拟函数)

Debug error - R6025 pure virtual function call (No virtual called)

本文关键字:虚拟 调用 函数 函数调用 错误 -R6025 调试      更新时间:2023-10-16

我是C++的新手,正在尝试学习我在网上找到的一些OpenCV教程。我生成的代码与Visual Studio 2013中的代码完全一样,并且能够正确运行代码。然而,我不断得到一个错误:

(按"重试"调试应用程序(调试错误!

程序:…rface_Basics\x64\Debug\OpenCV_Basics_PP_Interface_Basics.exe

R6025-纯虚拟函数调用

(按"重试"调试应用程序(

我读到了关于纯虚拟函数的文章,听起来你至少必须声明一个虚拟函数才能发生这个错误,这只会导致更多的混乱。以下是我的代码:

#include <opencv2opencv.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。

如果能为解决这一问题提供任何帮助,我们将不胜感激。

使用导致问题的静态或全局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中的一个公开缺陷(尚未修复(。试着将你打开的简历更新到最新版本,缺陷记录中提到了部分修复,可能会帮助你克服这个问题。

    Mat image;
    Mat processedImage;

这一全球宣言就是问题所在。呼叫

    image.release();
    processedImage.release(); 

之前

    return 0;

总的来说。这个问题似乎与最近的opencv3.0有关(我使用了alpha和beta版本,以及RC1版本,他们没有给出任何这样的错误(。