編譯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」: 未聲明的標識符
解決辦法:ui
這種沒法定位到指定代碼的錯誤,須要對代碼進行分段註釋,查找出錯代碼段,而後仔細校驗函數參數便可;debug
個人出錯函數爲:code
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);
正確的爲:blog
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);