error C2039: “type”: 不是“cv::DataType<T>”的成员 解决办法

编译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);
posted @ 2019-03-18 16:16  氕氘钏  阅读(3708)  评论(0编辑  收藏  举报