Reputation: 615
I'm developing an android app that uses the OpenCV and Tesseract library. I only use certain functions of these libraries. But with the libraries included, the size of the app grows from 4 to 50mb.
I obviously need to trim down the libraries. How would I do this?
EDIT: To maintain user-friendliness I don't want to use OpenCVManager. I don't want to force the user to install another app.
EDIT2: I need to do the same thing for tesseract libraries. I guess this works in the same way?
Upvotes: 2
Views: 1387
Reputation: 8914
If you don't want to use the OpenCVManager you can follow these instructions.
The problem is, I do not know if it will still works for versions above 2.4.3 and it will not reduce the size of your apk.
If you want to reduce that size you will have to compile opencv4android for yourself and chose which modules you need.
Upvotes: -1
Reputation: 4941
I'm absolutely not sure of what i'm going to suggest, but i recently found the -gc-sections
options in the GCC documentation. Used at link time, it's supposed to strip all unused code sections from the final executable/library. This could avoid having to trim OpenCV manually, which must be a long and rather unpleasant task given the complexity of this library.
To use it, you apparently have to compile each dependency using -ffunction-sections -fdata-sections -Os
, then link the whole code with -Wl,--gc-sections
. It may deserve a try!
I found some details on this page.
Don't hesitate to correct me if i'm wrong!
Upvotes: 4