Example #1
0
 protected override void OnDeleted()
 {
     if (webcambuffer != null && selectedCameraIndex != -1)
     {
         webcambuffer.UnregisterForImages(WebcamManager.GetCamera(selectedCameraIndex));
         ReleasePreviousBuffers();
         WebcamManager.ReleaseInactiveCameras();
         if (callbacksRegistered)
         {
             WebcamManager.UnregisterWebcamConnectionEvent(OnCameraConnected);
             WebcamManager.UnregisterWebcamRemovalEvent(OnCameraDisconnected);
             callbacksRegistered = false;
         }
     }
 }
Example #2
0
 protected override void OnDeleted()
 {
     if (motionDetector != null && selectedCameraIndex != -1)
     {
         motionDetector.MotionDetected -= WebCamMotionDetected;
         ReleasePreviousDetectors();
         WebcamManager.SetPropertyValueAuto(selectedCameraIndex, WebcamManager.CAMERA_PROPERTY.CAMERA_FOCUS);
         WebcamManager.SetPropertyValueAuto(selectedCameraIndex, WebcamManager.CAMERA_PROPERTY.CAMERA_ZOOM);
         WebcamManager.ReleaseInactiveCameras();
         if (callbacksRegistered)
         {
             WebcamManager.UnregisterWebcamConnectionEvent(OnCameraConnected);
             WebcamManager.UnregisterWebcamRemovalEvent(OnCameraDisconnected);
             callbacksRegistered = false;
         }
     }
 }
 public void Cleanup()
 {
     foreach (ImageViewer viewer in cameraPreviews)
     {
         for (int i = 0; i < viewer.ImageSource.SubscribedImagers.Count; i++)
         {
             viewer.ImageSource.UnregisterForImages(viewer.ImageSource.SubscribedImagers[i]);
         }
     }
     //foreach (ImageViewer viewer in mainView)
     //{
     //    for (int i = 0; i < viewer.ImageSource.SubscribedImagers.Count; i++)
     //        viewer.ImageSource.UnregisterForImages(viewer.ImageSource.SubscribedImagers[i]);
     //}
     WebcamManager.ReleaseInactiveCameras();
     WebcamManager.UnregisterWebcamConnectionEvent(OnCameraConnected);
     WebcamManager.UnregisterWebcamRemovalEvent(OnCameraDisconnected);
 }
Example #4
0
        //[MethodImpl(MethodImplOptions.Synchronized)]
        protected override void OnDisabled(DisabledEventArgs e)
        {
            if (!e.IsConfiguring)
            {
                if (faceDetector != null && selectedCameraIndex != -1)
                {
                    faceDetector.FaceDetected -= WebCamFaceDetected;
                    faceDetector.UnregisterForImages(WebcamManager.GetCamera(selectedCameraIndex));
                    ReleasePreviousDetectors();

                    WebcamManager.SetPropertyValueAuto(selectedCameraIndex, WebcamManager.CAMERA_PROPERTY.CAMERA_FOCUS);
                    WebcamManager.SetPropertyValueAuto(selectedCameraIndex, WebcamManager.CAMERA_PROPERTY.CAMERA_ZOOM);
                    WebcamManager.ReleaseInactiveCameras();
                    if (callbacksRegistered)
                    {
                        WebcamManager.UnregisterWebcamConnectionEvent(OnCameraConnected);
                        WebcamManager.UnregisterWebcamRemovalEvent(OnCameraDisconnected);
                        callbacksRegistered = false;
                    }
                }
            }
        }