OpenCV - Visual Studio 2015查找轮廓错误

时间:2016-10-18 21:12:19

标签: c++ opencv visual-studio-2015

我在Visual Studio 2015上遇到openCV 3.1的问题。每当我调用函数find contour时,我都会遇到运行时错误。我已经尝试过调查这个问题,而且我发现大多数人都认为将调试配置链接到发布库会导致这种情况,但我确保我没有犯错误(链接opencv_310d.lib)。

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace cv;
using namespace std;

Mat src; Mat src_gray;
int thresh = 100;
int max_thresh = 255;
RNG rng(12345);

/// Function header
void thresh_callback(int, void*);

/** @function main */
int main(int argc, char** argv)
{
    /// Load source image and convert it to gray
    src = imread("security.png", 1);

    /// Convert image to gray and blur it
    cvtColor(src, src_gray, CV_BGR2GRAY);
    blur(src_gray, src_gray, Size(3, 3));

    /// Create Window
    char* source_window = "Source";
    namedWindow(source_window, CV_WINDOW_AUTOSIZE);
    imshow(source_window, src);

    createTrackbar(" Canny thresh:", "Source", &thresh, max_thresh, thresh_callback);
    thresh_callback(0, 0);

    waitKey(0);
    return(0);
}

/** @function thresh_callback */
void thresh_callback(int, void*)
{
    Mat canny_output;
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;

    /// Detect edges using canny
    Canny(src_gray, canny_output, thresh, thresh * 2, 3);
    /// Find contours
    findContours(canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));


}

如果我注释掉对findContours()的调用,它似乎运行正常。这可能是一个.dll问题,但我并不完全确定如何解决这个问题。

Error Image

我的项目属性: 配置:活动(调试)平台:Acttive(x64)

C / C ++ =&GT;一般=&GT;其他包含目录:C:\ opencv \ build \ include

链接=&GT;一般=&GT;其他库目录:C:\ opencv \ build \ x64 \ vc14 \ lib

链接=&GT;输入=&GT;其他依赖项:opencv_world310d.lib;%(AdditionalDependencies)

配置:发布

C / C ++ =&GT;一般=&GT;其他包含目录:%(AdditionalIncludeDirectories)

链接=&GT;一般=&GT;其他图书馆目录:%(AdditionalLibraryDirectories)

链接=&GT;输入=&GT;其他依赖项:opencv_world310.lib;%(AdditionalDependencies)

0 个答案:

没有答案