I wanted to maintain my own Java video encoding application a while ago, but when the environment changed, I had to build the external libraries (JavaCV, JavaCPP) again. (Beginner of Windows application, I can't)
That's why I created a Maven environment so that JavaCV can be used easily at any time, so this is a memorandum.
I think there are various things, but only the points that are the points in this article are excerpted.
In this article, I will introduce how to describe pom.xml in 2.
About Maven, this article carefully describes the environment construction, so please refer to it if you are interested.
JavaCV is a convenient tool that both OpenCV, an image conversion tool, and FFmpeg, a video encoding tool, can be used in Java.
If you check the Official site, you can see how to describe Maven.
pom.xml
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.4.2</version>
</dependency>
Well, when I read it while wondering if this is all I need, it seems that JavaCPP Presets are also necessary. Actually, this is also essential because it includes the processing related to the main body of OpenCV and FFmpeg.
So check Java CPP official website.
pom.xml
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>${moduleName}-platform</artifactId>
<version>${moduleVersion}-1.4.2</version>
</dependency>
I also wrote this, okay! What are moduleName and moduleVersion?
JavaCPP contains various artifacts in the Maven repository, so you need to extract the one you want to use. Moreover, it is troublesome to find out that it is necessary to match the version. I'll look it up anyway.
When I was googled with javacpp-presets, I found the following repository site.
https://mvnrepository.com/
For pinpoint search, use https://mvnrepository.com/artifact/group ID
.
If you specify org.bytedeco.javacpp-presets, which is the target of this time, some artifacts will appear like this. I will.
This time it was FFmpeg and OpenCV, so check the contents of ffmpeg-platform and opencv-platform. Then, the version information that supports it like this will come out.
Compared with the official website of Java CPP in the above example, it seems that moduleName ⇒ ffmpeg-platform, module Version ⇒ 4.0.1-1.4.2.
With reference to the above, dependency was added to pom.xml as follows. As a result of the build, the Java application that the build was creating now works. Yay!
pom.xml
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv-platform</artifactId>
<version>3.4.2-1.4.2</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>4.0.1-1.4.2</version>
</dependency>
How do you find out the version of ** dependency this time? I wrote this article because I wanted to keep the point **.
Looking at it like this, recent development
--Build environment ⇒ Maven and Gradle --Operation tool ⇒ ruby gem, python pip, Linux apt / yum --Operating environment ⇒ Docker
It is common to make the same thing available anytime, anywhere. If you are developing in a closed environment in the company, you may not have many opportunities to touch it, but if you make a new tool by yourself, I would like to actively use these convenient functions.
Maven base: [For super beginners] Maven super introduction First reference article: Installing a convenient development environment called Eclipse + Maven from installation to project creation
Recommended Posts