简体   繁体   English

如何使用插件CDT为Java开发人员在Eclipse中配置opencv?

[英]How to configure opencv in Eclipse for Java developers with plugin CDT?

I'm making a CBIR program in Java. 我正在用Java制作一个CBIR程序。

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. 对于实际的图像处理,我正在使用我在大学的CS学位课程中获得的C ++文件(带有标题)。

I used JNI to connect the Java files to the C++ files by following this tutorial . 我按照本教程使用JNI将Java文件连接到C ++文件。

I was trying to find a tutorial for configuring OpenCV in "Eclipse for Java developers with plugin CDT" but couldn't find. 我试图在“Eclipse for Java开发人员使用插件CDT”中找到配置OpenCV的教程,但却找不到。

In this tutorial: https://docs.opencv.org/2.4.13.4/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html 在本教程中: 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. 在第8步中,我需要转到Eclipse中的“工具设置”选项卡,但我没有它。

This tutorial say to open a C++ project but I need a Java project (because most of my files are in Java). 本教程说打开一个C ++项目,但我需要一个Java项目(因为我的大部分文件都是Java)。

When I create a C++ project, I do see the "Tool Settings" tab. 当我创建一个C ++项目时,我看到了“工具设置”选项卡。

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. 但是我已经将我的项目转换为C ++项目作为JNI教程的一部分,所以我认为它与创建新的C ++项目相同。

The instructions for converting to C++ project was in step 2 in that tutorial: 转换为C ++项目的说明在该教程的第2步中:

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. 第2步:将Java项目转换为C / C ++ Makefile项目右键单击“HelloJNI”Java项目⇒新建⇒其他...⇒转换为> C / C ++项目(添加C / C ++性质)⇒下一步。

The "Convert to a C/C++ Project" dialog appears. 将出现“转换为C / C ++项目”对话框。 In "Project type", select >"Makefile Project" ⇒ In "Toolchains", select "MinGW GCC" ⇒ Finish. 在“项目类型”中,选择>“Makefile项目”⇒在“工具链”中,选择“MinGW GCC”⇒完成。

Now, you can run this project as a Java as well as C/C++ project. 现在,您可以将此项目作为Java和C / C ++项目运行。

Any pointer for how to solve this problem? 有关如何解决此问题的指针?

You need two projects, one C++, one java. 你需要两个项目,一个是C ++,一个是java。

The JNI tutorial is demonstrating how to call C++ from java via generating the required C++ headers with the javac/javah tool. JNI教程演示了如何通过使用javac / javah工具生成所需的C ++头来从java调用C ++。 In the example, they were done with java portion so they converted it to a C++ project. 在这个例子中,他们完成了java部分,因此他们将它转换为C ++项目。

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. 按照https://docs.opencv.org/2.4.13.4/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html中的说明使用opencv设置新的C ++项目,并为您的java源独立创建一个新的Java项目。 When you use javac to generate the headers, instead of specifying the "." 当您使用javac生成标头时,而不是指定“。” path on the command line, specify a path to your C++ project. 命令行上的路径,指定C ++项目的路径。

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). 您需要确保Java System.loadLibrary(“YourC ++ LibraryName”)调用可以找到由C ++项目创建的共享库(并且C ++项目构建共享库)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM