ICP::registerModelToScene() 未能达到 运行 最小示例
ICP::registerModelToScene() fails to run minimum example
这里是调用registerModelToScene()
的最小示例,包含在OpenCV贡献模块classcv::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 说:
Currently, CV_32F is the only supported data type.
因此模型和场景元素的数据类型(CV_32F
)与姿势中元素的数据类型(double
)不匹配。
知道如何避免这个问题,还是我做错了什么?
你没有足够的数据用于算法,即使错误没有说明
这里是调用registerModelToScene()
的最小示例,包含在OpenCV贡献模块classcv::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 说:
Currently, CV_32F is the only supported data type.
因此模型和场景元素的数据类型(CV_32F
)与姿势中元素的数据类型(double
)不匹配。
知道如何避免这个问题,还是我做错了什么?
你没有足够的数据用于算法,即使错误没有说明