一、下载
官网下载或者GitHub下载都是比较慢,这里从别的博主的服务器上下载特别快,传送门
在这里选择最新版本的即可 下载xx.exe
二、配置
自己创建一个项目,导入lib 完成后如下:
导入xx.dll,注意路径是双斜杠
三、测试
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
public class OpenCVJavaTest{
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
public static void main(String[] args) {
System.out.println("Welcome to OpenCV " + Core.VERSION);
Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
System.out.println("OpenCV Mat: " + m);
Mat mr1 = m.row(1);
mr1.setTo(new Scalar(1));
Mat mc5 = m.col(5);
mc5.setTo(new Scalar(5));
System.out.println("OpenCV Mat data:\n" + m.dump());
}
}
结果如下即成功:
|