| | |
| | | package cn.com.basic.face.util;
|
| | |
|
| | | import android.util.Base64;
|
| | | import android.view.Surface;
|
| | |
|
| | | /**
|
| | | * Created by xiuxi on 2017/3/21.
|
| | | */
|
| | | import org.xutils.http.RequestParams;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.util.ArrayList;
|
| | |
|
| | | 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 func);
|
| | | // public static native void lockFace(int cameraIdx);
|
| | | // public static native void releaseFace(int cameraIdx);
|
| | | // public static native boolean getFaceList(int cameraIdx, byte[] faceListPb);
|
| | | // public static native boolean getFaceImages(int cameraIdx, byte[] faceImagesIdx, byte[] faceImages);
|
| | |
|
| | | 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){};
|
| | | 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 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;};//图片
|
| | | 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 ArrayList<NativeImgIdx> getFaceImages(int cameraIdx, byte[] faceImages);
|
| | |
|
| | | public static void faceCallBack(int cameraIdx, int count)
|
| | | {
|
| | |
|
| | | lockFace(cameraIdx);
|
| | |
|
| | | byte[] faceListPb = new byte[1024 * 1024 * 1];
|
| | | int s = getFaceList(cameraIdx, faceListPb);
|
| | |
|
| | | byte[] faceImages = new byte[1024 * 1024 * 1];
|
| | | ArrayList<NativeImgIdx> faceImagesIdx = getFaceImages(cameraIdx, faceImages);
|
| | | int c = 0;
|
| | | if (faceImagesIdx != null)
|
| | | c = faceImagesIdx.size();
|
| | |
|
| | | for (int i = 0; i < c; i++) {
|
| | | System.out.println(i);
|
| | | // faceImagesIdx.get(i).offset, faceImagesIdx.get(i).size;
|
| | | 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, faceImagesIdx.get(i).offset, faceImagesIdx.get(i).size);
|
| | | f.close();
|
| | |
|
| | |
|
| | | RequestParams params = new RequestParams();
|
| | | // String encodedImage = Base64.encodeToString(faceImages, Base64.DEFAULT);
|
| | | params.addBodyParameter("choosePhoto", f1);
|
| | | RegisterMng.getInstance().add(params);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | 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;};//图片
|
| | |
|
| | | }
|