UnsatisfiedLink错误:opencv_java2411.dll已在玻璃鱼中的另一个类加载器中加载 [英] UnsatisfiedLink error : opencv_java2411.dll already loaded in another classloader in glass fish
本文介绍了UnsatisfiedLink错误:opencv_java2411.dll已在玻璃鱼中的另一个类加载器中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用opencv在Java中实现用于人脸识别的Web应用程序. 在运行用于人脸识别的代码时,出现了
I am implementing a web application for face recognition in java using opencv. While I am running the code for face recognition I am getting errors like
java.lang.UnsatisfiedLinkError: Native Library F:\opencv\build\java\x86\opencv_java2411.dll already loaded in another classloader
我已经完成了几种在Internet上可用的方法,例如检查类是否已加载,是否将system.loadlibrary作为静态块添加到环境变量的路径等等,但是在所有这些过程之后,错误仍然存在于系统中. /p>
i had done several methods avaliable over internet such as checking whether the class is loaded or not making the system.loadlibrary as static block adding path to environment variable and so on but the error persist in the system after all this process.
does anyone has the solution for this problem i am able to run with this dll in desktop application but while running in web application the error comes
i am running this project using glassfish server on netbeans ide
public class FaceRecognition {
public static boolean loaded = false;
public void loadLib(){
System.out.println("loading library");
try {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}catch(Exception e){}
loaded = true;
}
public FaceRecognition() {
}
public void saveFaceRecognizedImage(File file){
try {
MatOfByte mem = new MatOfByte();
CascadeClassifier faceDetector = new CascadeClassifier(facerecog.FaceRecognition.class.getResource("haarcascade_frontalface_alt.xml").getPath().substring(1));
MatOfRect faceDetections = new MatOfRect();
BufferedImage bi = ImageIO.read(file);
Mat frame = bufferedImageToMat(bi);
Rect rectcrop = null;
faceDetector.detectMultiScale(frame, faceDetections);
for (Rect rect : faceDetections.toArray()) {
System.out.println("ttt");
Core.rectangle(frame, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
new Scalar(0, 255,0));
rectcrop = new Rect(rect.x,rect.y,120,120);
}
try {
Mat imgrr = new Mat(frame,rectcrop);
Highgui.imwrite(file.getAbsolutePath(), imgrr);
// BufferedImage image = ImageIO.read(file);
// BufferedImage scaled = getScaledInstance(
// image, 120,120, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
// writeJPG(scaled, new FileOutputStream(file.getAbsolutePath()), 0.85f);
}catch(Exception e){}
// Highgui.imencode(".bmp", frame, mem);
// Image im = ImageIO.read(new ByteArrayInputStream(mem.toArray()));
// BufferedImage buff = (BufferedImage) im;
// ImageIO.write(buff,"jpg",file);
} catch (IOException ex) {
Logger.getLogger(FaceRecognition.class.getName()).log(Level.SEVERE, null, ex);
}
}
推荐答案
查看全文