In my research, I came across a situation where it would be better to use AR markers, so I searched for a library that could recognize AR markers and came across something called ArUco. This article shows you how to get started with the ArUco library. I'm using Java because I can't use C / C ++ / C #.
I also declare that using OpenCV in Java can be a hassle. It seems that very few people are using it. There are few code examples and questions even in English. However, it runs faster than Python, so I think it has many uses.
OpenCV OpenCV is an open source library for image processing and is fairly widely used. The ideas are so broadly covered that you can generally combine functions.
OpenCV_Contrib OpenCV_Contrib is a library that focuses on the latest technology in OpenCV and is treated as an auxiliary. Also, if you only use the main body, you do not need to build. You can get it by downloading from OpenCV.org (official page). However, it seems that OpenCV_Contrib needs to be built by myself probably because it is treated as an auxiliary. This page describes how to build this
ArUco A library that can do AR. You can generate and recognize AR markers. (The code etc. will be described next time.)
What to download | Description |
---|---|
OpenCV project source | Be sure to match the version with Conrib. I am Version: 3.4.I'm using 4. |
OpenCV_Contrib project source | Be sure to match the version with Conrib. I am Version: 3.4.I'm using 4. |
CMake | Appropriately. |
Visual Studio | I used Visual Studio Community 2017.(C++I think I had to put in a compiler ...) |
Python | You probably need it even when using Java. I am Version: 3.7.I'm using 1. |
JDK | I am using Java8u191. |
Ant | I am Version: 1.10.I am using 5. |
Expand the project source of OpenCV and OpenCV_Contrib. Please install CMake and Visual Studio by yourself.
Is this a songwriter unexpectedly? So, if you do not set it correctly, you will not be able to build. (I was addicted here)
What to download | Description |
---|---|
ANT_HOME |
The extracted Ant folder. (ex: C:\SOFT_File\apache-ant-1.10.5 ) |
JAVA_HOME |
The folder where Java is installed. (ex: C:\Program Files\Java\jdk1.8.0_191 ) |
Path |
The following contentsadd toplease.C:\Program Files\CMake\bin , %ANT_HOME%\bin , %JAVA_HOME%\bin (ex: C:\Program Files\CMake\bin;%ANT_HOME%\bin;%JAVA_HOME%\bin; ) |
It seems that you have to prepare for the build with CMake before building, so I will do it.
item | value |
---|---|
Where is the source code |
Specify the path of the extracted folder. (ex: C:/SOFT_File/opencv-3.4.4 ) |
Where to build the binaries |
I created a build folder under the extracted main library and specified the path of this folder. (ex: C:/SOFT_File/opencv-3.4.4/build ) |
After specifying these, press "Configure". At this time, specify the compiler. This time we will use Visual Studio for the build, so let's specify Visual Studio (the one that matches the version). (I chose "Visual Studio 2017 Win64")
Then, a red one pops out, but don't worry. Enable both the "Grouped" and "Advanced" checkboxes.
item | value |
---|---|
OPENCV_EXTRA_MODULES_PATH |
Deployed OpenCV_In the parent folder of ContribModules belowIs specified. (Deployed OpenCV_Not the parent folder of Contrib) |
Press Configure again.
Disable the "BUILD_SHARED_LIBS" checkbox. (Reference: http://answers.opencv.org/question/189941/java-cant-find-dependent-libraries/)
Press Configure again.
Please enable the check box of "BUILD_FAT_JAVA_LIB".
Press Configure again.
At this time, if there is no red object, it is OK. If so, please correct it.
Now check the log output. In particular, make sure that Java is as follows. (It's just an example)
Java: export all functions
ant: C:/SOFT_File/apache-ant-1.10.5/bin/ant.bat (ver 1.10.5)
JNI: C:/Program Files/Java/jdk1.8.0_191/include C:/Program Files/Java/jdk1.8.0_191/include/win32 C:/Program Files/Java/jdk1.8.0_191/include
Java wrappers: YES
Java tests: YES
Full text: https://pastebin.com/u2Qiy5EL
If there is no problem, Press "Generate".
When you're done, press "Open Project". This will launch Visual Studio. (To the next section)
Wait for a while to read various things.
Set "Release" / "Debug" in the middle to "Release". Also, please set the next one to "x64".
Press "Build"-> "Batch Build" on the menu bar above.
Check both ʻALL_BUILD and ʻINSTALL
and execute.
If you wait for a while (about 1h?), It should be created in the folder specified by Where to build the binaries
in CMake (ex: (OpenCV extraction folder) / build / install
).
If it's not generated, or if you have problems with this article, please leave a comment.
-OpenCV 3.4.1 and opencv_contrib environment construction on Windows 10 Recommended because it has new content and many images are used.
・ Building OpenCV Using MinGW on Windows --You, Myself and Community ・ Building Java Wrapper For OpenCV --You, Myself and Community ↑ It was the easiest to understand as a Java version.
・ OpenCV environment construction (OpenCV 3.0 / 3.1) --Build Insider ・ First OpenCV development-Customization of OpenCV using CMake [OpenCV 3.1.0] --Build Insider ) -Installing OpenCV for Java — OpenCV Java Tutorials 1.0 documentation ・ OpenCV.org (official page) ・ OpenCV --Wikipedia ・ Introduction to OpenCV for Java
Next time, I would like to actually run a light program.
→ Use OpenCV_Contrib (ArUco) in Java! (Part 2-Programming)
Recommended Posts