11

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?

2
  • Did you try to use #include "opencv2/core.hpp" instead of #include <opencv2/core.hpp> ? Commented May 17, 2019 at 14:37
  • Wher you are trying to build your project, use the verbose mode and look to see what it is missing. That way you can see if your configuration is being applied Commented May 17, 2019 at 15:26

1 Answer 1

3
+50

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.