下面是一个调用registerModelToScene()的最小示例,包含在OpenCV贡献模块曲面匹配的类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上,有一个帖子声明,registerModelToScene() (Mat)的前两个参数的元素数据类型需要与来自第四个参数(Matx44d)的数据类型相匹配。
但是文献化说:
目前,CV_32F是唯一受支持的数据类型。
因此,模型和场景元素(CV_32F)的数据类型与姿态中元素(double)的数据类型不匹配。
你知道怎么绕过这个问题吗,还是我弄错了?
发布于 2020-01-28 13:17:45
您没有足够的数据用于该算法,即使错误没有声明
https://stackoverflow.com/questions/55532416
复制相似问题