gpt4 book ai didi

c++ - Opencv 功能匹配在 iPhone 上中断,但在模拟器上没有

转载 作者:行者123 更新时间:2023-11-28 04:20:24 25 4
gpt4 key购买 nike

我有 Opencv C++ 代码在一个 .mm 文件中运行,带有一个桥接器以在 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>

关于c++ - Opencv 功能匹配在 iPhone 上中断,但在模拟器上没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55572773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com