Ask Your Question
0

OpenCv Android only native

asked 2017-09-30 07:24:21 -0600

Hi,

I am using the Android opencv sdk in my project, and everything is good but size. I know there are ways to build for diferent platforms, shrink size and so on, but my question is of different nature.

There is a thing I don't understand, when I build the library in Android Studio using cmake I link it to libraries provided from environment variable in cmake which opencv exposes (version 3.2) , for this I downloaded opencv native sdk for android and made a separate project in Android Studio, now the size is big because the libopencv_java3.so is somehow linked to my library so, but as I think of it libopencv_java comes for the java code which comes with opencv sdk, and I don't usye any of the sdk java code, I do everything in C/C++, and have defined my own JNI code to interact with that c/c++ methods. Now the question, can I, in my case reduce all the size to maybe 2-3 modules ( core, imageproc and one more maybe), because I need only those.

I know a bit of c/c++ syntax but the linking static, shared and so one all this things a bit in the fog for me.

Can you please help?

Thanks,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-09-30 08:13:27 -0600

tham gravatar image

updated 2017-09-30 08:13:51 -0600

You can compile the library by yourself, built them as static lib and disable opencv_world.This post has the details

Supplement :

  1. Switch off the modules you do not need
  2. Switch off BUILD_opencv_world(maybe step 2 could be skiped)
  3. Switch off BUILD_SHARED_LIBS
  4. I build opencv3.3 with tbb and carotene, they works fine on android phone

After you run mingw32-make install, link to the library you need, the order of linking is crucial, try to change their orders if you got a lot of link errors.

My example(I build the project by qmake):

LIBS += $${CV_LIB_PATH}/libopencv_world.a

LIBS += $${OPENCV_3RD_LIBS}/liblibtiff.a
LIBS += $${OPENCV_3RD_LIBS}/liblibjpeg.a
LIBS += $${OPENCV_3RD_LIBS}/liblibjasper.a
LIBS += $${OPENCV_3RD_LIBS}/liblibpng.a
LIBS += $${OPENCV_3RD_LIBS}/libIlmImf.a

LIBS += $${OPENCV_3RD_LIBS}/libcpufeatures.a
LIBS += $${OPENCV_3RD_LIBS}/libtegra_hal.a
LIBS += $${OPENCV_3RD_LIBS}/liblibwebp.a
LIBS += $${OPENCV_3RD_LIBS}/liblibprotobuf.a
LIBS += $${OPENCV_3RD_LIBS}/libtbb.a

I link with opencv_world because I do not want to fiddle with the link order

Example project--Light detector, build with Qt5 and opencv3.3, show you how to build cross-platform computer vision app with Qt5 and opencv.

ps : if you are familiar with tensorflow, please lend me a hand--Turn is_training of batchnorm(TensorFlow) to False, thanks.

edit flag offensive delete link more

Comments

Hi,

Thanks for the answer, it doesn't really answer my question, but you gave me some ideas of things to check.

p.s.: not familiar with tensor flow.

Alekshandru gravatar imageAlekshandru ( 2017-10-01 02:16:27 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-30 07:22:04 -0600

Seen: 1,597 times

Last updated: Sep 30 '17