我正在编译一个使用PCL和OPENCV的开源c ++程序。问题似乎是不同特征对象之间的类型转换。
c:\program files (x86)\pcl 1.6.0\3rdparty\eigen\include\eigen\src\core\matrix.h(294): error C2338:
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
程序中关于Eigen的代码:
cv::Mat R;
cv::Rodrigues( result.rvec, R );
Eigen::Matrix3d r;
cv::cv2eigen(R, r);
// 将平移向量和旋转矩阵转换成变换矩阵
Eigen::Isometry3d T = Eigen::Isometry3d::Identity();
Eigen::AngleAxisd angle(r);
cout<<"translation"<<endl;
Eigen::Translation<double,3> trans(result.tvec.at<double>(0,0), result.tvec.at<double>(0,1), result.tvec.at<double>(0,2));
T = angle;
T(0,3) = result.tvec.at<double>(0,0);
T(1,3) = result.tvec.at<double>(0,1);
T(2,3) = result.tvec.at<double>(0,2);
// Transform point clouds
cout<<"converting image to clouds"<<endl;
PointCloud::Ptr cloud1 = image2PointCloud( frame1.rgb, frame1.depth, camera );
PointCloud::Ptr cloud2 = image2PointCloud( frame2.rgb, frame2.depth, camera );
// Combine point clouds
cout<<"combining clouds"<<endl;
PointCloud::Ptr output (new PointCloud());
pcl::transformPointCloud( *cloud1, *output, T.matrix() ); // error occurs at this line, the compiler told.
*output += *cloud2;
错误消息:
1&gt; c:\ program files(x86)\ pcl
1.6.0 \ 3rdparty \ eigen \ include \ eigen \ src \ core \ matrix.h(294):错误C2338:
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_ TO_CAST_NUMERIC_TYPES_EXPLICITLY 1 GT; f:\ cpps \ win32project1 \ win32project1 \ jointpointcloud.cpp(88):见
参考功能模板实例化 &#39;本征::矩阵和LT; _Scalar,_Rows,_Cols&GT; ::矩阵(常量
Eigen :: MatrixBase&amp;)&#39;被编译 1 GT;同 1 GT; [ 1 GT; _Scalar =浮子, 1 GT; _Rows = 4, 1 GT; _Cols = 4, 1 GT;派生=本征::矩阵 1 GT; ] 1 GT; f:\ cpps \ win32project1 \ win32project1 \ jointpointcloud.cpp(88):见
参考功能模板实例化 &#39;本征::矩阵和LT; _Scalar,_Rows,_Cols&GT; ::矩阵(常量
Eigen :: MatrixBase&amp;)&#39;被编译 1 GT;同 1 GT; [ 1 GT; _Scalar =浮子, 1 GT; _Rows = 4, 1 GT; _Cols = 4, 1 GT;派生=本征::矩阵 1 GT; ] ==========构建:0成功,1个失败,0个最新,0个跳过==========
答案 0 :(得分:0)
PCL 1.6中的transformPointCloud
方法期望转换矩阵采用浮点格式(link)。
你需要写
pcl::transformPointCloud( *cloud1, *output, T.cast<float>() );
.matrix()
转换实际上不是必需的。