private void onRemoveFaceHander(FaceInfo f) { if (_LastFacePos.ContainsKey(f.faceid)) { _LastFacePos.Remove(f.faceid); } if (_FaceCmd == FaceCommand.None) { return; } if (f.faceid == _LastFaceID) { if (PicBoxShotFace != null) { Action d = () => { PicBoxShotFace.Image = null; }; PicBoxShotFace.Invoke(d); } if (PicBoxShotFullView != null) { Action d = () => { PicBoxShotFullView.Image = null; }; PicBoxShotFullView.Invoke(d); } if (PicBoxFoundPic != null) { Action d = () => { PicBoxFoundPic.Image = null; }; PicBoxFoundPic.Invoke(d); } } _LastFaceID = 0; FaceEvent e = new FaceEvent { type = FaceEvent.EventType.FaceRemoved, faceinfo = f, }; if (FaceHandler != null) { FaceHandler(e); } }
private void onNodShakeDetect(FaceInfo f) { try { _MaxPitchAngle = Math.Max(_MaxPitchAngle, f.pitchAngle); _MinPitchAngle = Math.Min(_MinPitchAngle, f.pitchAngle); _MaxYawAngle = Math.Max(_MaxYawAngle, f.yawAngle); _MinYawAngle = Math.Min(_MinYawAngle, f.yawAngle); if (_MaxPitchAngle - _MinPitchAngle > NOD_MIN_ANGLE && _MaxYawAngle - _MinYawAngle < NOD_SHAKE_MAX_ANGLE) { FaceEvent e = new FaceEvent { type = FaceEvent.EventType.HeadNodDetected, faceinfo = f, }; if (FaceHandler != null) { FaceHandler(e); } initNodShadeParams(); } else if (_MaxPitchAngle - _MinPitchAngle < NOD_SHAKE_MAX_ANGLE && _MaxYawAngle - _MinYawAngle > SHAKE_MIN_ANGLE) { FaceEvent e = new FaceEvent { type = FaceEvent.EventType.HeadShakeDetected, faceinfo = f, }; if (FaceHandler != null) { FaceHandler(e); } initNodShadeParams(); } else if (_MaxPitchAngle - _MinPitchAngle >= NOD_SHAKE_MAX_ANGLE && _MaxYawAngle - _MinYawAngle >= NOD_SHAKE_MAX_ANGLE) { _MaxPitchAngle = 0; _MinPitchAngle = 100; _MaxYawAngle = 0; _MinYawAngle = 100; } } catch (Exception ex) { Console.WriteLine("FaceCamera->nodShakeDetect:" + ex); } }
private void onFaceShotAndFindSame(FaceInfo f, FaceEvent.EventType t) { try { if (f == null) { return; } if (f.userid != 0) { return; } int score = 0, uid = 0; FaceData fd = null; _LastFaceID = f.faceid; //数据库检索 uid = FaceDic.FindSameFace(f, out score, out fd); if (uid != 0) { //更新抓拍全景照片 updateFullViewBmp(f); //更新抓拍特写照片 updateShotFace(f); //显示检索到的照片 updateFoundPic(f, fd); //在TracingList中标记相同人脸 f.text = score.ToString(); f.userid = uid; FaceEvent e = new FaceEvent { type = t, faceinfo = f, //userid = uid, //score = score }; if (FaceHandler != null) { FaceHandler(e); } } } catch (Exception ex) { Console.WriteLine("FaceCamera->shotFaceAndFind:" + ex); } }
private void onFaceCollect(FaceInfo f) { try { if (f.angleType == RequestAngleType) { FaceEvent e = new FaceEvent { type = FaceEvent.EventType.FaceCollected, faceinfo = f, }; if (FaceHandler != null) { FaceHandler(e); } } } catch (Exception ex) { Console.WriteLine("FaceCamera->faceCollect:" + ex); } }
private void onFaceShotAndFind(FaceInfo f, FaceEvent.EventType t) { try { bool isSame = false; if (f != null && f.userid == 0) { _LastFaceID = f.faceid; //更新抓拍全景照片 updateFullViewBmp(f); //更新抓拍特写照片 updateShotFace(f); //数据库检索并显示检索到的照片 int score = 0, uid = 0; FaceData fd = null; uid = FaceDic.FindMostSimilarFace(f, out score, out fd); //在TracingList中标记相同人脸 if (score >= Face.SameFaceThreshold) { f.userid = uid; isSame = true; //合并uid相同的人脸 FaceInfo mergeto; if (Face.MergeTracingList(f, out mergeto)) { //被合并后,需要删除 onRemoveFaceHander(f); return; } else { isSame = true; } } else { f.userid = 0; } f.text = score.ToString(); updateFoundPic(f, fd); } FaceEvent e = new FaceEvent { type = t, faceinfo = f, isFoundSame = isSame //userid = uid, //score = score }; if (SpeechEnable && isSame) { //进行语音播报 string text = FaceDic.GetUserName(f.userid); if (text.Trim().Length != 0) { text += ",你好。"; _Speech.SpeakAsync(text); } } //回调上层 if (FaceHandler != null) { FaceHandler(e); } } catch (Exception ex) { Console.WriteLine("FaceCamera->shotFaceAndFind:" + ex); } }