bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.51k stars 1.58k forks source link

Program won't compile with platform-specific requirement combined with javacv-platform dependency #1961

Open mtvgn opened 1 year ago

mtvgn commented 1 year ago

I'm programming this JavaFX application in Java 19 for which I also create a MSI file as installer. This works (packaging the Liberica SDK), but both the jar file as the installer (and also installed application) is very big then: around 1 GB.

I found the need to use the -Djavacpp.platform.windows-x86_64 option with mvn elsewhere on these javacv github pages to get only the platform-specific OpenCV and FFMPEG libraries packaged in the jar instead of all of them. This works when I use javacv 1.5.8 as dependency, but then when I run the installed program it gives the error mentioned at https://github.com/bytedeco/javacv/issues/1402

When I switch to javacv-platform 1.5.8 as dependency mvn will only compile my application successfully without the -Djavacpp.platform.windows-x86_64 option. With it I get a lot of missing dependencies:

Could not resolve dependencies for project :jar:0.0.1: The following artifacts could not be resolved: org.bytedeco:javacpp:jar:true:1.5.8, org.bytedeco:openblas:jar:true:0.3.21-1.5.8, org.bytedeco:opencv:jar:true:4.6.0-1.5.8, org.bytedeco:ffmpeg:jar:true:5.1.2-1.5.8, org.bytedeco:flycapture:jar:true:2.13.3.31-1.5.8, org.bytedeco:libdc1394:jar:true:2.2.6-1.5.8, org.bytedeco:libfreenect:jar:true:0.5.7-1.5.8, org.bytedeco:libfreenect2:jar:true:0.2.0-1.5.8, org.bytedeco:librealsense:jar:true:1.12.4-1.5.8, org.bytedeco:librealsense2:jar:true:2.50.0-1.5.8, org.bytedeco:videoinput:jar:true:0.200-1.5.8, org.bytedeco:artoolkitplus:jar:true:2.3.1-1.5.8, org.bytedeco:flandmark:jar:true:1.07-1.5.8, org.bytedeco:leptonica:jar:true:1.82.0-1.5.8, org.bytedeco:tesseract:jar:true:5.2.0-1.5.8: org.bytedeco:javacpp:jar:true:1.5.8

Especially the :true part seems weird to me and googling that (accompanied with one of these bytedeco jars) doesn't give me much either, so hopefully someone here can help me with my use case of needing to combine the javacv-platform dependency and the -Djavacpp.platform.windows-x86_64 option

saudet commented 1 year ago

Could you explain why the installer needs Maven?

mtvgn commented 1 year ago

The installer doesn't need maven, but it takes the content of the /target directory as input for the msi-file, so when I do 'mvn clean install' (when the dependency is on javacv-platform) without further arguments, the target directory is 908 MegaByte. When I add the -Djavacpp.platform.windows-x86_64 option I get the "Could not resolve" errors from above.

When I add the -Djavacpp.platform.windows-x86_64 option when the dependency is on javacv I get a way smaller /target directory (28 MB), but that installed program doesn't work because it misses one or more dependencies. Which makes sense as the target directory became 32 times smaller in size, I would have expected it to become 5-10 times smaller.

saudet commented 1 year ago

It sounds like you have a buggy version of Maven. Since you only need the binaries for a single platform anyway, use "-Djavacpp.platform=windows-x86_64" instead. That triggers a simpler profile.

mtvgn commented 1 year ago

That does the trick, thank you very much! Installer is now 170 MB, that seems logical