我最近在 opencv 的ORB描述符中发现了一些非常奇怪的行为。
cv::Mat grey; //greyscale image
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
cv::ORB detector;
detector(grey,cv::Mat(),keypoints,descriptors);
如果给定的图像不包含潜在的关键点(例如黑色图像)并出现错误,则上述代码始终崩溃
OpenCV Error: Assertion failed (m.dims >= 2) in Mat, file /Users/user/slave/ios_framework/src/opencv/modules/core/src/matrix.cpp, line 268
我发现要解决问题,我可以执行以下操作
cv::Mat grey;
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
cv::ORB detector;
detector(grey,cv::Mat(),keypoints);
if(keypoints.size() > 0)
{
detector(grey,cv::Mat(),keypoints,descriptors,true);
}
它首先检测关键点,然后在检测到任何关键点时生成它们的描述符。我在 iOS 上使用 opencv2 作为 .framework。
这是 OpenCV 中的错误吗?如果没有,我做错了什么?如果是这样,是否有修复它的任何版本?