Пример #1
0
        void InitializeFaceDetection(int cameraindex)
        {
            Thread thread = new Thread(() =>
            {
                try
                {
                    ReleasePreviousDetectors();
                    WebcamManager.SetPropertyValueManual(cameraindex, WebcamManager.CAMERA_PROPERTY.CAMERA_FOCUS, camerafocus);
                    WebcamManager.SetPropertyValueManual(cameraindex, WebcamManager.CAMERA_PROPERTY.CAMERA_ZOOM, camerazoom);

                    faceDetector = new WebCamFaceDetector();
                    faceDetector.ToggleVisualization();
                    faceDetector.RegisterForImages(WebcamManager.GetCamera(cameraindex));
                    faceDetector.SelectedCameraIndex = cameraindex;
                    faceDetector.RoiX          = roiX;
                    faceDetector.RoiY          = roiY;
                    faceDetector.RoiWidth      = roiWidth;
                    faceDetector.RoiHeight     = roiHeight;
                    faceDetector.FaceDetected += WebCamFaceDetected;
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.ToString());
                }
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
Пример #2
0
 public void OnCameraConnected(object sender, USBEvent e)
 {
     if (!selectedCameraConnected)
     {
         Thread.Sleep(50);
         WebcamManager.RestartService();
         selectedCameraIndex = LookforSelectedCamera();
         if (selectedCameraIndex != -1)
         {
             Logger.WriteLine("Selected camera reconnected");
             ErrorLog.AddError(ErrorType.Message, "Selected camera has been reconnected");
             faceDetector.RegisterForImages(WebcamManager.GetCamera(selectedCameraIndex));
             WebcamManager.ReleaseInactiveCameras();
         }
     }
 }