【问题标题】:Debug error - R6025 pure virtual function call (No virtual called)调试错误 - R6025 纯虚函数调用(没有虚调用)
【发布时间】:2015-07-14 04:09:31
【问题描述】:

我是 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;
        }
    }
}

我尝试从主函数中删除参数并完成上面引用中提供的调试过程。但是,它只是调用这个 crt0msg.c 文件并突出显示 #ifdef _DEBUG 部分的案例 1。

任何解决此问题的帮助将不胜感激。

【问题讨论】:

  • 记录在案,Ubuntu 14.04 和 Opencv 3.0.0 上的相同错误。似乎已考虑在内,请参阅@DeJaVo 答案中的链接,让我们等待下一个版本。

标签: c++ opencv visual-studio-2013 pure-virtual r6025


【解决方案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 调用移至主函数即可解决问题。
  • 参考您的链接,似乎还有关于 matrix.cpp 和 ocl.cpp 文件的代码的工作正在尝试实际解决问题。虽然当前的补丁对我不起作用,但遵循以下链接上的 cmets 应该可以找到最终解决方案。日期。github.com/Itseez/opencv/pull/4136
【解决方案2】:
    Mat image;
    Mat processedImage;

全局声明是问题所在。打电话

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

之前

    return 0;

主要是。这个问题似乎与最近的 opencv3.0 有关(我同时使用了 alpha 和 beta,以及 RC1 版本,他们没有给出任何此类错误)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    • 2012-07-01
    • 1970-01-01
    • 2012-03-20
    相关资源
    最近更新 更多