I'm making a CBIR program in Java.
For the actual image processing, I'm using the C++ file (with his header) that we got in a course that I did in my CS degree in the university.
I used JNI to connect the Java files to the C++ files by following this tutorial.
I was trying to find a tutorial for configuring OpenCV in "Eclipse for Java developers with plugin CDT" but couldn't find.
In this tutorial: https://docs.opencv.org/2.4.13.4/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html
in step 8, I need to go to "Tool Settings" tab in Eclipse but I don't have it.
This tutorial say to open a C++ project but I need a Java project (because most of my files are in Java).
When I create a C++ project, I do see the "Tool Settings" tab.
But I already converted my project to C++ project as part of that JNI tutorial, so I thought that it's the same as creating a new C++ Project.
The instructions for converting to C++ project was in step 2 in that tutorial:
Step 2: Convert the Java Project to C/C++ Makefile Project Right-click on the "HelloJNI" Java project ⇒ New ⇒ Other... ⇒ Convert to a >C/C++ Project (Adds C/C++ Nature) ⇒ Next.
The "Convert to a C/C++ Project" dialog appears. In "Project type", select >"Makefile Project" ⇒ In "Toolchains", select "MinGW GCC" ⇒ Finish.
Now, you can run this project as a Java as well as C/C++ project.
Any pointer for how to solve this problem?
You need two projects, one C++, one java.
The JNI tutorial is demonstrating how to call C++ from java via generating the required C++ headers with the javac/javah tool. In the example, they were done with java portion so they converted it to a C++ project.
Follow the instructions in https://docs.opencv.org/2.4.13.4/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html for setting up a new C++ project with opencv and independently create a new java project for your java source. When you use javac to generate the headers, instead of specifying the "." path on the command line, specify a path to your C++ project.
You will need to make sure that the Java System.loadLibrary("YourC++LibraryName") call can find the shared library created by the C++ project (and that the C++ project builds a shared library).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With