New file |
| | |
| | | package cn.com.basic.face.util;
|
| | |
|
| | | import android.util.Base64;
|
| | | import android.view.Surface;
|
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | |
|
| | | import cn.com.basic.face.base.BaseApplication;
|
| | | import cn.com.basic.face.service.RegisterMng;
|
| | |
|
| | | public class 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, byte[] faceListPb);
|
| | | public static native int getFaceImages(int cameraIdx, int[] faceImagesIdx, byte[] faceImages);
|
| | |
|
| | | 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);
|
| | |
|
| | | 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;};//图片
|
| | |
|
| | | }
|