簡體   English   中英

OpenCV KeyPoints斷言

[英]OpenCV KeyPoints assertion

我正在嘗試使用opencv 2.4.10在c ++中實現一個代碼,該代碼使用ORB計算框架的關鍵點。 當我在VS community 2015中運行代碼時,它給了我斷言:

程序:... l Studio 2015 \\ Projects \\ lbplibrary-master \\ x64 \\ Debug \\ prova1.exe文件:c:\\ program files(x86)\\ microsoft visual studio 14.0 \\ vc \\ include \\ xmemory0行:106

表達式:“((_ Ptr_user&(_BIG_ALLOCATION_ALIGNMENT-1))== 0” && 0

有關程序如何導致斷言失敗的信息,請參見有關斷言的Visual C ++文檔。

這是我正在編譯的代碼。 執行工作並完成了工作,但最后我得到了斷言!

#include <iostream>
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <string>
#include <fstream>
#include <opencv2/opencv.hpp>

#include "stdafx.h"


using namespace cv;
using namespace std;
using namespace lbplibrary;

static bool isFileExist(const String& filename)

{
    /// Open the file
    FILE* f = fopen(filename.c_str(), "rb");

    /// in the event of a failure, return false
    if (!f)
        return false;

    fclose(f);

    return true;
}


string intToStr(int i, string path) {

    string bla = "";
    stringstream ss;
    ss << i;
    string ret = "";
    ss >> ret;
    string name = bla.substr(0, bla.size() - ret.size());

    name = path + name + ret;
    return name;
}


int main(int argc, const char **argv)
{


    //keyframe
    string current_window = "Current frame ";
    Mat Current;


    //keypoints
    vector<KeyPoint> kp;
    Ptr<ORB> detector = FeatureDetector::create("ORB");

    fstream outputFile;

    //elaborate keyframes

    for (int i = 0; i< 178; i++)
    {

        //read and show keyframe 

        string Curr_name = intToStr(i, "dataset/backyard-seq/map/frame");
        Current = imread(Curr_name + ".jpg", 1);
        namedWindow(current_window, WINDOW_AUTOSIZE);
        imshow(current_window, Current);

        //calculate frame keypoints

        detector->detect(Current, kp);

        //save keypoints of each keyframe in txt

        if (!isFileExist(Curr_name + ".txt"))
        {
            outputFile.open(Curr_name + ".txt", ios::out);
            for (size_t ii = 0; ii < kp.size(); ++ii)
                outputFile << kp[ii].pt.x << " " << kp[ii].pt.y << std::endl;
            outputFile.close();
        }

        //draw and show keypoints

        Mat out;
        drawKeypoints(Current, kp, out, Scalar::all(255));
        imshow("Keypoints", out);


    }


    return 0;
}

您正在使用Visual Studio 2015,這意味着vc14編譯器。

OpenCV 2.4.10沒有為此預先構建的二進制文件,而僅針對vc10 (Visual Studio 2010), vc11 (Visual Studio 2012)和vc12 (Visual Studio 2013)。

因此,您有幾種選擇:

  1. 使用Visual Studio 2010、2011、2012鏈接正確的庫
  2. 使用vc14編譯OpenCV,並將其與Visual Studio 2015一起使用。
  3. 如果是這樣的話,您可以切換到OpenCV 3.1,它已經為vc14 64bit預構建了二進制文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM