Using specific OpenCV dependencies in Java using Bytedeco

Hi,

In our application we are using features from OpenCV for Image recognition to label producer brands. Our application is build with Java and to be able to use OpenCV, we have to use Bytedeco to make it work.

(maven dependency in use)

org.bytedeco
opencv
4.3.0-1.5.3
linux-x86_64</classifier

The problem is that this way a lot of the OpenCV dependencies are pulled that we don’t use (for exapmle IOS & Android), resulting in a large build, which brings deployment issues. I was wondering if anyone knows a method in which we can specify which dependencies we want to use so that only those we need are pulled and the build sizes are maintainable.

Thanks in advance!

that’s unlucky, as this is a 3rd party effort, not maintained from opencv
(so, noone really cares)

can you be a bit more explicit ? why would anything (what exactly ?) pull IOS dependancies for an android app ? do you mean: “opencv modules you do not need” ?

Is there another possibility that is directly supported by opencv that makes it possible to use the opencv dependencies in our Java project?

Yes, that’s correct, our application can be seen as a Java web app, which means mobile modules aren’t required, but that was just an example. In essence we would like to have control over the modules in the project to reduce the size of the libraries.

Thank you for your swift response, feel free to ask if some things are still unclear.

sure ! if it’s for windows, the prebuilt releases contain java bindings, for linux you would build from github src (with apache ant installed)

In essence we would like to have control over the modules

makes sense. there’s a whitelist cmake flag, that will allow you to select only the ones you require, like:

cmake -DBUILD_LIST=core,imgproc,imgcodecs,java

some more details, maybe ? where exactly does it run ? what’s your build / deploy process ?

The Vaadin application runs on a Tomcat (Windows & Linux) server and the build & deploy processes are maintained by maven (modules pulled from mavencentral, deployed by building a .war that is run on Tomcat)

Cmake is possible, but we would have to do this for every build for every version of our project, which isn’t entirely desired.

so, it’s a “long way through the stack” from your app to actual opencv libs, i guess ;(

just curious, what are you using opencv for here ?

sorry cannot help here, no idea if there’s some actively maintained opencv package there

yea, understood.
i once had something like this on heroku, and instead of rebuilding this over & over when deploying, i built it once from a remote console & stored the artefacts on github

Correct, it’s mainly a web app, but for some specific use cases the opencv library is used. For example image recognition in documents (logo’s of certain manufacturers of products).

Either way, we have a clear view of our options now, thank you for the information!

there seems to be this, at least (4.5.2):

This looks like a viable option, but the size is on the larger side of course. Still useful since it is directly on maven, thanks again!