diff --git a/doc/驾驶员危险驾驶行为监测系统-汇报PPT.pptx b/doc/驾驶员危险驾驶行为监测系统-汇报PPT.pptx index 1c15e98..52a578e 100644 Binary files a/doc/驾驶员危险驾驶行为监测系统-汇报PPT.pptx and b/doc/驾驶员危险驾驶行为监测系统-汇报PPT.pptx differ diff --git a/doc/驾驶员危险驾驶行为监测系统-软件系统的需求构思及描述.docx b/doc/驾驶员危险驾驶行为监测系统-软件系统的需求构思及描述.docx index 8995646..2ea9fcd 100644 Binary files a/doc/驾驶员危险驾驶行为监测系统-软件系统的需求构思及描述.docx and b/doc/驾驶员危险驾驶行为监测系统-软件系统的需求构思及描述.docx differ diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/AddCameraActivity.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/AddCameraActivity.java index f00bdfa..3648caa 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/AddCameraActivity.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/AddCameraActivity.java @@ -54,7 +54,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa private EditText pwdEdit = null; private EditText didEdit = null; private TextView textView_top_show = null; - private Button done; + private Button button_conn; private static final int SEARCH_TIME = 3000; private int option = ContentCommon.INVALID_OPTION; private int CameraType = ContentCommon.CAMERA_TYPE_MJPEG; @@ -134,7 +134,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa Thread.sleep(100); } catch (Exception e) { } - + if(SystemValue.deviceId.toLowerCase().startsWith("vsta")) { NativeCaller.StartPPPPExt(SystemValue.deviceId, SystemValue.deviceName, @@ -278,7 +278,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa } private void InitParams() { - done.setOnClickListener(this); + button_conn.setOnClickListener(this); btnSearchCamera.setOnClickListener(this); //监听软键盘的删除键 userEdit.setOnKeyListener(new View.OnKeyListener() { @@ -329,7 +329,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa } progressdlg.dismiss(); NativeCaller.StopSearch(); - + } @Override @@ -353,7 +353,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa updateListHandler.sendMessage(msg); } }; - + Handler updateListHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -403,7 +403,7 @@ public class AddCameraActivity extends Activity implements OnClickListener,AddCa Toast.makeText(AddCameraActivity.this, getResources().getString(R.string.add_search_no), 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); button_play = (Button) findViewById(R.id.play); button_setting = (Button) findViewById(R.id.setting); - done = (Button) findViewById(R.id.done); + button_conn = (Button) findViewById(R.id.done); //done.setText("连接"); 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(";"); for (int i = 0; i < strs.length; i++) { String str1 = strs[i].trim(); diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/BridgeService.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/BridgeService.java index b1a75f1..3d8cd89 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/BridgeService.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/BridgeService.java @@ -207,7 +207,7 @@ public class BridgeService extends Service break; case ContentCommon.MSG_TYPE_SET_ALARM: if (alarmInterface != null) { - // Log.d(TAG,"user result:"+result+" paramType:"+paramType); + Log.d(TAG,"user result:"+result+" paramType:"+paramType); alarmInterface.callBackSetSystemParamsResult(did, paramType,result); } break; @@ -1313,7 +1313,6 @@ public class BridgeService extends Service // 联动摄像机取消报警 if (sensoraction == ContentCommon.SENSOR_ALARM_ACTION_CANCELALARM) { - } 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, 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) { } - //add end public void CallBack_LowpowerDevMag(String did,int nState) { } - //start vuid /** 搜索回调(只有sdk版本0x1240以上的就用这个收到搜索通知,低于那版本使用SearchResult收取) @param sysVer: 设备固件版本 @@ -1415,7 +1412,6 @@ public class BridgeService extends Service } - //start vuid by dunn 2019-10-22 /** StartVUID连接时状态 @param did: UID diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/PlayActivity.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/PlayActivity.java index b62a68d..ef1cb2e 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/PlayActivity.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/PlayActivity.java @@ -123,7 +123,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL private static final String HANDLE_THREAD_NAME = "cameraBackground"; /**定时处理检测消息的Handler和timer*/ - protected Handler timeHandler; + private Handler timeHandler; Timer timer4Fatigue = null; Timer timer4Nod = 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 int AUDIO_BUFFER_START_CODE = 0xff00ff; - //surfaceView控键 + /**surfaceView控键*/ private GLSurfaceView playSurface = null; - //GLSurfaceView的渲染器 + /**GLSurfaceView的渲染器*/ private MyRender myRender; /** * videodata:视频流数据 @@ -284,9 +284,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL private boolean bInitCameraParam = false; private boolean bManualExit = false; - private TextView textosd = null; - private String strName = null; - private String strDID = null; + private TextView textosd = null;//顶部textView,显示用户名的 + private String strName = null;//用户名 + private String strDID = null;//设备id private View osdView = null; private boolean bDisplayFinished = true; private CustomBuffer AudioBuffer = null; @@ -298,10 +298,10 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL private ImageView videoViewStandard; //底部控件声明 private HorizontalScrollView bottomView; + //下面是一系列功能按钮 private ImageButton ptzAudio, ptztalk, ptzDefaultSet, ptzBrightness, ptzContrast, ptzTake_photos, ptzTake_vodeo, ptzResolutoin, preset; private int nStreamCodecType;//分辨率格式 - private PopupWindow controlWindow;//设备方向控制提示控件 private PopupWindow mPopupWindowProgress;//进度条控件 private PopupWindow presetBitWindow;//预置位面板 @@ -358,7 +358,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL private int picNum = 0;//拍照张数标识 /** * @Description 弹出退出确定的对话框 - * @Throws: + * @Throws:空指针错误 * NullPointerException dialog分配内存失败 */ public void showSureDialog() { @@ -385,6 +385,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL builder.show(); } + /**设置灯与警笛的视图(改软件系统的摄像头无法配置)*/ @SuppressLint("HandlerLeak") private Handler deviceParamsHandler = new Handler() { public void handleMessage(Message msg) { @@ -432,6 +433,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL int disPlaywidth; private Bitmap mBmp; + //传输视频流回调的Handler @SuppressLint("HandlerLeak") private Handler mHandler = new Handler() { public void handleMessage(Message msg) { @@ -651,7 +653,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL private Handler msgHandler = new Handler() { public void handleMessage(Message msg) { if (msg.what == 1) { - //Log.d("tag", "断线了"); + Log.d("tag", "断线了"); Toast.makeText(getApplicationContext(), R.string.pppp_status_disconnect, Toast.LENGTH_SHORT) .show(); @@ -662,10 +664,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL //视频流帧池,存储视频流,保证以一个稳定的帧数输出 private VideoFramePool framePool; - /** - * - * @param savedInstanceState - */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -675,7 +673,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.play); - //mine + //设置音频播放器 onCompletionListener = new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { @@ -690,9 +688,10 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL alarmPlayer.start(); isAlarming = true; showToast(R.string.initing); + //脸部框图初始化 mFaceRect = new DrawCaptureRect(getApplicationContext(), 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)); try { classifier = TensorFlowObjectDetectionAPIModel.create( @@ -730,7 +729,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL showBottom(); - //灯与警笛 + //灯与警笛(改软件系统的摄像头无法配置) if (SystemValue.supportLightAndSirenO13AndO10(MySharedPreferenceUtil.getSystemVer(this, strDID))) { getLightAndSirenStatte(strDID, SystemValue.devicePass); lightBtn.setVisibility(View.VISIBLE); @@ -790,6 +789,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL NativeCaller.PPPPCameraControl(strDID, 16, Resolution); } + /** + * 配置视图,绑定其控件 + */ private void findView() { //方向控制提示框 initControlDailog(); @@ -857,7 +859,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL @Override public boolean onTouch(View v, MotionEvent event) { - if (!isDown) { x1 = event.getX(); y1 = event.getY(); @@ -871,7 +872,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL originalScale = getScale(); break; case MotionEvent.ACTION_POINTER_UP: - break; case MotionEvent.ACTION_UP: 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 savedMatrix = new Matrix(); private PointF start = new PointF(); - private PointF mid = new PointF(); - float mMaxZoom = 2.0f; - float mMinZoom = 0.3125f; float originalScale; - float baseValue; protected Matrix mBaseMatrix = new Matrix(); protected Matrix mSuppMatrix = new Matrix(); private Matrix mDisplayMatrix = new Matrix(); 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) { return getValue(matrix, Matrix.MSCALE_X); } @@ -959,30 +933,13 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL 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 public boolean onDown(MotionEvent e) { Log.d("tag", "onDown"); - return false; } - private final int MINLEN = 80;//最小间距 + private final int MINLEN = 80;//滑动的最小间距 private Animation showTopAnim; private Animation dismissTopAnim; private boolean isPTZPrompt; @@ -1033,7 +990,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL @Override public void onShowPress(MotionEvent e) { - } @Override @@ -1041,22 +997,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL 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 public void onClick(View v) { switch (v.getId()) { @@ -1276,9 +1217,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } } - - /* - *异步控制方向 + /** + *异步控制摄像头朝向 */ private class ControlDeviceTask extends AsyncTask { private int type; @@ -1354,7 +1294,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL isControlDevice = false; if (controlWindow != null && controlWindow.isShowing()) controlWindow.dismiss(); - //mine + //每次摄像头朝向改变,需要重新开启定时器,重新初始化 stopBackgroundThread(); reInitPosition(); makeInitAlarm(3); @@ -1362,7 +1302,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } } - + /** + * 关闭已经启动的定时器 + */ private void reInitPosition() { initPosition = true; fail2Init = false; @@ -1978,7 +1920,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL public static Map> reslutionlist = new HashMap>(); /** - * 增加reslution + * 增加reslution 在之前的视频流回调的Handler处调用 */ private void addReslution(String mess, boolean isfast) { if (reslutionlist.size() != 0) { @@ -2014,7 +1956,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } } - /* + /** * @param type * 亮度饱和对比度 */ @@ -2076,16 +2018,18 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL @Override protected synchronized void onDestroy() { - NativeCaller.StopPPPPLivestream(strDID); - StopAudio(); - StopTalk(); - stopTakevideo(); - //mine - releaseAll(); - classifier.close(); + NativeCaller.StopPPPPLivestream(strDID);//提示摄像头停止传输视频流 + StopAudio();//停止播放音频 + StopTalk();//停止对讲 + stopTakevideo();//停止录像 + releaseAll();//释放定时器和tenginekit面部检测模型 + classifier.close();//关闭tensorflow的分类器模型 super.onDestroy(); } + /** + * 释放定时器和tenginekit面部检测模型 + */ public void releaseAll() { timeHandler.removeMessages(INIT_MSG); timeHandler.removeMessages(FATIGUE_MSG); @@ -2111,8 +2055,11 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } /*** - * BridgeService callback 视频参数回调 - * + * BridgeService callback 相机参数回调 + * @Param did:摄像机id + * @Param brightness:亮度 + * @Param constrat:对比度 + * @Param flip:是否开启了警报和灯(该软件系统对应摄像头无法使用) * **/ @Override public void callBackCameraParamNotify(String did, int resolution, @@ -2127,12 +2074,11 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL /** * 视频流回调,并开启人脸检测 - * - * @param videobuf - * @param h264Data - * @param len - * @param width - * @param height + * @param videobuf 视频流数据 + * @param h264Data 是否为h264格式的数据 + * @param len 数据长度 + * @param width 视频流宽度 + * @param height 视频流高度 */ @Override 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; try { if (mNV21Bytes == null) { - Init(); + Init();//初始化tengineKit } } catch (final Exception e) { Log.e(LOG_TAG, "callBackVideoData: " + e); @@ -2155,7 +2101,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL mNV21Bytes = videobuf; } }; - processImage(); + processImage();//调用检测函数 //mine bDisplayFinished = false; videodata = videobuf; @@ -2270,7 +2216,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL judgeEyesClose(faceAttr); judgeYawn(faceAttr); judgeNod(faceAttr); - judgeNotice(faceIrisInfo.get(0), faceAttr); + judgeAttention(faceIrisInfo.get(0), faceAttr); } } else { if (notDetectFrame >= 50) { @@ -2294,7 +2240,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL mFaceRect.invalidate(); } } - + //初始化人脸检测的有关参数 private void initParams() { totalFrameNumber = 0; twiceTimes = 2; @@ -2317,9 +2263,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } /** - * 初始化头部姿态 - * - * @param faceAttr + * 初始化头部姿态,记录这段时间内的信息和,后求平均值 + * @param faceAttr:人脸信息 */ private void initHeadPosition(FaceLandmarkInfo faceAttr) { 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) { if (initPosition) return; @@ -2347,8 +2291,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL /** * 获取一分钟打哈欠的个数 - * - * @param faceAttr + * @param faceAttr:人脸信息 */ private void judgeYawn(FaceLandmarkInfo faceAttr) { if (initPosition) return; @@ -2402,8 +2345,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL /** * 初始化头部姿态以及判定点头 - * - * @param faceAttr + * @param faceAttr:人脸信息 */ private void judgeNod(FaceLandmarkInfo faceAttr) { 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 (isEyesClose) { loseNoticeFrame = 0; @@ -2429,7 +2371,6 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL TenginekitPoint leftCorner = faceIrisInfo.leftEye.eyeLandmark.get(8); TenginekitPoint leftOuterCorner = faceIrisInfo.leftEye.eyeLandmark.get(0); 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) { loseNoticeFrame = loseNoticeFrame + 1; } else { @@ -2441,7 +2382,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } } - //发出初始化提示 + //发出初始化提示警报 public void makeInitAlarm(int flag) { if (isAlarming) return; if (alarmPlayer != null) { @@ -2476,7 +2417,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL break; } } - + //发出未检测到人的警报 public void makenotDetectFrameAlarm() { if (isAlarming || initPosition) return; if (alarmPlayer != null) { @@ -2564,7 +2505,28 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL alarmPlayer.start(); 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() { totalFrameNumber = 0; @@ -2580,7 +2542,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL @Override public synchronized void onResume() { super.onResume(); - handleTimeMsg(); + handleTimeMsg();//开启定时器 } @Override @@ -2588,7 +2550,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL stopBackgroundThread(); super.onPause(); } - + //定时处理监控信息,判定疲劳和偏头行为 public void handleTimeMsg() { timeHandler = new Handler(new Handler.Callback() { @Override @@ -2689,8 +2651,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL * **/ @Override public void callBackMessageNotify(String did, int msgType, int param) { - Log.d("tag", "MessageNotify did: " + did + " msgType: " + msgType - + " param: " + param); + /*Log.d("tag", "MessageNotify did: " + did + " msgType: " + msgType + + " param: " + param);*/ if (bManualExit) return; @@ -2772,11 +2734,9 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL } /** - * r * 获取警笛和白光状态 - * - * @param did - * @param pwd + * @param did:设备id + * @param 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); @@ -2804,6 +2764,8 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL */ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) private void stopBackgroundThread() { + if(backgroundHandler == null) + return ; backgroundThread.quitSafely(); try { backgroundThread.join(); @@ -2834,7 +2796,7 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL }; /** - * tensorFlow识别 + * tensorFlow识别,判定使用手机和吸烟 */ private void classifyFrame() { if (classifier == null || initPosition || videodata == null) { @@ -2852,15 +2814,14 @@ public class PlayActivity extends Activity implements OnTouchListener,OnGestureL final RectF location = result.getLocation(); if (location != null && result.getConfidence() >= MINIMUM_CONFIDENCE_TF_OD_API) { if (result.getTitle().equals("phone")) { - ; + makePhoneAlarm(); } else if (result.getTitle().equals("smoke")) { - ; - } else if (result.getTitle().equals("safety belt")) { - ; + makeSmokingAlarm(); } } } } + //改变Bitmap的大小,使其适应tensorflow的模型 private Bitmap changeBitmapSize(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingActivity.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingActivity.java index 2aa1a82..b7bd436 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingActivity.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingActivity.java @@ -13,12 +13,6 @@ import android.view.WindowManager; import android.widget.Button; import android.widget.RelativeLayout; - -/** - * - * @author - * 设备系统设置 - */ public class SettingActivity extends Activity implements OnClickListener { diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingAlarmActivity.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingAlarmActivity.java index 7ed32d3..62deeec 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingAlarmActivity.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingAlarmActivity.java @@ -69,7 +69,7 @@ public class SettingAlarmActivity extends BaseActivity implements motionAlermView.setVisibility(View.GONE); } else { - cbxMotionAlerm.setChecked(true); + cbxMotionAlarm.setChecked(true); motionAlermView.setVisibility(View.VISIBLE); } tvSensitivity.setText(String.valueOf(alermBean @@ -89,7 +89,7 @@ public class SettingAlarmActivity extends BaseActivity implements private TextView tvSensitivity = null; - private CheckBox cbxMotionAlerm = null; + private CheckBox cbxMotionAlarm = null; private AlermBean alermBean = null; private PopupWindow sensitivePopWindow = null; @@ -142,7 +142,7 @@ public class SettingAlarmActivity extends BaseActivity implements btnOk.setOnClickListener(this); btnCancel.setOnClickListener(this); imgSensitiveDrop.setOnClickListener(this); - cbxMotionAlerm.setOnCheckedChangeListener(this); + cbxMotionAlarm.setOnCheckedChangeListener(this); scrollView.setOnTouchListener(this); progressDialog.setOnKeyListener(new OnKeyListener() { @Override @@ -161,7 +161,7 @@ public class SettingAlarmActivity extends BaseActivity implements public void onClick(View v) { switch (v.getId()) { case R.id.alerm_ok: - setAlerm(); + setAlarm(); break; case R.id.alerm_cancel: finish(); @@ -229,7 +229,7 @@ public class SettingAlarmActivity extends BaseActivity implements } } - private void setAlerm() { + private void setAlarm() { if (successFlag) { Log.e("setAlerm", "setAlermTemp: " + alermBean.getAlarm_temp()); NativeCaller.PPPPAlarmSetting(strDID, alermBean.getAlarm_audio(), @@ -264,7 +264,7 @@ public class SettingAlarmActivity extends BaseActivity implements 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); diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingUserActivity.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingUserActivity.java index 203817c..671901b 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingUserActivity.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/SettingUserActivity.java @@ -32,7 +32,7 @@ import android.widget.Toast; public class SettingUserActivity extends Activity implements OnCheckedChangeListener, OnClickListener,UserInterface{ private boolean successFlag=false; - private int CAMERAPARAM=0xffffffff;//״̬ + private int CAMERAPARAM=0xffffffff; private final int TIMEOUT=3000; private final int FAILED=0; private final int SUCCESS=1; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/MoveVideoTimingAdapter.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/MoveVideoTimingAdapter.java index 1001f25..5912696 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/MoveVideoTimingAdapter.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/MoveVideoTimingAdapter.java @@ -4,9 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; - - - import com.ipcamer.detect.R; import android.content.Context; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SearchListAdapter.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SearchListAdapter.java index bf02019..6d7329c 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SearchListAdapter.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SearchListAdapter.java @@ -6,9 +6,6 @@ import java.util.List; import java.util.Map; 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 android.content.Context; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SensorListAdapter.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SensorListAdapter.java index 953da55..adbe2a7 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SensorListAdapter.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/SensorListAdapter.java @@ -1,7 +1,6 @@ package com.ipcamera.detect.adapter; import java.util.ArrayList; -import java.util.HashMap; import java.util.Map; import com.ipcamer.detect.R; @@ -13,7 +12,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; public class SensorListAdapter extends BaseAdapter{ diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/VideoTimingAdapter.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/VideoTimingAdapter.java index 4ffdad2..71adc6a 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/VideoTimingAdapter.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/VideoTimingAdapter.java @@ -7,12 +7,10 @@ import java.util.Map; import com.ipcamer.detect.R; import android.content.Context; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; -import android.widget.ImageView; import android.widget.TextView; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/WifiScanListAdapter.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/WifiScanListAdapter.java index 5d1e52e..d84e0cb 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/WifiScanListAdapter.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/adapter/WifiScanListAdapter.java @@ -3,10 +3,6 @@ package com.ipcamera.detect.adapter; import java.util.ArrayList; 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 android.content.Context; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/DefenseConstant.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/DefenseConstant.java index ba7a60d..49cc0f5 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/DefenseConstant.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/DefenseConstant.java @@ -12,6 +12,5 @@ public class DefenseConstant { public static String key_allAlarm="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"; public static String key_allDisAlarm="000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - + } diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/ErrorBean.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/ErrorBean.java index 07769eb..5d423d1 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/ErrorBean.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/ErrorBean.java @@ -1,10 +1,5 @@ package com.ipcamera.detect.bean; -/* - * 编写:vst on - * // - * // - */ public class ErrorBean { private int errorCode; private String errorMsg; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/JsonBean.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/JsonBean.java index 2183b0c..c4fe2b8 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/JsonBean.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/JsonBean.java @@ -1,10 +1,5 @@ package com.ipcamera.detect.bean; -/* - * 编写:vst on 2017/5/5 14:03 - * // - * // - */ public class JsonBean { private int code; private String json; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/PushBindDeviceBean.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/PushBindDeviceBean.java index fd4f909..6a0d2ce 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/PushBindDeviceBean.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/PushBindDeviceBean.java @@ -1,10 +1,5 @@ package com.ipcamera.detect.bean; -/* - * 编写:vst on 2017/10/30 17:22 - * // - * // - */ public class PushBindDeviceBean { private String uid; private String token; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SetLanguageBean.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SetLanguageBean.java index acbf119..bab957e 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SetLanguageBean.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SetLanguageBean.java @@ -1,10 +1,5 @@ package com.ipcamera.detect.bean; -/* - * 编写:vst on - * // - * // - */ public class SetLanguageBean { private String uid; private String token; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SwitchBean.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SwitchBean.java index 63f07f4..af34ed8 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SwitchBean.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/SwitchBean.java @@ -3,9 +3,6 @@ package com.ipcamera.detect.bean; import java.io.Serializable; public class SwitchBean implements Serializable{ - /** - * - */ private static final long serialVersionUID = 1L; private String motion_record_plan_enable; //移动侦测录像计划 private String motion_push_plan_enable; //移动侦测推送计划 diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/WifiScanBean.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/WifiScanBean.java index 06a5737..84b0493 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/WifiScanBean.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/bean/WifiScanBean.java @@ -3,9 +3,6 @@ package com.ipcamera.detect.bean; import java.io.Serializable; public class WifiScanBean implements Serializable { - /** - * - */ private static final long serialVersionUID = 1L; private String did; private String ssid; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/ApiCallBack.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/ApiCallBack.java index ed81bf8..5d641cf 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/ApiCallBack.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/ApiCallBack.java @@ -4,11 +4,6 @@ package com.ipcamera.detect.net; import com.ipcamera.detect.bean.ErrorBean; import com.ipcamera.detect.bean.JsonBean; -/* - * 编写:vst on 2017/9/28 18:21 - * // - * // - */ public abstract interface ApiCallBack { void onFinish(JsonBean bean); void onError(ErrorBean bean); diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpConstances.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpConstances.java index 73a99cb..b8d3a1d 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpConstances.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpConstances.java @@ -1,10 +1,5 @@ package com.ipcamera.detect.net; -/* - * 编写:vst on 2017/10/30 17:39 - * // - * // - */ 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="http://push2.eye4.cn:3000"; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpHelper.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpHelper.java index 0f0aca0..3c3ee21 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpHelper.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/HttpHelper.java @@ -18,11 +18,6 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -/* - * 编写:vst on 2017/9/28 16:39 - * // - * // - */ public class HttpHelper { public static final String TAG = "OkHttpHelper"; public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/VcmApi.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/VcmApi.java index 8d9cfe5..e0c20f3 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/VcmApi.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/net/VcmApi.java @@ -1,7 +1,5 @@ package com.ipcamera.detect.net; - - import com.ipcamera.detect.bean.ErrorBean; import com.ipcamera.detect.bean.JsonBean; import com.ipcamera.detect.utils.GsonUtils; @@ -10,12 +8,6 @@ import com.ipcamera.detect.utils.StringUtils; import okhttp3.Request; - -/* - * 编写:vst on 2017/9/28 17:37 - * // - * // - */ public class VcmApi { private static VcmApi api; diff --git a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/utils/VideoFramePool.java b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/utils/VideoFramePool.java index 907ddb2..3613954 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/utils/VideoFramePool.java +++ b/src/Driving_Reminder_Assistant/app/src/main/java/com/ipcamera/detect/utils/VideoFramePool.java @@ -55,7 +55,7 @@ public class VideoFramePool extends Thread { if (frameData != null) { this.myRender.writeSample(frameData,mframeSize,mWidth,mHeight); } - Log.e("pool","poolsize "+framePool.size() +"frameRate***"+frameRate); + Log.e("pool","poolsize "+framePool.size() +";frameRate***"+frameRate); try { endDate = System.currentTimeMillis(); if (frameRate == 10) { diff --git a/src/Driving_Reminder_Assistant/app/src/main/res/raw/phone.mp3 b/src/Driving_Reminder_Assistant/app/src/main/res/raw/phone.mp3 new file mode 100644 index 0000000..8a1039c Binary files /dev/null and b/src/Driving_Reminder_Assistant/app/src/main/res/raw/phone.mp3 differ diff --git a/src/Driving_Reminder_Assistant/app/src/main/res/raw/smoke.mp3 b/src/Driving_Reminder_Assistant/app/src/main/res/raw/smoke.mp3 new file mode 100644 index 0000000..fed2b60 Binary files /dev/null and b/src/Driving_Reminder_Assistant/app/src/main/res/raw/smoke.mp3 differ diff --git a/src/Driving_Reminder_Assistant/app/src/main/res/values/strings.xml b/src/Driving_Reminder_Assistant/app/src/main/res/values/strings.xml index 9b5f2be..764db90 100644 --- a/src/Driving_Reminder_Assistant/app/src/main/res/values/strings.xml +++ b/src/Driving_Reminder_Assistant/app/src/main/res/values/strings.xml @@ -3,7 +3,7 @@ /sdcard/test0.mp4 - Driving reminder assistant + ReminderAssistant username version number software name diff --git a/src/Driving_Reminder_Assistant/app/src/test/java/com/ipcamera/detect/utils/VuidUtilsTest.java b/src/Driving_Reminder_Assistant/app/src/test/java/com/ipcamera/detect/utils/VuidUtilsTest.java new file mode 100644 index 0000000..5f7fde2 --- /dev/null +++ b/src/Driving_Reminder_Assistant/app/src/test/java/com/ipcamera/detect/utils/VuidUtilsTest.java @@ -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")); + } +} \ No newline at end of file