OpenCV native files (*.so & *.dll)

0
Hi, By default during the creation of deployment package in Environment. "native-libs" directory (which contains "libopencv_java4120.so" and "opencv_java4120.dll") are not copied into the package.   I have created the "native-libs" directory parallel to the "userlib" (which contains "opencv-4120.jar") in project directory.   When i have tested locally, I copied the "native-libs" directory into the deployment directory and used the JVM parameter as "-Djava.library.path=.\native-libs" in settings of the project.   It works as expected. But how to do the same when i create the deployment package in Environment. Since it is Linux environment.  It seems like default build does not copy the "native-libs" directory along with deployment.   Does any one know, how to solve this issue? Thanks
asked
2 answers
0

If you want some files to be part of the deployment package you can add them to the /resources folder. You can access that path in java via Core.getConfiguration().getResourcesPath()

For using openCV there are some packages with packaged native libraries, e.g.: https://github.com/openpnp/opencv

Not sure if these are still maintained, but this is generally a working approach.

regards Fabian

answered
-1

 If you do not mind these files potentially being downloaded by users, you can drop them into the theme directory. because files there are copied to the web directory.

 

with these files present inside of the container, you can load them as you described above. But following this:

 

 

You can configure the Java properties by providing the JAVA_OPTS enviroment variable to the application.

Configure the JAVA_OPTS environment variable by using the cf set-env command.

cf set-env <YOUR_APP> JAVA_OPTS '["-Djava.rmi.server.hostname=127.0.0.1", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.port=5000", "-Dcom.sun.management.jmxremote.rmi.port=5000"]'

 

do note what you are doing is fragile and hacky. This means that this functionality might not even work (not tested) or can break in the future out of the blue. Because your approach depends on native libraries other than java libs.

 

a better solution would be to extract your functionality of opencv into a separate service. Then call this service via API from your mendix app.

 

answered