Debug Assertion Failed Expression: _pFirstBlock == pHead using OpenCV and C++ trying to call SurfFeatureDetector

前端 未结 3 1770
春和景丽
春和景丽 2021-02-09 01:24

I have this function in C++ using OpenCV:

vector test(Mat img)
{
  int minHessian = 400;
  SurfFeatureDetector detector( minHessian );

  vector&         


        
3条回答
  •  伪装坚强ぢ
    2021-02-09 02:12

    I also had the same Debug Assertion Failed (dbgheap.c Line:1424 Expression: _pFirstBlock == pHead). I am using Visual Studio 2012 Professional (vc11) to compile with OpenCV 2.4.9.

    int main(){
        SurfFeatureDetector detector(50);
        std::vector keypoints[502];
        //In my case, some ranges in for-loop may success without Assertion failed.
        for(int j=0;j<502;j++){
            sprintf(filename, "../../%06d.bmp", j);
            img[j] = imread(filename);
            detector.detect(img[j], keypoints[j]);
            waitKey(10);
        }
        printf("leaving main()\n");
        //Debug Assertion Failed after leaving main()
    }
    

    My mistake is that I set the system PATH variable to OpenCV x64 path (c:\opencv\build\x64\vc11\bin) but I linked my code with x86 libs in VC2012 project.

    After redefine the PATH variable in Windows to correct OpenCV x86 path (c:\opencv\build\x86\vc11\bin) and restart my VC2012, the Assertion failed of dbgheap.c(1424) will not happened again.

    @TheMotivation, Your answer inspired me. Thank you.

提交回复
热议问题