/// <summary> /// 释放资源。 /// </summary> public void Dispose() { if (!isInitialized) { return; } Close(); SpeechEnable = false; if (Frame != null) { Frame.Dispose(); Frame = null; } if (Face != null) { Face.Dispose(); Face = null; } if (FaceDic != null) { FaceDic.Clear(); FaceDic = null; } FaceDetectSDK.Exit();//关闭识别库 isInitialized = false; }
private void updateShotFace(FaceInfo f) { if (PicBoxShotFace != null) { Action d = () => { if (f == null) { PicBoxShotFace.Image = null; } else { if (FaceAutoUpdateOn) { PicBoxShotFace.Image = FaceRecgnize.DeepCopyBitmap((Bitmap)f.FaceShotBmp);//防止同时占用的异常,拷贝一份 } else { PicBoxShotFace.Image = f.FaceShotBmp; } } }; PicBoxShotFace.BeginInvoke(d); } }
public DataAccess(FaceRecgnize face, FaceDictionary fdic) { _Face = face; _FaceDic = fdic; DataSource = DataSrcType.FileSystem; //InitDB(); }
} //获取人脸数据数量 public FaceDictionary(FaceCamera camera, FaceRecgnize face /*, DataAccess data*/) : base() { _Camera = camera; _Face = face; //_Data = data; FaceCount = 0; _FaceNameDic = new Dictionary <int, string>(); }
/// <summary> /// 初始化函数。开始之前需要先初始化。 /// </summary> /// <returns></returns> public bool Init() { if (isInitialized) { Console.WriteLine("Init: Camera is already initialized!"); return(false); } //初始化变量 PicBoxRealTime = null; PicBoxShotFace = null; PicBoxShotFullView = null; PicBoxFoundPic = null; isStarted = false; FaceAutoUpdateOn = false; _LastFacePos = new Dictionary <int, Rectangle>(); //初始化人脸识别库 int init = FaceDetectSDK.Init(1);//0:VGA; 1:FHD if (init < 0) { Console.WriteLine("Init: FaceDetectSDK Init Failed!"); return(false); } //创建人脸识别对象 Face = new FaceRecgnize(); //创建图像帧对象 Frame = new Mat(); //配置人脸识别类参数 Face.DrawPenThickness = 3; Face.MinFaceWidth = 20; FaceCmd = FaceCommand.None; Face.ShotFaceHandler += onShotFaceHander; Face.RemoveFaceHandler += onRemoveFaceHander; //创建人脸字典 FaceDic = new FaceDictionary(this, Face); Data = new DataAccess(Face, FaceDic); Data.DataSource = DataAccess.DataSrcType.FileSystem; isInitialized = true; return(true); }