0
votes

when I try debug my project, I get Debug Assertion Failed, at the end of the execution up. You can see it below.

Debug Assertion Filed

I think that the problem is related to FAST function from OpenCV, because when I comment out the line which contains this function, it works fine.

This is my code:

#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;
}

I build my project in Visual Studio 2015 Preview.

When I clicked "Retry" to break at that assertion, I got the following exception:

Unhandled exception at 0x00007FF851891B4B (ucrtbased.dll) in 

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

This is in xmemory0 file from VS in 120 line.

1
Was opencv built with Visual Studio 2015? - drescherjm
Also when you get the popup error hit retry and then look at the callstack up to your code to see exactly what line in your code is causing the problem. - drescherjm
@drescherjm Yes, but only with preview. With new VS2015 it doesn't work. Here is the screen from callstack i.stack.imgur.com/pAo65.png - B.Kosmowski
Line 133 in my project is return 0; - B.Kosmowski
The error looks like some type of heap corruption. - drescherjm

1 Answers

2
votes

I found the answer. I changed in Property Pages in my project Platform Toolset from Visual Studio 2015 (v140) to Visual Studio 2013 (v120). Now it works fine. It seems that the problem wasn't in FAST function, but in this case, that I use VS 2015 with OpenCV 3.0. @drescherjm thank you for help me do this.