完善并提交最终版本

master
XF1001 4 years ago
parent c1fde1dc4e
commit 8f6bbbc4f7

@ -54,7 +54,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
private EditText pwdEdit = null; private EditText pwdEdit = null;
private EditText didEdit = null; private EditText didEdit = null;
private TextView textView_top_show = null; private TextView textView_top_show = null;
private Button done; private Button button_conn;
private static final int SEARCH_TIME = 3000; private static final int SEARCH_TIME = 3000;
private int option = ContentCommon.INVALID_OPTION; private int option = ContentCommon.INVALID_OPTION;
private int CameraType = ContentCommon.CAMERA_TYPE_MJPEG; private int CameraType = ContentCommon.CAMERA_TYPE_MJPEG;
@ -134,7 +134,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
Thread.sleep(100); Thread.sleep(100);
} catch (Exception e) { } catch (Exception e) {
} }
if(SystemValue.deviceId.toLowerCase().startsWith("vsta")) if(SystemValue.deviceId.toLowerCase().startsWith("vsta"))
{ {
NativeCaller.StartPPPPExt(SystemValue.deviceId, SystemValue.deviceName, NativeCaller.StartPPPPExt(SystemValue.deviceId, SystemValue.deviceName,
@ -278,7 +278,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
} }
private void InitParams() { private void InitParams() {
done.setOnClickListener(this); button_conn.setOnClickListener(this);
btnSearchCamera.setOnClickListener(this); btnSearchCamera.setOnClickListener(this);
//监听软键盘的删除键 //监听软键盘的删除键
userEdit.setOnKeyListener(new View.OnKeyListener() { userEdit.setOnKeyListener(new View.OnKeyListener() {
@ -329,7 +329,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
} }
progressdlg.dismiss(); progressdlg.dismiss();
NativeCaller.StopSearch(); NativeCaller.StopSearch();
} }
@Override @Override
@ -353,7 +353,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
updateListHandler.sendMessage(msg); updateListHandler.sendMessage(msg);
} }
}; };
Handler updateListHandler = new Handler() { Handler updateListHandler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -403,7 +403,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
Toast.makeText(AddCameraActivity.this, Toast.makeText(AddCameraActivity.this,
getResources().getString(R.string.add_search_no), getResources().getString(R.string.add_search_no),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
isSearched = false;// isSearched = false;//
} }
} }
} }
@ -431,7 +431,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
textView_top_show = (TextView) findViewById(R.id.login_textView1); textView_top_show = (TextView) findViewById(R.id.login_textView1);
button_play = (Button) findViewById(R.id.play); button_play = (Button) findViewById(R.id.play);
button_setting = (Button) findViewById(R.id.setting); button_setting = (Button) findViewById(R.id.setting);
done = (Button) findViewById(R.id.done); button_conn = (Button) findViewById(R.id.done);
//done.setText("连接"); //done.setText("连接");
userEdit = (EditText) findViewById(R.id.editUser); userEdit = (EditText) findViewById(R.id.editUser);
@ -841,7 +841,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa
} }
} }
private String spitValue(String name, String tag) { public String spitValue(String name, String tag) {
String[] strs = name.split(";"); String[] strs = name.split(";");
for (int i = 0; i < strs.length; i++) { for (int i = 0; i < strs.length; i++) {
String str1 = strs[i].trim(); String str1 = strs[i].trim();

@ -207,7 +207,7 @@ public class BridgeService extends Service
break; break;
case ContentCommon.MSG_TYPE_SET_ALARM: case ContentCommon.MSG_TYPE_SET_ALARM:
if (alarmInterface != null) { if (alarmInterface != null) {
// Log.d(TAG,"user result:"+result+" paramType:"+paramType); Log.d(TAG,"user result:"+result+" paramType:"+paramType);
alarmInterface.callBackSetSystemParamsResult(did, paramType,result); alarmInterface.callBackSetSystemParamsResult(did, paramType,result);
} }
break; break;
@ -1313,7 +1313,6 @@ public class BridgeService extends Service
// 联动摄像机取消报警 // 联动摄像机取消报警
if (sensoraction == ContentCommon.SENSOR_ALARM_ACTION_CANCELALARM) if (sensoraction == ContentCommon.SENSOR_ALARM_ACTION_CANCELALARM)
{ {
} }
if (selfcmd == ContentCommon.SENSOR_ALARM_ACTION_ALARM&& sensoraction == 8) if (selfcmd == ContentCommon.SENSOR_ALARM_ACTION_ALARM&& sensoraction == 8)
@ -1371,7 +1370,7 @@ public class BridgeService extends Service
} }
//add start by ydzhu 2017-11-20 增加tf卡播放下载接口 //增加tf卡播放下载接口
public void CallBack_TFCardPlayback(String did, byte[] yuv, int type, public void CallBack_TFCardPlayback(String did, byte[] yuv, int type,
int size,int width,int height, int timestamp,float pos,float cachePOS) { int size,int width,int height, int timestamp,float pos,float cachePOS) {
@ -1385,13 +1384,11 @@ public class BridgeService extends Service
public void CallBack_TFCardRecord(String did, float pos,int nError) { public void CallBack_TFCardRecord(String did, float pos,int nError) {
} }
//add end
public void CallBack_LowpowerDevMag(String did,int nState) { public void CallBack_LowpowerDevMag(String did,int nState) {
} }
//start vuid
/** /**
(sdk0x1240使SearchResult) (sdk0x1240使SearchResult)
@param sysVer: @param sysVer:
@ -1415,7 +1412,6 @@ public class BridgeService extends Service
} }
//start vuid by dunn 2019-10-22
/** /**
StartVUID StartVUID
@param did: UID @param did: UID

@ -123,7 +123,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private static final String HANDLE_THREAD_NAME = "cameraBackground"; private static final String HANDLE_THREAD_NAME = "cameraBackground";
/**定时处理检测消息的Handler和timer*/ /**定时处理检测消息的Handler和timer*/
protected Handler timeHandler; private Handler timeHandler;
Timer timer4Fatigue = null; Timer timer4Fatigue = null;
Timer timer4Nod = null; Timer timer4Nod = null;
Timer timer4Init = null; Timer timer4Init = null;
@ -257,9 +257,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private static final float MINIMUM_CONFIDENCE_TF_OD_API = 0.6f; private static final float MINIMUM_CONFIDENCE_TF_OD_API = 0.6f;
private static final int AUDIO_BUFFER_START_CODE = 0xff00ff; private static final int AUDIO_BUFFER_START_CODE = 0xff00ff;
//surfaceView控键 /**surfaceView控键*/
private GLSurfaceView playSurface = null; private GLSurfaceView playSurface = null;
//GLSurfaceView的渲染器 /**GLSurfaceView的渲染器*/
private MyRender myRender; private MyRender myRender;
/** /**
* videodata * videodata
@ -284,9 +284,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private boolean bInitCameraParam = false; private boolean bInitCameraParam = false;
private boolean bManualExit = false; private boolean bManualExit = false;
private TextView textosd = null; private TextView textosd = null;//顶部textView显示用户名的
private String strName = null; private String strName = null;//用户名
private String strDID = null; private String strDID = null;//设备id
private View osdView = null; private View osdView = null;
private boolean bDisplayFinished = true; private boolean bDisplayFinished = true;
private CustomBuffer AudioBuffer = null; private CustomBuffer AudioBuffer = null;
@ -298,10 +298,10 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private ImageView videoViewStandard; private ImageView videoViewStandard;
//底部控件声明 //底部控件声明
private HorizontalScrollView bottomView; private HorizontalScrollView bottomView;
//下面是一系列功能按钮
private ImageButton ptzAudio, ptztalk, ptzDefaultSet, ptzBrightness, ptzContrast, ptzTake_photos, ptzTake_vodeo, ptzResolutoin, preset; private ImageButton ptzAudio, ptztalk, ptzDefaultSet, ptzBrightness, ptzContrast, ptzTake_photos, ptzTake_vodeo, ptzResolutoin, preset;
private int nStreamCodecType;//分辨率格式 private int nStreamCodecType;//分辨率格式
private PopupWindow controlWindow;//设备方向控制提示控件 private PopupWindow controlWindow;//设备方向控制提示控件
private PopupWindow mPopupWindowProgress;//进度条控件 private PopupWindow mPopupWindowProgress;//进度条控件
private PopupWindow presetBitWindow;//预置位面板 private PopupWindow presetBitWindow;//预置位面板
@ -358,7 +358,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private int picNum = 0;//拍照张数标识 private int picNum = 0;//拍照张数标识
/** /**
* @Description 退 * @Description 退
* @Throws * @Throws
* NullPointerException dialog * NullPointerException dialog
*/ */
public void showSureDialog() { public void showSureDialog() {
@ -385,6 +385,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
builder.show(); builder.show();
} }
/**设置灯与警笛的视图(改软件系统的摄像头无法配置)*/
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
private Handler deviceParamsHandler = new Handler() { private Handler deviceParamsHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -432,6 +433,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
int disPlaywidth; int disPlaywidth;
private Bitmap mBmp; private Bitmap mBmp;
//传输视频流回调的Handler
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() { private Handler mHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -651,7 +653,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private Handler msgHandler = new Handler() { private Handler msgHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if (msg.what == 1) { if (msg.what == 1) {
//Log.d("tag", "断线了"); Log.d("tag", "断线了");
Toast.makeText(getApplicationContext(), Toast.makeText(getApplicationContext(),
R.string.pppp_status_disconnect, Toast.LENGTH_SHORT) R.string.pppp_status_disconnect, Toast.LENGTH_SHORT)
.show(); .show();
@ -662,10 +664,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
//视频流帧池,存储视频流,保证以一个稳定的帧数输出 //视频流帧池,存储视频流,保证以一个稳定的帧数输出
private VideoFramePool framePool; private VideoFramePool framePool;
/**
*
* @param savedInstanceState
*/
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -675,7 +673,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.play); setContentView(R.layout.play);
//mine //设置音频播放器
onCompletionListener = new MediaPlayer.OnCompletionListener() { onCompletionListener = new MediaPlayer.OnCompletionListener() {
@Override @Override
public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) {
@ -690,9 +688,10 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
alarmPlayer.start(); alarmPlayer.start();
isAlarming = true; isAlarming = true;
showToast(R.string.initing); showToast(R.string.initing);
//脸部框图初始化
mFaceRect = new DrawCaptureRect(getApplicationContext(), mFaceRect = new DrawCaptureRect(getApplicationContext(),
190, 10, 1, 1, getResources().getColor(R.color.color_green)); 190, 10, 1, 1, getResources().getColor(R.color.color_green));
//在一个activity上面添加额外的content //在一个activity上面添加额外的content(脸部框图)
addContentView(mFaceRect, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT)); addContentView(mFaceRect, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
try { try {
classifier = TensorFlowObjectDetectionAPIModel.create( classifier = TensorFlowObjectDetectionAPIModel.create(
@ -730,7 +729,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
showBottom(); showBottom();
//灯与警笛 //灯与警笛(改软件系统的摄像头无法配置)
if (SystemValue.supportLightAndSirenO13AndO10(MySharedPreferenceUtil.getSystemVer(this, strDID))) { if (SystemValue.supportLightAndSirenO13AndO10(MySharedPreferenceUtil.getSystemVer(this, strDID))) {
getLightAndSirenStatte(strDID, SystemValue.devicePass); getLightAndSirenStatte(strDID, SystemValue.devicePass);
lightBtn.setVisibility(View.VISIBLE); lightBtn.setVisibility(View.VISIBLE);
@ -790,6 +789,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
NativeCaller.PPPPCameraControl(strDID, 16, Resolution); NativeCaller.PPPPCameraControl(strDID, 16, Resolution);
} }
/**
*
*/
private void findView() { private void findView() {
//方向控制提示框 //方向控制提示框
initControlDailog(); initControlDailog();
@ -857,7 +859,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
if (!isDown) { if (!isDown) {
x1 = event.getX(); x1 = event.getX();
y1 = event.getY(); y1 = event.getY();
@ -871,7 +872,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
originalScale = getScale(); originalScale = getScale();
break; break;
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
if (Math.abs((x1 - x2)) < 25 && Math.abs((y1 - y2)) < 25) { if (Math.abs((x1 - x2)) < 25 && Math.abs((y1 - y2)) < 25) {
@ -914,38 +914,12 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
private Matrix matrix = new Matrix(); private Matrix matrix = new Matrix();
private Matrix savedMatrix = new Matrix(); private Matrix savedMatrix = new Matrix();
private PointF start = new PointF(); private PointF start = new PointF();
private PointF mid = new PointF();
float mMaxZoom = 2.0f;
float mMinZoom = 0.3125f;
float originalScale; float originalScale;
float baseValue;
protected Matrix mBaseMatrix = new Matrix(); protected Matrix mBaseMatrix = new Matrix();
protected Matrix mSuppMatrix = new Matrix(); protected Matrix mSuppMatrix = new Matrix();
private Matrix mDisplayMatrix = new Matrix(); private Matrix mDisplayMatrix = new Matrix();
private final float[] mMatrixValues = new float[9]; private final float[] mMatrixValues = new float[9];
protected void zoomTo(float scale, float centerX, float centerY) {
Log.d("zoomTo", "zoomTo scale:" + scale);
if (scale > mMaxZoom) {
scale = mMaxZoom;
} else if (scale < mMinZoom) {
scale = mMinZoom;
}
float oldScale = getScale();
float deltaScale = scale / oldScale;
Log.d("deltaScale", "deltaScale:" + deltaScale);
mSuppMatrix.postScale(deltaScale, deltaScale, centerX, centerY);
videoViewStandard.setScaleType(ImageView.ScaleType.MATRIX);
videoViewStandard.setImageMatrix(getImageViewMatrix());
}
protected Matrix getImageViewMatrix() {
mDisplayMatrix.set(mBaseMatrix);
mDisplayMatrix.postConcat(mSuppMatrix);
return mDisplayMatrix;
}
protected float getScale(Matrix matrix) { protected float getScale(Matrix matrix) {
return getValue(matrix, Matrix.MSCALE_X); return getValue(matrix, Matrix.MSCALE_X);
} }
@ -959,30 +933,13 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
return mMatrixValues[whichValue]; return mMatrixValues[whichValue];
} }
/*private float (MotionEvent event) {
try {
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
return FloatMath.sqrt(x * x + y * y);
} catch (Exception e) {
}
return 0;
}*/
private void midPoint(PointF point, MotionEvent event) {
float x = event.getX(0) + event.getX(1);
float y = event.getY(0) + event.getY(1);
point.set(x / 2, y / 2);
}
@Override @Override
public boolean onDown(MotionEvent e) { public boolean onDown(MotionEvent e) {
Log.d("tag", "onDown"); Log.d("tag", "onDown");
return false; return false;
} }
private final int MINLEN = 80;//最小间距 private final int MINLEN = 80;//滑动的最小间距
private Animation showTopAnim; private Animation showTopAnim;
private Animation dismissTopAnim; private Animation dismissTopAnim;
private boolean isPTZPrompt; private boolean isPTZPrompt;
@ -1033,7 +990,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
@Override @Override
public void onShowPress(MotionEvent e) { public void onShowPress(MotionEvent e) {
} }
@Override @Override
@ -1041,22 +997,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
return false; return false;
} }
/**下方按钮的按键响应*/
public void showSureDialogPlay() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.app);
builder.setTitle(getResources().getString(R.string.exit_show));
builder.setMessage(R.string.exit_play_show);
builder.setPositiveButton(R.string.str_ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
PlayActivity.this.finish();
}
});
builder.setNegativeButton(R.string.str_cancel, null);
builder.show();
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
@ -1276,9 +1217,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
} }
/**
/* *
*
*/ */
private class ControlDeviceTask extends AsyncTask<Void, Void, Integer> { private class ControlDeviceTask extends AsyncTask<Void, Void, Integer> {
private int type; private int type;
@ -1354,7 +1294,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
isControlDevice = false; isControlDevice = false;
if (controlWindow != null && controlWindow.isShowing()) if (controlWindow != null && controlWindow.isShowing())
controlWindow.dismiss(); controlWindow.dismiss();
//mine //每次摄像头朝向改变,需要重新开启定时器,重新初始化
stopBackgroundThread(); stopBackgroundThread();
reInitPosition(); reInitPosition();
makeInitAlarm(3); makeInitAlarm(3);
@ -1362,7 +1302,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
} }
/**
*
*/
private void reInitPosition() { private void reInitPosition() {
initPosition = true; initPosition = true;
fail2Init = false; fail2Init = false;
@ -1978,7 +1920,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
public static Map<String, Map<Object, Object>> reslutionlist = new HashMap<String, Map<Object, Object>>(); public static Map<String, Map<Object, Object>> reslutionlist = new HashMap<String, Map<Object, Object>>();
/** /**
* reslution * reslution Handler
*/ */
private void addReslution(String mess, boolean isfast) { private void addReslution(String mess, boolean isfast) {
if (reslutionlist.size() != 0) { if (reslutionlist.size() != 0) {
@ -2014,7 +1956,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
} }
/* /**
* @param type * @param type
* *
*/ */
@ -2076,16 +2018,18 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
@Override @Override
protected synchronized void onDestroy() { protected synchronized void onDestroy() {
NativeCaller.StopPPPPLivestream(strDID); NativeCaller.StopPPPPLivestream(strDID);//提示摄像头停止传输视频流
StopAudio(); StopAudio();//停止播放音频
StopTalk(); StopTalk();//停止对讲
stopTakevideo(); stopTakevideo();//停止录像
//mine releaseAll();//释放定时器和tenginekit面部检测模型
releaseAll(); classifier.close();//关闭tensorflow的分类器模型
classifier.close();
super.onDestroy(); super.onDestroy();
} }
/**
* tenginekit
*/
public void releaseAll() { public void releaseAll() {
timeHandler.removeMessages(INIT_MSG); timeHandler.removeMessages(INIT_MSG);
timeHandler.removeMessages(FATIGUE_MSG); timeHandler.removeMessages(FATIGUE_MSG);
@ -2111,8 +2055,11 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
/*** /***
* BridgeService callback * BridgeService callback
* * @Param didid
* @Param brightness
* @Param constrat
* @Param flip使
* **/ * **/
@Override @Override
public void callBackCameraParamNotify(String did, int resolution, public void callBackCameraParamNotify(String did, int resolution,
@ -2127,12 +2074,11 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
/** /**
* *
* * @param videobuf
* @param videobuf * @param h264Data h264
* @param h264Data * @param len
* @param len * @param width
* @param width * @param height
* @param height
*/ */
@Override @Override
public void callBackVideoData(final byte[] videobuf, int h264Data, int len, int width, int height) { public void callBackVideoData(final byte[] videobuf, int h264Data, int len, int width, int height) {
@ -2143,7 +2089,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
previewHeight = height; previewHeight = height;
try { try {
if (mNV21Bytes == null) { if (mNV21Bytes == null) {
Init(); Init();//初始化tengineKit
} }
} catch (final Exception e) { } catch (final Exception e) {
Log.e(LOG_TAG, "callBackVideoData: " + e); Log.e(LOG_TAG, "callBackVideoData: " + e);
@ -2155,7 +2101,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
mNV21Bytes = videobuf; mNV21Bytes = videobuf;
} }
}; };
processImage(); processImage();//调用检测函数
//mine //mine
bDisplayFinished = false; bDisplayFinished = false;
videodata = videobuf; videodata = videobuf;
@ -2270,7 +2216,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
judgeEyesClose(faceAttr); judgeEyesClose(faceAttr);
judgeYawn(faceAttr); judgeYawn(faceAttr);
judgeNod(faceAttr); judgeNod(faceAttr);
judgeNotice(faceIrisInfo.get(0), faceAttr); judgeAttention(faceIrisInfo.get(0), faceAttr);
} }
} else { } else {
if (notDetectFrame >= 50) { if (notDetectFrame >= 50) {
@ -2294,7 +2240,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
mFaceRect.invalidate(); mFaceRect.invalidate();
} }
} }
//初始化人脸检测的有关参数
private void initParams() { private void initParams() {
totalFrameNumber = 0; totalFrameNumber = 0;
twiceTimes = 2; twiceTimes = 2;
@ -2317,9 +2263,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
/** /**
* 姿 * 姿
* * @param faceAttr
* @param faceAttr
*/ */
private void initHeadPosition(FaceLandmarkInfo faceAttr) { private void initHeadPosition(FaceLandmarkInfo faceAttr) {
totalPitch = totalPitch + faceAttr.pitch; totalPitch = totalPitch + faceAttr.pitch;
@ -2330,8 +2275,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
/** /**
* *
* * @param faceAttr
* @param faceAttr
*/ */
private void judgeEyesClose(FaceLandmarkInfo faceAttr) { private void judgeEyesClose(FaceLandmarkInfo faceAttr) {
if (initPosition) return; if (initPosition) return;
@ -2347,8 +2291,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
/** /**
* *
* * @param faceAttr
* @param faceAttr
*/ */
private void judgeYawn(FaceLandmarkInfo faceAttr) { private void judgeYawn(FaceLandmarkInfo faceAttr) {
if (initPosition) return; if (initPosition) return;
@ -2402,8 +2345,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
/** /**
* 姿 * 姿
* * @param faceAttr
* @param faceAttr
*/ */
private void judgeNod(FaceLandmarkInfo faceAttr) { private void judgeNod(FaceLandmarkInfo faceAttr) {
if (initPosition) return; if (initPosition) return;
@ -2416,10 +2358,10 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
/** /**
* 线 * 线
* * @param faceIrisInfo
* @param faceIrisInfo * @param faceAttr
*/ */
private void judgeNotice(FaceIrisInfo faceIrisInfo, FaceLandmarkInfo faceAttr) { private void judgeAttention(FaceIrisInfo faceIrisInfo, FaceLandmarkInfo faceAttr) {
if (initPosition) return; if (initPosition) return;
if (isEyesClose) { if (isEyesClose) {
loseNoticeFrame = 0; loseNoticeFrame = 0;
@ -2429,7 +2371,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
TenginekitPoint leftCorner = faceIrisInfo.leftEye.eyeLandmark.get(8); TenginekitPoint leftCorner = faceIrisInfo.leftEye.eyeLandmark.get(8);
TenginekitPoint leftOuterCorner = faceIrisInfo.leftEye.eyeLandmark.get(0); TenginekitPoint leftOuterCorner = faceIrisInfo.leftEye.eyeLandmark.get(0);
float deviation = (leftCenter.X - leftOuterCorner.X) / (leftCorner.X - leftOuterCorner.X); float deviation = (leftCenter.X - leftOuterCorner.X) / (leftCorner.X - leftOuterCorner.X);
//Log.d(LOG_TAG, "judgeNotice: devuation" + Float.toString(deviation));
if (deviation < noticeThreshold1 || deviation > noticeThreshold2 || Math.abs(faceAttr.yaw - normalYaw) > 20) { if (deviation < noticeThreshold1 || deviation > noticeThreshold2 || Math.abs(faceAttr.yaw - normalYaw) > 20) {
loseNoticeFrame = loseNoticeFrame + 1; loseNoticeFrame = loseNoticeFrame + 1;
} else { } else {
@ -2441,7 +2382,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
} }
//发出初始化提示 //发出初始化提示警报
public void makeInitAlarm(int flag) { public void makeInitAlarm(int flag) {
if (isAlarming) return; if (isAlarming) return;
if (alarmPlayer != null) { if (alarmPlayer != null) {
@ -2476,7 +2417,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
break; break;
} }
} }
//发出未检测到人的警报
public void makenotDetectFrameAlarm() { public void makenotDetectFrameAlarm() {
if (isAlarming || initPosition) return; if (isAlarming || initPosition) return;
if (alarmPlayer != null) { if (alarmPlayer != null) {
@ -2564,7 +2505,28 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
alarmPlayer.start(); alarmPlayer.start();
isAlarming = true; isAlarming = true;
} }
//发出使用手机的警报
public void makePhoneAlarm() {
if (isAlarming || initPosition) return;
if (alarmPlayer != null) {
alarmPlayer.release();
}
alarmPlayer = MediaPlayer.create(this, R.raw.phone);
alarmPlayer.setOnCompletionListener(onCompletionListener);
alarmPlayer.start();
isAlarming = true;
}
//发出吸烟的警报
public void makeSmokingAlarm() {
if (isAlarming || initPosition) return;
if (alarmPlayer != null) {
alarmPlayer.release();
}
alarmPlayer = MediaPlayer.create(this, R.raw.smoke);
alarmPlayer.setOnCompletionListener(onCompletionListener);
alarmPlayer.start();
isAlarming = true;
}
//重置疲劳检测的有关参数 //重置疲劳检测的有关参数
private void reSetParameter() { private void reSetParameter() {
totalFrameNumber = 0; totalFrameNumber = 0;
@ -2580,7 +2542,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
@Override @Override
public synchronized void onResume() { public synchronized void onResume() {
super.onResume(); super.onResume();
handleTimeMsg(); handleTimeMsg();//开启定时器
} }
@Override @Override
@ -2588,7 +2550,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
stopBackgroundThread(); stopBackgroundThread();
super.onPause(); super.onPause();
} }
//定时处理监控信息,判定疲劳和偏头行为
public void handleTimeMsg() { public void handleTimeMsg() {
timeHandler = new Handler(new Handler.Callback() { timeHandler = new Handler(new Handler.Callback() {
@Override @Override
@ -2689,8 +2651,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
* **/ * **/
@Override @Override
public void callBackMessageNotify(String did, int msgType, int param) { public void callBackMessageNotify(String did, int msgType, int param) {
Log.d("tag", "MessageNotify did: " + did + " msgType: " + msgType /*Log.d("tag", "MessageNotify did: " + did + " msgType: " + msgType
+ " param: " + param); + " param: " + param);*/
if (bManualExit) if (bManualExit)
return; return;
@ -2772,11 +2734,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
} }
/** /**
* r
* *
* * @param didid
* @param did * @param pwd
* @param pwd
*/ */
public static void getLightAndSirenStatte(String did, String pwd) { public static void getLightAndSirenStatte(String did, String pwd) {
NativeCaller.TransferMessage(did, "trans_cmd_string.cgi?cmd=2109&command=2" + "&loginuse=" + "admin" + "&loginpas=" + pwd, 1); NativeCaller.TransferMessage(did, "trans_cmd_string.cgi?cmd=2109&command=2" + "&loginuse=" + "admin" + "&loginpas=" + pwd, 1);
@ -2804,6 +2764,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
*/ */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void stopBackgroundThread() { private void stopBackgroundThread() {
if(backgroundHandler == null)
return ;
backgroundThread.quitSafely(); backgroundThread.quitSafely();
try { try {
backgroundThread.join(); backgroundThread.join();
@ -2834,7 +2796,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
}; };
/** /**
* tensorFlow * tensorFlow使
*/ */
private void classifyFrame() { private void classifyFrame() {
if (classifier == null || initPosition || videodata == null) { if (classifier == null || initPosition || videodata == null) {
@ -2852,15 +2814,14 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL
final RectF location = result.getLocation(); final RectF location = result.getLocation();
if (location != null && result.getConfidence() >= MINIMUM_CONFIDENCE_TF_OD_API) { if (location != null && result.getConfidence() >= MINIMUM_CONFIDENCE_TF_OD_API) {
if (result.getTitle().equals("phone")) { if (result.getTitle().equals("phone")) {
; makePhoneAlarm();
} else if (result.getTitle().equals("smoke")) { } else if (result.getTitle().equals("smoke")) {
; makeSmokingAlarm();
} else if (result.getTitle().equals("safety belt")) {
;
} }
} }
} }
} }
//改变Bitmap的大小使其适应tensorflow的模型
private Bitmap changeBitmapSize(Bitmap bitmap) { private Bitmap changeBitmapSize(Bitmap bitmap) {
int width = bitmap.getWidth(); int width = bitmap.getWidth();
int height = bitmap.getHeight(); int height = bitmap.getHeight();

@ -13,12 +13,6 @@ import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
/**
*
* @author
*
*/
public class SettingActivity extends Activity implements OnClickListener public class SettingActivity extends Activity implements OnClickListener
{ {

@ -69,7 +69,7 @@ public class SettingAlarmActivity extends BaseActivity implements
motionAlermView.setVisibility(View.GONE); motionAlermView.setVisibility(View.GONE);
} else { } else {
cbxMotionAlerm.setChecked(true); cbxMotionAlarm.setChecked(true);
motionAlermView.setVisibility(View.VISIBLE); motionAlermView.setVisibility(View.VISIBLE);
} }
tvSensitivity.setText(String.valueOf(alermBean tvSensitivity.setText(String.valueOf(alermBean
@ -89,7 +89,7 @@ public class SettingAlarmActivity extends BaseActivity implements
private TextView tvSensitivity = null; private TextView tvSensitivity = null;
private CheckBox cbxMotionAlerm = null; private CheckBox cbxMotionAlarm = null;
private AlermBean alermBean = null; private AlermBean alermBean = null;
private PopupWindow sensitivePopWindow = null; private PopupWindow sensitivePopWindow = null;
@ -142,7 +142,7 @@ public class SettingAlarmActivity extends BaseActivity implements
btnOk.setOnClickListener(this); btnOk.setOnClickListener(this);
btnCancel.setOnClickListener(this); btnCancel.setOnClickListener(this);
imgSensitiveDrop.setOnClickListener(this); imgSensitiveDrop.setOnClickListener(this);
cbxMotionAlerm.setOnCheckedChangeListener(this); cbxMotionAlarm.setOnCheckedChangeListener(this);
scrollView.setOnTouchListener(this); scrollView.setOnTouchListener(this);
progressDialog.setOnKeyListener(new OnKeyListener() { progressDialog.setOnKeyListener(new OnKeyListener() {
@Override @Override
@ -161,7 +161,7 @@ public class SettingAlarmActivity extends BaseActivity implements
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.alerm_ok: case R.id.alerm_ok:
setAlerm(); setAlarm();
break; break;
case R.id.alerm_cancel: case R.id.alerm_cancel:
finish(); finish();
@ -229,7 +229,7 @@ public class SettingAlarmActivity extends BaseActivity implements
} }
} }
private void setAlerm() { private void setAlarm() {
if (successFlag) { if (successFlag) {
Log.e("setAlerm", "setAlermTemp: " + alermBean.getAlarm_temp()); Log.e("setAlerm", "setAlermTemp: " + alermBean.getAlarm_temp());
NativeCaller.PPPPAlarmSetting(strDID, alermBean.getAlarm_audio(), NativeCaller.PPPPAlarmSetting(strDID, alermBean.getAlarm_audio(),
@ -264,7 +264,7 @@ public class SettingAlarmActivity extends BaseActivity implements
private void findView() { private void findView() {
cbxMotionAlerm = (CheckBox) findViewById(R.id.alerm_cbx_move_layout); cbxMotionAlarm = (CheckBox) findViewById(R.id.alerm_cbx_move_layout);
tvSensitivity = (TextView) findViewById(R.id.alerm_tv_sensitivity); tvSensitivity = (TextView) findViewById(R.id.alerm_tv_sensitivity);

@ -32,7 +32,7 @@ import android.widget.Toast;
public class SettingUserActivity extends Activity implements OnCheckedChangeListener, OnClickListener,UserInterface{ public class SettingUserActivity extends Activity implements OnCheckedChangeListener, OnClickListener,UserInterface{
private boolean successFlag=false; private boolean successFlag=false;
private int CAMERAPARAM=0xffffffff;//״̬ private int CAMERAPARAM=0xffffffff;
private final int TIMEOUT=3000; private final int TIMEOUT=3000;
private final int FAILED=0; private final int FAILED=0;
private final int SUCCESS=1; private final int SUCCESS=1;

@ -4,9 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.ipcamer.detect.R; import com.ipcamer.detect.R;
import android.content.Context; import android.content.Context;

@ -6,9 +6,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.ipcamer.detect.R; import com.ipcamer.detect.R;
import com.ipcamer.detect.R.drawable;
import com.ipcamer.detect.R.id;
import com.ipcamer.detect.R.layout;
import com.ipcamera.detect.utils.ContentCommon; import com.ipcamera.detect.utils.ContentCommon;
import android.content.Context; import android.content.Context;

@ -1,7 +1,6 @@
package com.ipcamera.detect.adapter; package com.ipcamera.detect.adapter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.ipcamer.detect.R; import com.ipcamer.detect.R;
@ -13,7 +12,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
public class SensorListAdapter extends BaseAdapter{ public class SensorListAdapter extends BaseAdapter{

@ -7,12 +7,10 @@ import java.util.Map;
import com.ipcamer.detect.R; import com.ipcamer.detect.R;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;

@ -3,10 +3,6 @@ package com.ipcamera.detect.adapter;
import java.util.ArrayList; import java.util.ArrayList;
import com.ipcamer.detect.R; import com.ipcamer.detect.R;
import com.ipcamer.detect.R.drawable;
import com.ipcamer.detect.R.id;
import com.ipcamer.detect.R.layout;
import com.ipcamer.detect.R.string;
import com.ipcamera.detect.bean.WifiScanBean; import com.ipcamera.detect.bean.WifiScanBean;
import android.content.Context; import android.content.Context;

@ -12,6 +12,5 @@ public class DefenseConstant {
public static String key_allAlarm="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"; public static String key_allAlarm="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
public static String key_allDisAlarm="000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; public static String key_allDisAlarm="000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
} }

@ -1,10 +1,5 @@
package com.ipcamera.detect.bean; package com.ipcamera.detect.bean;
/*
* vst on
* //
* //
*/
public class ErrorBean { public class ErrorBean {
private int errorCode; private int errorCode;
private String errorMsg; private String errorMsg;

@ -1,10 +1,5 @@
package com.ipcamera.detect.bean; package com.ipcamera.detect.bean;
/*
* vst on 2017/5/5 14:03
* //
* //
*/
public class JsonBean { public class JsonBean {
private int code; private int code;
private String json; private String json;

@ -1,10 +1,5 @@
package com.ipcamera.detect.bean; package com.ipcamera.detect.bean;
/*
* vst on 2017/10/30 17:22
* //
* //
*/
public class PushBindDeviceBean { public class PushBindDeviceBean {
private String uid; private String uid;
private String token; private String token;

@ -1,10 +1,5 @@
package com.ipcamera.detect.bean; package com.ipcamera.detect.bean;
/*
* vst on
* //
* //
*/
public class SetLanguageBean { public class SetLanguageBean {
private String uid; private String uid;
private String token; private String token;

@ -3,9 +3,6 @@ package com.ipcamera.detect.bean;
import java.io.Serializable; import java.io.Serializable;
public class SwitchBean implements Serializable{ public class SwitchBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String motion_record_plan_enable; //移动侦测录像计划 private String motion_record_plan_enable; //移动侦测录像计划
private String motion_push_plan_enable; //移动侦测推送计划 private String motion_push_plan_enable; //移动侦测推送计划

@ -3,9 +3,6 @@ package com.ipcamera.detect.bean;
import java.io.Serializable; import java.io.Serializable;
public class WifiScanBean implements Serializable { public class WifiScanBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String did; private String did;
private String ssid; private String ssid;

@ -4,11 +4,6 @@ package com.ipcamera.detect.net;
import com.ipcamera.detect.bean.ErrorBean; import com.ipcamera.detect.bean.ErrorBean;
import com.ipcamera.detect.bean.JsonBean; import com.ipcamera.detect.bean.JsonBean;
/*
* vst on 2017/9/28 18:21
* //
* //
*/
public abstract interface ApiCallBack { public abstract interface ApiCallBack {
void onFinish(JsonBean bean); void onFinish(JsonBean bean);
void onError(ErrorBean bean); void onError(ErrorBean bean);

@ -1,10 +1,5 @@
package com.ipcamera.detect.net; package com.ipcamera.detect.net;
/*
* vst on 2017/10/30 17:39
* //
* //
*/
public class HttpConstances { public class HttpConstances {
//public static final String BASE_SERVICE_URL = "https://api.eye4.cn"; //正式 http://push2.eye4.cn:3000/binding //public static final String BASE_SERVICE_URL = "https://api.eye4.cn"; //正式 http://push2.eye4.cn:3000/binding
public static final String BASE_SERVICE_URL="http://push2.eye4.cn:3000"; public static final String BASE_SERVICE_URL="http://push2.eye4.cn:3000";

@ -18,11 +18,6 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
/*
* vst on 2017/9/28 16:39
* //
* //
*/
public class HttpHelper { public class HttpHelper {
public static final String TAG = "OkHttpHelper"; public static final String TAG = "OkHttpHelper";
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");

@ -1,7 +1,5 @@
package com.ipcamera.detect.net; package com.ipcamera.detect.net;
import com.ipcamera.detect.bean.ErrorBean; import com.ipcamera.detect.bean.ErrorBean;
import com.ipcamera.detect.bean.JsonBean; import com.ipcamera.detect.bean.JsonBean;
import com.ipcamera.detect.utils.GsonUtils; import com.ipcamera.detect.utils.GsonUtils;
@ -10,12 +8,6 @@ import com.ipcamera.detect.utils.StringUtils;
import okhttp3.Request; import okhttp3.Request;
/*
* vst on 2017/9/28 17:37
* //
* //
*/
public class VcmApi { public class VcmApi {
private static VcmApi api; private static VcmApi api;

@ -55,7 +55,7 @@ public class VideoFramePool extends Thread {
if (frameData != null) { if (frameData != null) {
this.myRender.writeSample(frameData,mframeSize,mWidth,mHeight); this.myRender.writeSample(frameData,mframeSize,mWidth,mHeight);
} }
Log.e("pool","poolsize "+framePool.size() +"frameRate***"+frameRate); Log.e("pool","poolsize "+framePool.size() +"frameRate***"+frameRate);
try { try {
endDate = System.currentTimeMillis(); endDate = System.currentTimeMillis();
if (frameRate == 10) { if (frameRate == 10) {

@ -3,7 +3,7 @@
<string name="path">/sdcard/test0.mp4</string> <string name="path">/sdcard/test0.mp4</string>
<!-- 应用程序 --> <!-- 应用程序 -->
<string name="app_name">Driving reminder assistant</string> <string name="app_name">ReminderAssistant</string>
<string name="camera_user">username</string> <string name="camera_user">username</string>
<string name="version_code">version number</string> <string name="version_code">version number</string>
<string name="soft_name">software name</string> <string name="soft_name">software name</string>

@ -0,0 +1,29 @@
package com.ipcamera.detect.utils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class VuidUtilsTest {
@Before
public void setUp() throws Exception {
System.out.println("测试开始:");
}
@After
public void tearDown() throws Exception {
System.out.println("测试结束!");
}
@Test
public void isVuidTest(){
assertTrue(VuidUtils.isVuid("VSTK0914947LLBPL"));
assertFalse(VuidUtils.isVuid("VSTK091497LLBPL"));
assertFalse(VuidUtils.isVuid("VSTK09ss497LLBPL"));
assertFalse(VuidUtils.isVuid("VSTK0914975453"));
assertFalse(VuidUtils.isVuid("0914975453LLBPL"));
}
}
Loading…
Cancel
Save