2015-10-19 192 views
0

当我尝试调试我的项目时,我得到Debug Assertion Failed,在执行结束时。你可以在下面看到它。FAST函数OpenCV Debug Assertion Faild

Debug Assertion Filed

我认为这个问题是从OpenCV的,与FAST功能,因为当我注释掉包含此功能的线,它工作正常。

这是我的代码:

#pragma once 
#include <opencv2/core/core.hpp> 
#include <opencv2/imgcodecs.hpp> 
#include <opencv2/highgui/highgui.hpp> 
#include <opencv2/opencv.hpp> 
#include <iostream> 
#include <string> 
using namespace cv; 
using namespace std; 
int main() 
{ 
    string table[2] = { "background_2.jpg","foreground_2.jpg" }; 
    Mat firstImage = imread(table[0], IMREAD_COLOR); 
    Mat secondImage = imread(table[1], IMREAD_COLOR); 
    Mat result; 
    subtract(firstImage, secondImage, result); 
    Mat resultGray, firstImageGray, secondImageGray; 

    cvtColor(firstImage, firstImageGray, COLOR_BGR2GRAY); 
    cvtColor(secondImage, secondImageGray, COLOR_BGR2GRAY); 
    cvtColor(result, resultGray, COLOR_BGR2GRAY); 

    Canny(firstImageGray, firstImageGray, 33, 100, 3); 
    Canny(secondImageGray, secondImageGray, 33, 100, 3); 
    Canny(resultGray, resultGray, 33, 100, 3); 


    vector <KeyPoint> keyPoints; 
    FAST(resultGray, keyPoints, 9, true);//Probably here is the problem. 
    Mat resultKeyPoints; 
    drawKeypoints(resultGray, keyPoints, resultKeyPoints, 156); 

    return 0; 
} 

我建我的项目在Visual Studio 2015年预览。

当我点击“重试”,在这一断言突破,我有以下异常:

Unhandled exception at 0x00007FF851891B4B (ucrtbased.dll) in 

OpenCVProject.exe: An invalid parameter was passed to a function that considers invalid parameters fatal. 

这是从VS 120线xmemory0文件。

+1

使用Visual Studio 2015构建opencv吗? – drescherjm

+0

此外,当你得到弹出错误命中重试,然后看看你的代码的调用堆栈确切地看到代码中的哪一行导致了这个问题。 – drescherjm

+0

@drescherjm是的,但只有预览。新的VS2015不起作用。 这是来自callstack的屏幕http://i.stack.imgur.com/pAo65.png –

回答

2

我找到了答案。我在Property Pages中更改了我的项目Platform ToolsetVisual Studio 2015 (v140)Visual Studio 2013 (v120)。现在它工作正常。看来问题不在FAST功能,但在这种情况下,我使用VS 2015OpenCV 3.0。 @drescherjm谢谢你帮我做到这一点。