Opencv曲面匹配

时间:2017-01-20 07:29:08

标签: c++ opencv

我正在研究3d点云,我正在使用opencv表面匹配模块但是我有一个我无法理解的错误 我的代码是:

NO_ERROR

我的错误:(当代码是这些行时:

#include "stdafx.h"
#include <iostream>
#include <vector>
#include "opencv2/core/utility.hpp"
#include "opencv2\opencv_modules.hpp"
#include "opencv2\surface_matching.hpp"
#include "opencv2\surface_matching\ppf_helpers.hpp"
using namespace std;
using namespace cv;
using namespace cv::ppf_match_3d;


static void help(const string& errorMessage)
{
    cout << "Program init error : " << errorMessage << endl;
    cout << "\nUsage : ppf_matching [input model file] [input scene file]" << endl;
    cout << "\nPlease start again with new parameters" << endl;
}

int main(int argc, char** argv)
{
    // welcome message
    cout << "****************************************************" << endl;
    cout << "* Surface Matching demonstration : demonstrates the use of surface matching"
            " using point pair features." << endl;
    cout << "* The sample loads a model and a scene, where the model lies in a different"
            " pose than the training.\n* It then trains the model and searches for it in the"
            " input scene. The detected poses are further refined by ICP\n* and printed to the "
            " standard output." << endl;
    cout << "****************************************************" << endl;

/*  if (argc < 2)
    {
        help("Not enough input arguments");
        exit(1);
    }*/

/*#if (defined __x86_64__ || defined _M_X64)
    cout << "Running on 64 bits" << endl;
#else
    cout << "Running on 32 bits" << endl;
#endif

#ifdef _OPENMP
    cout << "Running with OpenMP" << endl;
#else
    cout << "Running without OpenMP and without TBB" << endl;
#endif*/

    string modelFileName = "C://opencv_contrib-master//modules//surface_matching//samples//data//parasaurolophus_6700";
    string sceneFileName = "C://opencv_contrib-master//modules//surface_matching//samples//data//parasaurolophus_low_normals2";

    Mat pc = loadPLYSimple(modelFileName.c_str(), 1);

    // Now train the model
    cout << "Training..." << endl;
    int64 tick1 = cv::getTickCount();
    ppf_match_3d::PPF3DDetector detector(0.025, 0.05);
    detector.trainModel(pc);
    int64 tick2 = cv::getTickCount();
    cout << endl << "Training complete in "
         << (double)(tick2 - tick1) / cv::getTickFrequency()
         << " sec" << endl << "Loading model..." << endl;

    // Read the scene
    Mat pcTest = loadPLYSimple(sceneFileName.c_str(), 1);

    // Match the model to the scene and get the pose
    cout << endl << "Starting matching..." << endl;
    vector<Pose3DPtr> results;
    tick1 = cv::getTickCount();
    detector.match(pcTest, results, 1.0 / 40.0, 0.05);
    tick2 = cv::getTickCount();
    cout << endl << "PPF Elapsed Time "
         << (tick2 - tick1) / cv::getTickFrequency() << " sec" << endl;

    // Get only first N results
    int N = 2;
    vector<Pose3DPtr> resultsSub(results.begin(), results.begin() + N);

    // Create an instance of ICP
    ICP icp(100, 0.005f, 2.5f, 8);
    int64 t1 = cv::getTickCount();

    // Register for all selected poses
    cout << endl << "Performing ICP on " << N << " poses..." << endl;
    icp.registerModelToScene(pc, pcTest, resultsSub);
    int64 t2 = cv::getTickCount();

    cout << endl << "ICP Elapsed Time "
         << (t2 - t1) / cv::getTickFrequency() << " sec" << endl;

    cout << "Poses: " << endl;
    // debug first five poses
    for (size_t i = 0; i<resultsSub.size(); i++)
    {
        Pose3DPtr result = resultsSub[i];
        cout << "Pose Result " << i << endl;
        result->printPose();
        if (i == 0)
        {
            Mat pct = transformPCPose(pc, result->pose);
            writePLY(pct, "para6700PCTrans.ply");
        }
    }

    return 0;
}

我收到此错误:

enter image description here

2 个答案:

答案 0 :(得分:0)

您似乎使用发布模式来运行程序。 我以前遇到过这个问题。当我改为调试模式。一切都运作良好。

答案 1 :(得分:0)

使用调试模式。通过这些行在t_hash_int.cpp源文件中更改密钥类型

#if (defined x86_64 || defined _M_X64)
typedef uint64_t KeyType;
#else
typedef unsigned int KeyType;
#endif

从源头重新构建 检查以下问题:https://github.com/opencv/opencv_contrib/issues/170