Ask Your Question

Ben Lau's profile - activity

2017-02-15 10:39:08 -0600 received badge  Teacher (source)
2017-02-13 05:31:06 -0600 received badge  Necromancer (source)
2017-02-13 03:17:42 -0600 received badge  Editor (source)
2017-02-13 03:17:10 -0600 answered a question OpenCV 3.2 build for iOS with libjpeg-turbo to be used with Qt

I have tried to build OpenCV 3.2 with libjpeg-turbo 1.3.0. It crashes in imwrite without any error message. Then I fallback to the libjpeg version used by Qt 5.8. That works.

The build Instruction

1) Download opencv 3.2 and opencv contrib 3.2 and extract them:

$ ls opencv-3.2.0 opencv_contrib-3.2.0

2) Download libjpeg source code

Since I have already downloaded the Qt 5.8 source code, I simply use Qt's version.

3) Patch opencv-3.2.0/platforms/ios/build_framework.py

--- build_framework.py.orig 2017-02-13 11:12:14.000000000 +0800
+++ build_framework.py  2017-02-13 11:13:42.000000000 +0800
@@ -135,6 +135,7 @@
             cmakecmd.append("-DENABLE_NEON=ON")
         cmakecmd.append(self.opencv)
         cmakecmd.extend(cmakeargs)
+        cmakecmd.extend(["-DWITH_JPEG=ON", "-DBUILD_JPEG=OFF","-DJPEG_INCLUDE_DIR=/opt/libjpeg-turbo/include", "-DJPEG_LIBRARY=/opt/libjpeg-turbo/lib64/libjpeg.a"])
         execute(cmakecmd, cwd = builddir)
         # Clean and build
         clean_dir = os.path.join(builddir, "install")

You should change the parameter of -DJPEG_INCLUDE_DIR and -DJPEG_LIBRARY according to your environment

-DJPEG_INCLUDE_DIR = Path to the source code

e.g ~/qt-everywhere-opensource-src-5.8.0/qtbase/src/3rdparty/libjpeg

-DJPEG_LIBRARY = Path to the libqjpeg.a from Qt SDK

e.g ~/Qt/5.8/ios/plugins/imageformats/libqjpeg.a

4) Build

cd opencv-3.2.0
mkdir build
cd build
../platforms/ios/build_framework.py ios --contrib=../../opencv_contrib-3.2.0
2015-01-30 01:23:32 -0600 answered a question OpenCV iOS build problem: The opencv2.framework is almost empty

Seem that there has problem in making the libopencv_world.a . It do not include the built module. Finally , I solve this problem by checkout the latest git version instead of using 2.4.9 /2.4.10 .

2015-01-28 01:17:07 -0600 asked a question OpenCV iOS build problem: The opencv2.framework is almost empty

Hi,

I would like to build OpenCV for iOS. I have followed the instruction with those steps

  1. cd /; sudo ln -s /Applications/Xcode.app/Contents/Developer Developer
  2. cd ~/<my_working_directory>; python opencv/platforms/ios/build_framework.py ios

http://docs.opencv.org/doc/tutorials/...

Those step is successfully without any errors. The opencv2.framework was there in the ios folder. However, the file size is just around 2MB.

Then I run nm to check the content:

$ nm ios/opencv2.framework/Versions/Current/opencv2 

ios/opencv2.framework/Versions/Current/opencv2(world_init.o):
0000000000000030 s EH_Frame1
                 U __ZN2cv13initModule_mlEv
                 U __ZN2cv16initModule_videoEv
                 U __ZN2cv18initModule_nonfreeEv
                 U __ZN2cv21initModule_features2dEv
0000000000000000 T __ZN2cv7initAllEv
0000000000000048 s func.eh

That is all the symbol of the file has. Unlike the opencv2.framework downloaded

I have been tested with 2.4.9 and 2.4.10 . The result is same. Any suggestion to find out the problem?

-- General configuration for OpenCV 2.4.10 =====================================
--   Version control:               unknown
--
--   Platform:
--     Host:                        Darwin 14.0.0 x86_64
--     Target:                      iOS
--     CMake:                       3.0.0
--     CMake generator:             Xcode
--     CMake build tool:            /usr/local/Cellar/cmake/3.0.0/bin/cmakexbuild
--     Xcode:                       6.0.1
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ Compiler:                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++  (ver 6.0.0.6000051)
--     C++ flags (Release):         -stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden -fPIC   -DNDEBUG -O3 -fomit-frame-pointer -ffast-math  -DNDEBUG
--     C++ flags (Debug):           -stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden -fPIC   -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
--     C flags (Release):           -Wno-implicit-function-declaration -fPIC   -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -Wno-implicit-function-declaration -fPIC   -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     Precompiled headers:         NO
--
--   OpenCV modules:
--     To be built:                 core flann imgproc highgui features2d calib3d ml nonfree objdetect video contrib legacy photo stitching videostab world
--     Disabled:                    -
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera dynamicuda gpu java ocl python superres ts viz
--
--   GUI:
--     Cocoa:                       YES
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.2.7)
--     JPEG:                        build (ver 62)
--     PNG:                         build (ver 1.5.12)
--     TIFF:                        NO
--     JPEG 2000:                   NO
--     OpenEXR:                     NO
--
--   Video I/O:
--     AVFoundation:                YES
--     QuickTime:                   NO
--     QTKit:                       NO
--     V4L/V4L2:                    NO/NO
--     XIMEA:                       NO
--
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   NO
--     Use TBB:                     NO
--     Use OpenMP:                  NO
--     Use GCD                      YES
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  NO
--
--   Python:
--     Interpreter:                 NO
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java tests:                  NO
--
--   Documentation:
--     Build Documentation:         NO
--     Sphinx:                      NO
--     PdfLaTeX compiler:           NO
--
--   Tests and samples:
--     Tests:                       NO
--     Performance tests:           NO
--     C/C++ Examples:              NO
--
--   Install path:                  /Users/benlau/Downloads/opencv-2.4.10/ios/build/iPhoneOS-armv7/install
--
--   cvconfig.h is in:              /Users/benlau/Downloads/opencv-2.4.10/ios/build/iPhoneOS-armv7
-- -----------------------------------------------------------------
2013-11-29 11:03:58 -0600 commented answer How to use the LshIndexParams?

ohoho , I found out the reason. It is the problem of source installation of OpenCV. There has multiple version on my Linux and it is linked to old version. It is fixed. thx

2013-11-28 19:16:00 -0600 commented answer How to use the LshIndexParams?

I am using OpenCV 2.4.7 but it still throw 'cvflann::anyimpl::bad_any_cast'.. Anyone know what is wrong? thx