| | |
| | | import android.util.Log;
|
| | | import android.view.Surface;
|
| | |
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.InputStream;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | | import cn.com.basic.face.fragment.RegisterFragment;
|
| | | import cn.com.basic.face.base.BaseApplication;
|
| | | import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
|
| | | import cn.com.basic.face.service.SurveillanceMng;
|
| | |
|
| | | /**
|
| | |
| | | public byte[][] arr2;
|
| | | }
|
| | |
|
| | | class NativeImg
|
| | | {
|
| | | public int size;
|
| | | public int type;
|
| | | public int width;
|
| | | public int height;
|
| | | public byte[] image;
|
| | | }
|
| | |
|
| | |
|
| | | public class RtspFaceNative {
|
| | |
|
| | |
| | | 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 int getFaceList(int cameraIdx, int dbId, RefByteArray faceListPb);
|
| | | //public static native ArrayList<NativeImgIdx> getFaceImages(int cameraIdx, RefByteArray faceImages);
|
| | | public static native ArrayList<NativeImg> getFaceImages(int cameraIdx);
|
| | |
|
| | | public static native void dbgFaceAdd(NativeImg faceImage);
|
| | | public static native String dbgGetLog();
|
| | | public static native void dbgSetStfaceLicense(String lic);
|
| | |
|
| | | public static int COMPANY_ID = 1001;
|
| | |
|
| | | public static void faceCallBack(int cameraIdx, int count)
|
| | | {
|
| | | System.out.println("cameraIdex="+cameraIdx+", count="+count);
|
| | | Log.i("@@@", "RtspFaceNative.faceCallBack, cameraIdx=" + cameraIdx + ", count=" + count);
|
| | |
|
| | | // something else
|
| | |
| | | lockFace(cameraIdx);
|
| | |
|
| | | RefByteArray faceListPb = new RefByteArray();
|
| | | int s = getFaceList(cameraIdx, faceListPb);
|
| | |
|
| | | try {
|
| | | COMPANY_ID = Integer.parseInt(BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | } catch (Exception e) {
|
| | | COMPANY_ID = 0;
|
| | | }
|
| | |
|
| | | int s = getFaceList(cameraIdx, COMPANY_ID, faceListPb);
|
| | | Log.i("@@@", "RtspFaceNative.faceCallBack, getFaceList, cameraIdx=" + cameraIdx + ", size=" + s);
|
| | |
|
| | | //RefByteArray faceImages = new RefByteArray();
|
| | |
| | | ", h=" + faceImages.get(i).height +
|
| | | ", image[0]=" + faceImages.get(i).image[0] +
|
| | | ", image[1]=" + faceImages.get(i).image[1]);
|
| | |
|
| | | if (i == 0)
|
| | | {
|
| | | //Bitmap bitmap = Bitmap.createBitmap(faceImages.get(i).width, faceImages.get(i).height, Bitmap.Config.RGB_565);
|
| | | //ByteBuffer byteBuffer = ByteBuffer.wrap(faceImages.get(i).image, 0, faceImages.get(i).size);
|
| | | //bitmap.copyPixelsFromBuffer(byteBuffer);
|
| | | //NativeCodec.setFaceDrawable(bitmap);
|
| | |
|
| | | //NativeCodec.setFaceDrawable(faceImages.get(i));
|
| | | }
|
| | | }
|
| | |
|
| | | try{
|
| | | List<Bitmap> bitmapList = new ArrayList();
|
| | |
|
| | | List<SurveillanceQueryItem> bitmapList = new ArrayList();
|
| | | for (int i = 0; i < faceImages.size(); i++) {
|
| | | NativeImg item = faceImages.get(i);
|
| | | SurveillanceQueryItem surveillanceQueryItem = new SurveillanceQueryItem();
|
| | | int offset = 0;
|
| | | int size = item.size;
|
| | | Bitmap bitmap = Bitmap.createBitmap(item.width,item.height, Bitmap.Config.RGB_565);
|
| | | ByteBuffer byteBuffer = ByteBuffer.wrap(item.image, offset, size);
|
| | | //byteBuffer.rewind();
|
| | | bitmap.copyPixelsFromBuffer(byteBuffer);
|
| | | bitmapList.add(bitmap);
|
| | | // String str = Base64.encodeToString(item.image, offset, size, Base64.DEFAULT);
|
| | | // System.out.println(str.length());
|
| | | // System.out.println(str);
|
| | | // surveillanceQueryItem.setBase64Image(str);
|
| | | surveillanceQueryItem.setNativeImg(item);
|
| | | surveillanceQueryItem.setBitmap(bitmap);
|
| | | surveillanceQueryItem.setWidth(item.width+"");
|
| | | surveillanceQueryItem.setHeight(item.height+"");
|
| | | bitmapList.add(surveillanceQueryItem);
|
| | | }
|
| | | SurveillanceMng.getInstance().addBitmap(bitmapList, faceListPb.arr, s);
|
| | | SurveillanceMng.getInstance().addBitmap(bitmapList, faceListPb.arr, s, cameraIdx+"");
|
| | |
|
| | | }catch(Exception e){
|
| | | e.printStackTrace();
|