Setting up OpenCV for JAVA.

Installation and setting up of your System for OpenCV with java.

Prithvi Dev
Javarevisited

--

Photo by Caspar Camille Rubin on Unsplash

Hello guys, in this article we will discuss about how to download and install OpenCV in your system and configure it with your Java IDE.

OpenCV is a cross-platform library used for developing real-time computer vision applications. It is useful in so many fields like medicine, security, transport, etc.

Using OpenCV we can Capture video and image. We can transform the image and can change it’s color from colored images to GrayScale images.

Using OpenCV with JAVA is so cool. we have to work with JavaFX to use OpenCV with Java GUI.

OpenCV is a very useful library but a vast library also. It is a very large library including so many useful packages to perform operations.

Now let’s download and Install OpenCV in your System so that you can also make some good stuff using OpenCV.

There are a few simple steps, you can follow to Install OpenCV.

First of all, you have to download OpenCV in your System. By following these steps you can download OpenCV in your System.

Step 1) Open the Homepage of OpenCV simply by following the given link https://opencv.org/about/ .

On clicking the given link, the Homepage of OpenCV will be open.

Step 2) Click on the Releases link, It will be directed to Releases page and then you have to choose Windows. It will get download in your specified folder.

Step 3) On Clicking windows, a file name “OpenCV-4.4.0.exe” will get save in downloads folder. You have to click on that file and Install it in your computer. After installing you will get a folder named OpenCV will be created.

Step 4) you have to open the folder “opencv -> build -> Java”. There you will find the jar file “opencv-3410.jar”.

Configuring Eclipse IDE,

Firstly install Eclipse in your System correctly. Here’s the link to download Eclipse IDE in your system https://www.eclipse.org/downloads/packages/release/oxygen/3a/eclipse-ide-java-developers .

Setting build path:

Step 1) Create a new Project by clicking on File, then new and choose Project.

Step 2) On selecting Project, A dialogue box will be open “Select a Wizard”. Choose Java Project and click on Next.

Step 3) Now New Java Project wizard will get open. Enter project name of your own and click on Finish.

Step 4) After creating new Project, right click on it and select Build Path and then Configure Build Path.

Step 5) On clicking the Configure Build Path, Java Build Path Wizard will open. Click on Add External JARs.

Step 6) Select the path of the file Opencv jar file and Click on open. Those files will be added to your library.

Step 7) By Clicking on Apply and Close, you will successfully added the required OpenCV jar file to your project library. You can see that Library by clicking on “Referenced Libraries” .

Setting Native Libraries..

Now we have to set path for the Native Libraries. Need to set path for DLL files of OpenCV.

In the folder, “opencv -> build -> java”, you will find the two other folders named x64(for 64 bit) and x86(for 32 bit). These folders will contain the required DLL files of OpenCV.

You have to follow some more simple steps to set the Native Library of OpenCV.

Step 1) Again Open the Java Build Path Wizard. Here you can find the added JAR file and JRE System Library.

Step 2) Expanding the OpenCV jar file, you will get the system libraries and “Native Library Location: “. Refer the image below.

Step 3) By Double Clicking the “Native Library Location:” option , “Native Library Folder Configuration window” will open.

Step 4) Now choose External Folder option and select the path for the DLL file of OpenCV.

Choosing of Folder x64(64 bit) or x86(32 bit), will be based on your System Configuration. If your System is 64 bit then choose x64 folder and if your System is 32 bit then choose x86 folder.

Now Click Apply and Close, start writing your code for OpenCV.

I hope you all Installed and Configured OpenCV correctly. Thanking you for visiting and reading the full article.

Thank You.

--

--

Prithvi Dev
Javarevisited

Software Engineer specializes in Middleware Technologies and Cloud Platform Administration. Seeking knowledge and practice on DevOps Projects.