OpenCV ios project crash

1.1k views Asked by At

i have build OpenCV framework for IOS and i am learning OpenCV from scratch, the framework compiled well and when i am running this code :

IplImage *img = cvLoadImage("dpad_off.png");
cvNamedWindow("Example1",CV_WINDOW_NORMAL);
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");

the app crash with this log :

OpenCV Error: Unspecified error (The function is not implemented.
Rebuild the library with Windows, GTK+ 2.x or Carbon support.
If you are on Ubuntu or Debian, install libgtk2.0-dev andpkg-config,
then re-run cmake or configure script) in cvNamedWindow, file            /Volumes/minijHome/Documents/xcode_mini/hillegass/advancedIOS/postCourse/openCV/clean-     downloads/openCVgitClone/opencv/modules/highgui/src/window.cpp, line 652
libc++abi.dylib: terminate called throwing an exception

i have tried to look for answer on the web but cant figure out why this is happen. any idea ?

2

There are 2 answers

0
berak On BEST ANSWER

bear with me for not knowing anything about ios, but:

the error says, that the highgui module was built without any gui support, so you can't use:

  1. cvNamedWindow
  2. cvShowImage
  3. cvWaitKey

hold your breath, that's all ok even.

basically what you're trying now, is to use desktop functions in a phone api.

i'm sure, that there are proper replacements for that in the ios api, just take a read here

0
Nupur Sharma On

Change your .m class to .mm to use c++ methods. Then import the below two libraries in both classes i.e .h objective c and objective c++ wrapper class:

#import <opencv2/opencv.hpp>
#import <opencv2/imgcodecs/ios.h>