New file |
| | |
| | | package cn.com.basic.face.util;
|
| | |
|
| | | import android.util.Log;
|
| | | import android.view.Surface;
|
| | | import java.util.ArrayList;
|
| | |
|
| | | /**
|
| | | * Created by houxiao on 2017/3/21 0021.
|
| | | */
|
| | |
|
| | | class NativeImgIdx {
|
| | | public int offset;
|
| | | public int size;
|
| | | public int type;
|
| | | public int width;
|
| | | public int height;
|
| | | }
|
| | |
|
| | | class RefByteArray
|
| | | {
|
| | | public byte[] arr;
|
| | | }
|
| | |
|
| | | public class RtspFaceNative {
|
| | |
|
| | | //cn.com.basic.face.util.RtspFaceNative
|
| | |
|
| | | public static native void init();
|
| | | public static native void setSurface(int cameraIdx, Surface surface);
|
| | | public static native boolean createPlayer(int cameraIdx, String uri);
|
| | | public static native void shutdown(int cameraIdx);
|
| | | // typedef void (* Java_com_example_nativecodec_NativeCodec_FaceCallback_func)(int cameraIdx, int count);
|
| | | public static native boolean setFaceCallback(int cameraIdx, String className, String funcName);
|
| | | public static native void lockFace(int cameraIdx);
|
| | | public static native void releaseFace(int cameraIdx);
|
| | | public static native int getFaceList(int cameraIdx, RefByteArray faceListPb);
|
| | | public static native ArrayList<NativeImgIdx> getFaceImages(int cameraIdx, RefByteArray faceImages);
|
| | |
|
| | | public static void faceCallBack(int cameraIdx, int count)
|
| | | {
|
| | | Log.i("@@@", "RtspFaceNative.faceCallBack, cameraIdx=" + cameraIdx + ", count=" + count);
|
| | |
|
| | | // something else
|
| | | if (count <= 0)
|
| | | return;
|
| | |
|
| | | lockFace(cameraIdx);
|
| | |
|
| | | RefByteArray faceListPb = new RefByteArray();
|
| | | int s = getFaceList(cameraIdx, faceListPb);
|
| | | Log.i("@@@", "RtspFaceNative.faceCallBack, getFaceList, cameraIdx=" + cameraIdx + ", size=" + s);
|
| | |
|
| | | RefByteArray faceImages = new RefByteArray();
|
| | | ArrayList<NativeImgIdx> faceImagesIdx = getFaceImages(cameraIdx, faceImages);
|
| | | int c = 0;
|
| | | if (faceImagesIdx != null)
|
| | | c = faceImagesIdx.size();
|
| | | Log.i("@@@", "RtspFaceNative.faceCallBack, getFaceImages, cameraIdx=" + cameraIdx + ", count=" + c);
|
| | |
|
| | | releaseFace(cameraIdx);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | // static int i = 1;
|
| | | // public static void faceCallBack(int cameraIdx, int count)
|
| | | // {
|
| | | // lockFace(cameraIdx);
|
| | | //
|
| | | // byte[] faceListPb = new byte[1024 * 1024 * 1];
|
| | | // int s = getFaceList(cameraIdx, faceListPb);
|
| | | //
|
| | | // //;byte(faceListPb,s)
|
| | | //
|
| | | //
|
| | | // int[] faceImagesIdx = new int[10];
|
| | | // byte[] faceImages = new byte[1024 * 1024 * 1];
|
| | | // int c = getFaceImages(cameraIdx, faceImagesIdx, faceImages);
|
| | | //
|
| | | // try {
|
| | | // File path = BaseApplication.getInstance().getFilesDir();
|
| | | // File f1 = new File(path, ""+i);
|
| | | // if (!f1.exists()) {
|
| | | // f1.createNewFile();
|
| | | // }
|
| | | // FileOutputStream f = new FileOutputStream(f1);
|
| | | // f.write(faceImages);
|
| | | // f.close();
|
| | | // RequestParams params = new RequestParams();
|
| | | // String encodedImage = Base64.encodeToString(faceImages, Base64.DEFAULT);
|
| | | // params.addBodyParameter("choosePhoto", encodedImage);
|
| | | // RegisterMng.getInstance().add(params);
|
| | | // } catch (Exception e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | //
|
| | | // releaseFace(cameraIdx);
|
| | | // }
|
| | |
|
| | | // public static void init() {};
|
| | | // public static void setSurface(int cameraIdx, Surface surface){};
|
| | | // public static boolean createPlayer(int cameraIdx, String uri){return true;};
|
| | | // public static void shutdown(int cameraIdx){};
|
| | | // // typedef void (* Java_com_example_nativecodec_NativeCodec_FaceCallback_func)(int cameraIdx, int count);
|
| | | // public static boolean setFaceCallback(int cameraIdx, String func){return true;};
|
| | | // public static void lockFace(int cameraIdx){};
|
| | | // public static void releaseFace(int cameraIdx){};
|
| | | // public static boolean getFaceList(int cameraIdx, byte[] faceListPb){return true;};//二进制
|
| | | // public static boolean getFaceImages(int cameraIdx, byte[] faceImagesIdx, byte[] faceImages){return true;};//图片
|