2015-10-19 65 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謝謝你幫我做到這一點。