|
|
|
@ -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<Void, Void, Integer> {
|
|
|
|
|
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<String, Map<Object, Object>> reslutionlist = new HashMap<String, Map<Object, Object>>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 增加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();
|
|
|
|
|