Unable to run OpenCV on iOS device (works fine in simulator)

asked 2017-11-15 03:22:24 -0500

rentziass gravatar image

updated 2017-11-15 03:26:06 -0500

Hi all, I recently got into OpenCV for a personal project, and I am now trying to embed what I achieved into an iOS application. I was really happy that I got it to work since these were my very first lines of C++, but can't manage to get it to work outside of simulator. I'm using SURF and a Flann Matcher. The error I get is

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

once I reach this line

#import <opencv2/imgproc/imgproc.hpp>
#import <opencv2/imgcodecs/ios.h>
#import <opencv2/xfeatures2d/nonfree.hpp>

std::vector<cv::Mat> baseDescriptors;
cv::Mat unitDescriptor;

// setup stuff
FlannBasedMatcher matcher;
std::vector<std::vector<DMatch>> matches;
matcher.knnMatch(baseDescriptors[j], unitDescriptor, matches, 2); // <- here is the problem

I've looked at these [1, 2, 3, 4] with no luck. Already stripped down my imports and tried building configuration to Release but still nothing. I find this really weird, since the app runs fine in the simulator at this point I think I'm missing something related to build configuration. Thanks for any kind of help!

edit retag flag offensive close merge delete


I have the same issue, and if change scheme to release and run on Simlulator, will crash again at line: FlannBasedMatcher matcher;

xpiscoder gravatar imagexpiscoder ( 2017-11-21 04:42:18 -0500 )edit