ICP :: registerModelToScene()无法运行最小示例

时间:2019-04-05 09:37:18

标签: opencv opencv-contrib

这是调用registerModelToScene()的一个最小示例,它封装在OpenCV贡献模块 surface matching 的类cv::ppf_match_3d::ICP中:

#include <opencv2/surface_matching/icp.hpp>
#include <opencv2/surface_matching/ppf_helpers.hpp>

int main() {
    /* allocate solver */
    cv::ppf_match_3d::ICP iterativeClosestPoint;

    /* reference vertices */
    cv::Mat reference = cv::ppf_match_3d::loadPLYSimple("reference.ply", 1);
    /* measured vertices */
    cv::Mat measurement = cv::ppf_match_3d::loadPLYSimple("measurement.ply", 1);

    /* do the magic */
    double error;
    cv::Matx44d transformation;
    iterativeClosestPoint.registerModelToScene(reference, measurement, error, transformation);

    return 0;
}

要与(reference.ply)匹配的顶点以多边形文件格式给出,并且仅用法线表示两个点:

ply
format ascii 1.0
element vertex 2
property float x
property float y
property float z
property float nx
property float ny
property float nz
end_header
0 0 0 0 0 1
0 1 0 0 0 1

需要匹配的顶点以相同的文件格式,相同的两个点给出,并绕z轴旋转20°:

ply
format ascii 1.0
element vertex 2
property float x
property float y
property float z
property float nx
property float ny
property float nz
end_header
0 0 0 0 0 1
0.3429 0.93937 0 0 0 1

代码在GCC 8.2.0,OpenCV版本4.0.0上编译。

运行时错误:

OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.0.0) Error: Assertion failed (dataset.type() == CvType<ElementType>::type()) in GenericIndex, file C:/Users/maxherrman/openCV/4.0.0/modules/flann/include/opencv2/flann.hpp, line 316

在answers.opencv.org上,有一个post指出registerModelToScene()Mat)的前两个参数的元素数据类型必须与第四个参数的元素数据类型匹配(Matx44d

但是documenation说:

  

当前,CV_32F是唯一受支持的数据类型。

因此模型和场景(CV_32F)的元素的数据类型与姿势(double)中的元素的数据类型不匹配。

有什么想法可以解决这个问题,还是我弄错了?

1 个答案:

答案 0 :(得分:0)

即使错误并没有说明该数据,您也没有足够的算法数据