首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调试错误- R6025纯虚拟函数调用(没有虚拟调用)

调试错误- R6025纯虚拟函数调用(没有虚拟调用)
EN

Stack Overflow用户
提问于 2015-07-14 04:09:31
回答 2查看 1.6K关注 0票数 1

我是C++的新手,我正在尝试浏览一些我在网上找到的OpenCV教程。我生成的代码与在Visual 2013中找到的完全一样,并且能够正确运行代码。但是,我一直收到一个错误:

(按“重试”调试应用程序)调试错误! 程序:...rface_Basics\x64\Debug\OpenCV_Basics_CPP_Interface_Basics.exe R6025 -纯虚函数调用 (按“重试”以调试应用程序)

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

代码语言:javascript
复制
#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。

如能帮助解决这一问题,将不胜感激。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-07-14 05:57:54

使用静态或全局Mat导致问题。

我发现了问题

代码语言:javascript
复制
>    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中的一个公开缺陷(尚未修复)。试着将你的公开简历更新到最新版本,缺陷记录中提到了部分修复,这可能会帮助你克服这个问题。

票数 2
EN

Stack Overflow用户

发布于 2015-07-31 21:23:33

代码语言:javascript
复制
    Mat image;
    Mat processedImage;

全球宣言才是问题所在。打电话

代码语言:javascript
复制
    image.release();
    processedImage.release(); 

代码语言:javascript
复制
    return 0;

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31397482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档