error in ICP

asked 2018-01-09 09:09:17 -0600

updated 2018-01-10 02:20:26 -0600

berak gravatar image

Hello,

i want to use the icp algorothm. But there is a error. Can someone tell me what should i do. Thank you!

#include <opencv2/core.hpp>
#include <iostream>
#include <cv.h> 
#include <vector> 
#include "opencv2/surface_matching/icp.hpp"
#include "opencv2/surface_matching/pose_3d.hpp"
#include <stdio.h>  
#include <stdlib.h>  
#include "flann.hpp"


using namespace cv;
using namespace ppf_match_3d;
using namespace std;

int main()
{

    try {
        float m2[4][6] = { { 1,     1,    0,    1,    1,    1 },{ 2 ,    2   ,  0,    1  ,  1,    1 },{ 2, 1,  0  ,  1 ,   1 ,   1 },{ 1 ,    2 ,    0  ,   1,     1,     1 } };
        float m1[4][6] = { { 1,     1,    0,    1,    1,    1 },{ 2 ,    2   ,  0,    1  ,  1,    1 },{ 2, 1,  0  ,  1 ,   1 ,   1 },{ 1 ,    2 ,    0  ,   1,     1,     1 } };
        Mat M1 = cv::Mat(4, 6, CV_32F, m1);
        Mat M2 = cv::Mat(4, 6, CV_32F, m2);
        double re;
        Matx44d pose1;

        vector<Pose3DPtr> resultsSub;
        cv::ppf_match_3d::ICP calculate(100, 0.005f, 2.5f, 8);
        calculate.registerModelToScene(M1, M2, re, pose1);

    }
    catch (cv::Exception ex) {
        std::cout << ex.msg << std::endl;
        std::getchar();
    }
    return 0;
}

error is:

OpenCV Error: Assertion failed (dataset.type() == CvType<ElementType>::type()) in cv::flann::GenericIndex<struct cvflann::L2<float> >::GenericIndex, file C:\Users\XIAOBME\open\opencv\sources\modules\flann\include\opencv2/flann.hpp, line 253

C:\Users\open\opencv\sources\modules\flann\include\opencv2/flann.hpp:253
: error: (-215) dataset.type() == CvType<ElementType>::type() in function cv::flann::GenericIndex<struct cvflann::L2<float> >::GenericIndex
edit retag flag offensive close merge delete

Comments

1

thanks for your answer, now you can see the text of my error

laurin1993 gravatar imagelaurin1993 ( 2018-01-10 02:20:07 -0600 )edit
1

i guess, if your pose1 Mat is double, you have to use double for M1 and M2, too.

berak gravatar imageberak ( 2018-01-10 02:25:32 -0600 )edit