【发布时间】:2018-07-29 19:52:50
【问题描述】:
我正在通过 eclipse 4.5.0 在 java 中使用 open Graphics Library 创建一个人脸检测程序,并将一个 jar 文件添加到 open CV 2.4.1 的 java 项目中,并且我已经尝试了 web 上指定的所有方法用于通过 Eclipse IDE 中可用的构建路径选项设置 NATIVE_LIBRARY_NAME 的位置,但仍然找不到解决方案...请帮我解决此错误
我的人脸检测 Java 文件
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.objdetect.CascadeClassifier;
public class FaceDetection
{
public static void main(String[] args)
{
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.out.println("\nRunning FaceDetector");
CascadeClassifier faceDetector = new CascadeClassifier(FaceDetection.class.getResource("haarcascade_frontalface_alt.xml").getPath());
Mat image = Highgui
.imread(FaceDetection.class.getResource("shekhar.JPG").getPath());
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));
for (Rect rect : faceDetections.toArray())
{
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
new Scalar(0, 255, 0));
}
String filename = "ouput.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
我已点击此链接 https://blog.openshift.com/day-12-opencv-face-detection-for-java-developers/
【问题讨论】:
-
你看过这个吗? stackoverflow.com/questions/25379814/… 检查 JAR 是否包含 org.opencv.core.Core,它尚未从该 API 中删除:docs.opencv.org/java/index.html?org/opencv/core/Core.html 确保为您的架构和操作系统使用正确的本机库。如果在 64 位操作系统上使用 32 位 JVM,则必须使用 32 位本机库。
标签: java eclipse opencv opengl