簡體   English   中英

Opencv功能匹配在iPhone上打破,但在模擬器上沒有

[英]Opencv feature matching breaks on iPhone but not on simulator

我有一個運行在.mm文件中的Opencv C ++代碼,它有一個可以在iPhone上運行的橋接器。 在模擬器中,它工作正常,沒有問題。 在iPhone上運行時,它會中斷。 這是代碼

 int minHessian = 400;
Ptr<cv::xfeatures2d::SURF> detector = cv::xfeatures2d::SURF::create( minHessian );
std::vector<KeyPoint> keypoints1, keypoints2;
Mat descriptors1, descriptors2;
detector->detectAndCompute( img1, noArray(), keypoints1, descriptors1 );
detector->detectAndCompute( img2, noArray(), keypoints2, descriptors2 );
//-- Step 2: Matching descriptor vectors with a FLANN based matcher
// Since SURF is a floating-point descriptor NORM_L2 is used
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(DescriptorMatcher::FLANNBASED);
std::vector< std::vector<DMatch> > knn_matches;
matcher->knnMatch( descriptors1, descriptors2, knn_matches, 2 );
//-- Filter matches using the Lowe's ratio test
const float ratio_thresh = 0.8f;
std::vector<DMatch> good_matches;
for (size_t i = 0; i < knn_matches.size(); i++)
{
    if (knn_matches[i][0].distance < ratio_thresh * knn_matches[i][1].distance)
    {
        good_matches.push_back(knn_matches[i][0]);
    }
}

它明確打破了這條線

matcher->knnMatch( descriptors1, descriptors2, knn_matches, 2 );

錯誤日志將此指定為錯誤

libc++abi.dylib: terminating with uncaught exception of type cvflann::anyimpl::bad_any_cast

您必須刪除#import opencv2/opencv.hpp並添加所需的特定模塊。 在我的情況下,我需要這些文件

#import <opencv2/imgcodecs.hpp>
#import <opencv2/calib3d.hpp>
#import <opencv2/features2d.hpp>
#import <opencv2/xfeatures2d.hpp>
#import <opencv2/imgproc/imgproc.hpp>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM