Error in loading libraries in JavaCV in Android -
i'm trying implement simple face recognition code using javacv. i'm getting error , don't know why.
i have copied every .so file directories -> app/libs/armeabi , app/src/main/jnilibs copies javacpp.jar , javacv.jar app/libs directory
here's error :
caused by: java.lang.unsatisfiedlinkerror: dlopen failed: not load library "libopencv_contrib.so" needed "libjniopencv_contrib.so"; caused not load library "../../lib/libopencv_legacy.so" needed "libopencv_contrib.so"; caused library "../../lib/libopencv_legacy.so" not found @ java.lang.runtime.load(runtime.java:330) @ java.lang.system.load(system.java:511) @ com.googlecode.javacpp.loader.loadlibrary(loader.java:700) @ com.googlecode.javacpp.loader.load(loader.java:586) @ com.googlecode.javacpp.loader.load(loader.java:540) @ com.googlecode.javacv.cpp.opencv_contrib.(opencv_contrib.java:97) @ com.ifta.face.opencvfacerecognizer.recognise(opencvfacerecognizer.java:102) @ com.ifta.face.finalactivity.testpreviousimage(finalactivity.java:126) @ com.ifta.face.finalactivity.ontestclicked(finalactivity.java:50) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ android.view.view$1.onclick(view.java:3809) @ android.view.view.performclick(view.java:4421) @ android.view.view$performclick.run(view.java:17903) @ android.os.handler.handlecallback(handler.java:730) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:213) @ android.app.activitythread.main(activitythread.java:5225) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:741) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:557) @ dalvik.system.nativestart.main(native method)
the java function i'm using :
public static void recognise(context context, file sampledir, file testfile) { // debug-1 if(sampledir!=null) log(context, "1. sampledir ok. " + testfile.getabsolutepath()); else { log(context, "1. sampledir null"); return; } filenamefilter pngfilter = new filenamefilter() { public boolean accept(file dir, string name) { return name.tolowercase().endswith(".png"); } }; file[] imagefiles = sampledir.listfiles(pngfilter); // debug-2 if(imagefiles!=null) { log(context, "2. imagefile ok, files :"); for(file imagefile : imagefiles) log(context, "file : " + imagefile.getabsolutepath() ); } else { log(context, "2. imagefile array null"); return; } // debug-.5 if(testfile!=null) log(context, "2.5. testfile ok. " + testfile.getabsolutepath()); else { log(context, "2.5. testfile null"); return; } iplimage testimage = cvloadimage(testfile.getabsolutepath()); // debug-3 if(imagefiles!=null) log(context, "3. testimageipl ok"); else { log(context, "3. testimageipl null"); return; } matvector images = new matvector(imagefiles.length); int[] labels = new int[imagefiles.length]; int counter = 0; int label; iplimage img; iplimage grayimg; (file image : imagefiles) { // image , label: img = cvloadimage(image.getabsolutepath()); label = integer.parseint(image.getname().split("\\-")[0]); // convert image gray scale: grayimg = iplimage.create(img.width(), img.height(), ipl_depth_8u, 1); cvcvtcolor(img, grayimg, cv_bgr2gray); // append in image list: images.put(counter, grayimg); // , in labels list: labels[counter] = label; // increase counter next image: counter++; } //facerecognizer facerecognizer = createfisherfacerecognizer(); facerecognizer facerecognizer = createeigenfacerecognizer(); // facerecognizer facerecognizer = createlbphfacerecognizer(); facerecognizer.train(images, labels); // load test image: iplimage greytestimage = iplimage.create(testimage.width(), testimage.height(), ipl_depth_8u, 1); cvcvtcolor(testimage, greytestimage, cv_bgr2gray); // , prediction: //int predictedlabel = facerecognizer.predict(greytestimage); //system.out.println("predicted label: " + predictedlabel); int[] imagelabels = new int[1]; double[] confidences = new double[1]; facerecognizer.predict(greytestimage, imagelabels, confidences); log(context, "result : label - " + imagelabels[0] + " conf - " + confidences[0]); }
i solved after 2 days... suppose load library manually. added few lines
system.load("/data/data/com.ifta.face/lib/libopencv_photo.so"); system.load("/data/data/com.ifta.face/lib/libopencv_flann.so"); system.load("/data/data/com.ifta.face/lib/libopencv_features2d.so"); system.load("/data/data/com.ifta.face/lib/libopencv_calib3d.so"); system.load("/data/data/com.ifta.face/lib/libopencv_ml.so"); system.load("/data/data/com.ifta.face/lib/libopencv_video.so"); system.load("/data/data/com.ifta.face/lib/libopencv_legacy.so"); system.load("/data/data/com.ifta.face/lib/libopencv_objdetect.so"); system.load("/data/data/com.ifta.face/lib/libopencv_gpu.so"); system.load("/data/data/com.ifta.face/lib/libopencv_nonfree.so"); system.load("/data/data/com.ifta.face/lib/libopencv_contrib.so");
and 1 thing found out libraries having names "libjni*.so" loaded automatically , "libopencv_*.so" have load manually. loading sequence must mentioned above because libraries dependent on former ones. 1 know why happening ?
Comments
Post a Comment