实际上我在使用opencv 3.0.0时检测到第一帧相机在Eclipse中崩溃。 代码看起来像这样
public class main
{
static {
System.out.println("java.library.path="+System.getProperty("java.library.path"));
System.load(new File("/Desktop/opencv-3.0.0/build22/lib/libopencv_java300.dylib").getAbsolutePath());
// System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.load(new File("/Documents/Mourish/java-proj/FaceDetector/libFaceDetector.so").getAbsolutePath());
System.out.println("Library loaded");
}
public static void main(String argv[]) {
int n = 0 ;
final Scalar FACE_RECT_COLOR = new Scalar(0, 255, 0, 255);
MatOfRect faces = new MatOfRect();
// CascadeClassifier cascadename = new CascadeClassifier("/Documents/FD/sample/lbpcascade_frontalface.xml");
String s = "/Documents/FD/sample/lbpcascade_frontalface.xml";
Imshow im = new Imshow("window");
VideoCapture camera = new VideoCapture(0);
if(!camera.isOpened()){
System.out.println("Error");
}
else {
Mat frame = new Mat();
Mat out = new Mat();
while(true){
if (camera.read(frame)){
//
n = FaceDetector.sample(frame, out, faces, s);
System.out.println("Frame Obtained");
System.out.println("Captured Frame Width " +
frame.width() + " Height " + frame.height());
Rect[] facesArray = faces.toArray();
for (int i = 0; i < facesArray.length; i++)
Imgproc.rectangle(frame, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);
im.showImage(frame);
Imgcodecs.imwrite("/Documents/FD/sample/camera.jpg", frame);
System.out.println("OK");
break;
}
}
}
// return n;
}
}
在im.showImage()中显示一些异常。我导入外部罐子opencv_300.jar。例外看起来像..,
Exception in thread "main" java.lang.NoClassDefFoundError: org/opencv/highgui/Highgui
at com.atul.JavaOpenCV.Imshow.showImage(Imshow.java:77)
at main.main(main.java:61)
Caused by: java.lang.ClassNotFoundException: org.opencv.highgui.Highgui
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.secu`enter code here`rity.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more
Pls help me to find actual issue....