Opencv HOG运行时异常

时间:2015-12-28 21:21:49

标签: windows visual-studio opencv runtime-error

我有以下代码;

EducateHOG(string file){
    Mat image = imread(file);
    vector <float> desc;
    vector <Point> locs;

    resize(image, image, Size(64,48));
    cvtColor(image, image, CV_BGR2GRAY);
    HogDescriptor hog(Size(32,16), Size(8,8), Size(4,4), Size(4,4), 9);
    hog.compute(image, desc, Size(0,0), Size(0,0), lots); //This cause error
}

它只是读取一个带有汽车的简单图像,但是hog.compute(...)会导致运行时错误,如下所示:

Exception thrown at 0x00007FF... (msvcr120.dll) .... Access violating writing location 0x0000258....

我在Win 10上使用Visual Studio 2015和OpenCv库。我找不到此错误的原因。

1 个答案:

答案 0 :(得分:0)

在项目属性中,您链接Opencv库。在linker -> Input -> Aditional dependencies中确保在调试配置中,您只有opencv _ ** 300d.lib。(每个lib都在&#34; D&#34;)。我也没有opencv_ts300.lib,它构建正常。但是在调试中运行时会在.hog.compute

上抛出异常