error C2039: “type”: 不是“cv::DataType ”的成員 解決辦法


編譯opencv4.0.x版本的程序時,由於個人疏忽致使opencv 函數參數順序調用錯誤,但是編譯時沒有提示該語句參數順序錯誤,提示以下錯誤:

g:\library\opencv-master\build\install\include\opencv2\core\traits.hpp(386): error C2039: “type”: 不是“cv::DataType<T>”的成員
1> with
1> [
1> T=cv::KeyPoint
1> ]
1> g:\library\opencv-master\build\install\include\opencv2\core\traits.hpp(386): note: 參見“cv::DataType<T>”的聲明
1> with
1> [
1> T=cv::KeyPoint
1> ]
1> g:\library\opencv-master\build\install\include\opencv2\core\mat.inl.hpp(95): note: 參見對正在編譯的類 模板 實例化“cv::traits::Type<_Tp>”的引用
1> with
1> [
1> _Tp=cv::KeyPoint
1> ]
1> g:\project\rewptis\rewptis\rewptis.cpp(192): note: 參見對正在編譯的函數 模板 實例化“cv::debug_build_guard::_InputArray::_InputArray<cv::KeyPoint>(const std::vector<cv::KeyPoint,std::allocator<_Ty>> &)”的引用
1> with
1> [
1> _Ty=cv::KeyPoint
1> ]
1>g:\library\opencv-master\build\install\include\opencv2\core\traits.hpp(386): error C2065: “type”: 未聲明的標識符

解決辦法:

這種無法定位到指定代碼的錯誤,需要對代碼進行分段注釋,查找出錯代碼段,然后仔細校驗函數參數即可;

我的出錯函數為:

cv::drawMatches(imageList[edge.first].getMat(cv::ACCESS_READ), imageList[edge.second].getMat(cv::ACCESS_READ), keypoints[edge.first], keypoints[edge.second], matches[i], img_matches);

正確的為:

cv::drawMatches(imageList[edge.first].getMat(cv::ACCESS_READ), keypoints[edge.first], imageList[edge.second].getMat(cv::ACCESS_READ),  keypoints[edge.second], matches[i], img_matches);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM