【OpenCV】"(_Ptr_user&(_BIG_ALLOCATION_ALIGNMENT - 1)) ==0" && 0

在使用VS2015+OpenCV2410时,会报如下错误,而用VS2013时不会,网上说是兼容性问题。

void extractfeatures::extractKeypoints(cv::Mat _frame, cv::Mat _object)
{
    //Extract keypoints
    cv::Ptr::FeatureDetector> detector;
    cv::Ptr::AKAZE> akaze = cv::AKAZE::create();
    std::vector::KeyPoint> object_keypoints, background_keypoints;
    cv::Mat desc1, desc2;
    akaze->detectAndCompute(_object, cv::noArray(), object_keypoints, desc1);
    akaze->detectAndCompute(_frame, cv::noArray(), background_keypoints, desc2);
}
Expression: "(_Ptr_user&(_BIG_ALLOCATION_ALIGNMENT - 1)) ==0" && 0

查遍各大网站,在角落里挖到正确解决办法

Because the memory of vector is limited, there are too many keypoints. If the keypoints are about 10000:

object_keypoints.reserve(10000);
background_keypoints.reserve(10000)

简单来说就是给vector分配的内存有限,而特征点太多

你可能感兴趣的:(OpenCV)