[英]Java - OpenCV java.lang.NoClassDefFoundError exception
I'm trying to make an app that takes pictures using the webcam. 我正在尝试制作一个使用网络摄像头拍照的应用程序。 I'm using OpenCV with Java.
我在Java中使用OpenCV。 This is the method I'm using:
这是我使用的方法:
public String sacarFoto(){
//conecta con la webcam
VideoCapture cap = new VideoCapture(0);
//variable donde se va a guardar la imagen
Mat image = new Mat();
cap.retrieve(image);
//establece el path de la foto
String foto="C:/Documents/workspace-sts-3.6.4.RELEASE/resources/captura.jpg";
//guarda la foto (este archivo se pisa cada vez que se vuelve a correr el reconocimiento)
Highgui.imwrite(foto, image);
//libera la referencia a la webcam
cap.release();
//devuelve el path a la foto
return foto;
}
When I try to run it I get this error: 当我尝试运行它时,出现此错误:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/opencv/highgui/VideoCapture
I know that the library is working because I tried to use the face recognition functionality and it worked perfectly. 我知道该库正在运行,因为我尝试使用人脸识别功能并且运行良好。
Any suggestions of what could be missing? 关于可能缺少的任何建议?
EDDITED EDDITED
So, I tried running that part of the code as a java application (instead of 'run on server') and it works fine. 因此,我尝试将部分代码作为Java应用程序运行(而不是“在服务器上运行”),并且运行良好。 So I assume the problem is in the spring dependencies.
因此,我认为问题出在Spring依赖项中。 This is what I have:
这就是我所拥有的:
<dependency>
<groupId>nu.pattern</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-4</version>
</dependency>
but it's not working. 但它不起作用。 Any ideas of what could be wrong?
关于什么可能是错的任何想法?
Please ensure that the library which contains the class "org/opencv/highgui/VideoCapture" is in the classpath. 请确保包含类“ org / opencv / highgui / VideoCapture”的库在类路径中。 If maven is being used, add this jar as a dependency.
如果正在使用maven,请将此jar添加为依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.