0
我已經在Android Studio中實現了這個項目:https://github.com/yaylas/AndroidFaceRecognizer。我使用教程包含OpenCV:https://www.youtube.com/watch?v=OTw_GIQNbD8(這是靜態初始化)。而且,我在Android Studio設置中設置了適當的NDK位置。 問題是,如果我加入這個類:OpenCV + Android - 人臉識別不起作用
package com.yaylas.sytech.facerecognizer;
import java.util.Vector;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import android.widget.Toast;
public class DetectionBasedTracker
{
public DetectionBasedTracker(String cascadeName, int minFaceSize, boolean isFaceDetector) {
mNativeObj = nativeCreateObject(cascadeName, minFaceSize, isFaceDetector);
}
public long getNativeObj(){
return mNativeObj;
}
public void setMinFaceSize(int size) {
nativeSetFaceSize(mNativeObj, size);
}
public void detect(Mat imageGray, MatOfRect faces) {
nativeDetect(mNativeObj, imageGray.getNativeObjAddr(), faces.getNativeObjAddr());
}
public void release() {
nativeDestroyObject(mNativeObj);
mNativeObj = 0;
}
public static Vector<Mat> imageVector = new Vector<Mat>();
public static void addElement(Mat m){
imageVector.add(m);
System.out.println("--------------------------------- elementAdded: "+imageVector.size());
}
public static long getElementAt(int index){
if(index >= imageVector.size() || index < 0){
return 0;
}
System.out.println("-------------------------***** get element: "+imageVector.size()+" index: "+index);
return imageVector.elementAt(index).getNativeObjAddr();
}
public static int getImageCount(){
return imageVector.size();
}
private long mNativeObj = 0;
private static native long nativeCreateObject(String cascadeName, int minFaceSize, boolean faceDetection);
private static native void nativeDestroyObject(long thiz);
private static native void nativeStart(long thiz);
private static native void nativeStop(long thiz);
private static native void nativeSetFaceSize(long thiz, int size);
private static native void nativeDetect(long thiz, long inputImage, long faces);
}
返回一個錯誤信息:
無法解析對應的JNI功能
我什麼都試過,但錯誤依然存在。我想問問,哪裏可以成爲問題?
也許我可以找到metods/tutorial來整合JNI funcion在NDK OpenCV性質?我嘗試這些要點,但我的程序仍然無法正常工作... – Pitter
@Pitter我在Android上添加了OpenCV上的信息鏈接。該頁面鏈接到晚餐教程。 – Jerry101