如何在Eclipse中配置OpenCV开发环境

2024-11-29 23:47:24
推荐回答(1个)
回答1:

在Eclipse中配置OpenCV开发环境
首先去官网下载OpenCV并安装,接着新创建一个Java项目:OpenCV1

2. 配置Java Build Path:
2.1 右击项目OpenCV1 -> Build Path -> Configure Build Path -> Libraries -> AddLibrary;
2.2 选择 User Library,依次点击Next -> User Libraries -> New;
2.3 在弹出来的对话框中输入opencv-3.2.0,然后点击OK;
2.4 选择Add External JARs, 在OpenCV安装根目录下找到opencv-320.jar文件并添加;
2.5 然后选择Native library location:(None),点击右侧Edit 添加 G:\opencv\build\java\x64(选择自己OpenCV安装目录),然后点击OK,配置完毕 测试代码如下测试即可:package com.nb.opencv;import org.opencv.core.Core;import org.opencv.core.CvType;import org.opencv.core.Mat;public class TestOpenCV{ 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()); }}