Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 功能描述教程无法使用opencv_C++_Debugging_Opencv_Crash - Fatal编程技术网

C++ 功能描述教程无法使用opencv

C++ 功能描述教程无法使用opencv,c++,debugging,opencv,crash,C++,Debugging,Opencv,Crash,我在opencv.com上尝试了有关功能描述的教程,程序崩溃,出现错误: Debug assertion failed , Expression: vector iterator outside range 排队_ detector.detect(img_1, keypoints_1); 我在Visual Studio 2010中使用OpenCV 2.4.11,并链接到库目录C:\OpenCV\build\x86\vc10\lib中的OpenCV\u 2411d.lib库 代码如下: #in

我在opencv.com上尝试了有关功能描述的教程,程序崩溃,出现错误:

Debug assertion failed , Expression: vector iterator outside range
排队_

detector.detect(img_1, keypoints_1);
我在Visual Studio 2010中使用OpenCV 2.4.11,并链接到库目录
C:\OpenCV\build\x86\vc10\lib中的
OpenCV\u 2411d.lib

代码如下:

#include <iostream>
#include <stdio.h>
#include <opencv2\core\core.hpp>
#include <opencv2\features2d\features2d.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\nonfree\features2d.hpp>
#include <opencv2\legacy\legacy.hpp>

using namespace cv;
using namespace std;



int main(int argc, char ** argv)
{
    Mat img_1 = imread("3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
    Mat img_2 = imread("2.jpg", CV_LOAD_IMAGE_GRAYSCALE);

    if (!img_1.data || !img_2.data)
    {
        cout << " Nu au fost afisate imaginile" << endl;
        return -1;
    }

    int minHessian = 400;
    imshow("1.png", img_1);
    imshow("2.png", img_2);


    SurfFeatureDetector detector(minHessian);

    vector<KeyPoint> keypoints_1, keypoints_2;

    detector.detect(img_1, keypoints_1);
    detector.detect(img_2, keypoints_2);

    //-- Step 2: Calculate descriptors (feature vectors)
    SurfDescriptorExtractor extractor;

    Mat descriptors_1, descriptors_2;

    extractor.compute(img_1, keypoints_1, descriptors_1);
    extractor.compute(img_2, keypoints_2, descriptors_2);

    //-- Step 3: Matching descriptor vectors with a brute force matcher
    BFMatcher matcher(NORM_L2);
    vector< DMatch > matches;
    matcher.match(descriptors_1, descriptors_2, matches);

    //-- Draw matches
    Mat img_matches;
    drawMatches(img_1, keypoints_1, img_2, keypoints_2, matches, img_matches);

    //-- Show detected matches
    imshow("Matches", img_matches);

    waitKey(0);

    return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间cv;
使用名称空间std;
int main(int argc,字符**argv)
{
Mat img_1=imread(“3.jpg”,CV_LOAD_IMAGE_GRAYSCALE);
Mat img_2=imread(“2.jpg”,CV_LOAD_IMAGE_GRAYSCALE);
如果(!img_1.data | |!img_2.data)
{

我敢打赌您有opencv 3.0,而本教程来自opencv 2.4.Xpost,同时也会显示错误消息。(您还应该更新到最新版本。)错误“调试断言失败,表达式:向量迭代器超出范围”。如果你看上面的图像,你会看到它崩溃的地方。我的错误是,我让opencv 2.4.11也发布了你的库目录C:\opencv\build\include-at可执行目录;C:\opencv\build\x86\vc10\lib-at include目录;opencv\u core2411d.lib opencv\u imgproc2411d.lib opencv\u highgui2411d.lib opencv\u特性2411.lib opencv\u calib3d2411.lib,链接器上的opencv_nonfree2411d.lib