Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Eclipse的OpenCV_Java_Eclipse_Opencv - Fatal编程技术网

Java Eclipse的OpenCV

Java Eclipse的OpenCV,java,eclipse,opencv,Java,Eclipse,Opencv,安装说明: 我下载了所有的东西。除了运行此示例程序外,其他一切似乎都正常工作: import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; public class Main { public static void main(String[] args) { System.out.println("Welcome to OpenCV " + Core.VERSION)

安装说明:

我下载了所有的东西。除了运行此示例程序外,其他一切似乎都正常工作:

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Main {

public static void main(String[] args) {
    System.out.println("Welcome to OpenCV " + Core.VERSION);
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
    System.out.println("m = " + m.dump());
}

}
我得到输出:

m = [1, 0, 0;
     0, 1, 0;
     0, 0, 1]
(我希望这是对的)

但我也会收到以下错误消息:

objc[63784]: Class CVWindow is implemented in both /Users/.../cv2.so and /Users/... /libopencv_java246.dylib. One of the two will be used. Which one is undefined.
objc[63784]: Class CVView is implemented in both /Users/.../cv2.so and /Users/.../libopencv_java246.dylib. One of the two will be used. Which one is undefined.
objc[63784]: Class CVSlider is implemented in both /Users/.../cv2.so and /Users/.../libopencv_java246.dylib. One of the two will be used. Which one is undefined.
objc[63784]: Class CaptureDelegate is implemented in both /Users/... /cv2.so and /Users/jsuit/opencv/lib/libopencv_java246.dylib. One of the two will be used. Which one is undefined.

我已经尝试将cv2.so文件移动到另一个文件夹,但是程序无法编译

据我所知,这个问题必须通过引用最终包含在Java库中的Python库(即.so版本)来解决。这似乎是一个构建配置错误(遵循说明确实会产生错误)

通过在cmake步骤中使用以下步骤(所有其他步骤都相同),在不支持Python库的情况下重新构建Java版本,我能够消除双定义错误:

新生成的Java库和.jar与以前一样工作,但没有错误消息

(请注意,我不能保证这不会导致其他问题,特别是如果您想进行某种混合语言编程,但它确实生成了对Java和Eclipse有用的库。您也可以始终构建多个版本的OpenCV,其中一些支持Python,另一些不支持Python,如果您同时切换语言,可以使用任意一个版本有一点。)

帽尖:

cmake -D BUILD_SHARED_LIBS=OFF -D BUILD_NEW_PYTHON_SUPPORT=NO ..