0

我正在編譯一個使用PCL和OPENCV的開源C++程序。問題似乎是不同特徵對象之間的類型轉換。YOU_MIXED_DIFFERENT_NUMERIC_TY與VS 2010一起使用PCL的錯誤

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

代碼有關的本徵在該程序:

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> C:\程序文件(86)\ PCL
1.6.0 \ 3rdparty \ e IGEN \包括\固有\ SRC \芯\ matrix.h(294):錯誤C2338:
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_ TO_CAST_NUMERIC_TYPES_EXPLICITLY 1> F:\ CPPS \ win32project1 \ win32project1 \ jointpointcloud.cpp(88):見
參照功能模板實例
'本徵::矩陣< _Scalar,_Rows,_Cols> ::矩陣(常量
徵:: MatrixBase &)' 被編譯 1>使用 1> [ 1> _Scalar =浮子, 1> _Rows = 4, 1> _Cols = 4, 1>派生=徵::矩陣 1>] 1> F:\ CPPS \ win32project1 \ win32project1 \ jointpointcloud.cpp(88):見
參考起作用模板實例
「本徵::矩陣< _Scalar, _Rows,_Cols> ::矩陣(常量
徵:: MatrixBase &)」被編譯 1>使用 1> [ 1> _Scalar =浮子, 1> _Rows = 4, 1> _Cols = 4, 1> Derived = Eigen :: Matrix 1>] ==========構建:0成功,1失敗,0最新,0跳過==========

+0

這一步可能是一個問題'T =角度;'。相反,你應該使用'T =(Eigen :: Isometry3d)角度;' –

+0

你能更具體哪一行實際上導致問題? @TheApache提到的行不涉及數字類型轉換,所以我不認爲這是錯誤的原因。 – chtz

+0

歡迎來到StackOverflow!請向我們提供有關您的問題的更多信息。特別是,請發佈[mcve]和您收到的_full_錯誤消息。根據所提供的信息,我們目前無法確定問題所在。 – mindriot

回答

0

PCL 1.6中的transformPointCloud方法期望轉換矩陣採用浮點格式(link)。 你需要寫

pcl::transformPointCloud(*cloud1, *output, T.cast<float>()); 

.matrix()轉換實際上是沒有必要的。

+0

這完全解決了這個錯誤。謝謝你,謝謝。 – user18441