Пример #1
0
        internal void Close()
        {
            // NOTE: Stop gesture recognition, if the host application is not running.
            if (Settings != null)
            {
                Settings.IsToDetectFacesOnDevice.Value = false;
                // NOTE: If the firmware version is larger than 1.1, stopping hand detection changes the LED color from blue to red.
                Settings.IsToDetectHandsOnDevice.Value = false;
            }
            if (FaceDetectionOnHost != null)
            {
                FaceDetectionOnHost.Dispose(); FaceDetectionOnHost = null;
            }

            // static event
            Microsoft.Win32.SystemEvents.DisplaySettingsChanged -= EgsGestureHidReport.OnDisplaySettingsChanged;
            if (CameraViewImageSourceBitmapCapture != null)
            {
                CameraViewImageSourceBitmapCapture.DisposeWithClearingVideoCaptureDeviceInformationOnDeviceDisconnected();
                // TODO: FIX: The next line can cause exception, in the other threads or in getting images with a Timer.
                CameraViewImageSourceBitmapCapture = null;
            }
            if (HidReportsUpdate != null)
            {
                HidReportsUpdate.OnDisable();
                HidReportsUpdate = null;
            }
        }
Пример #2
0
        internal void StopFaceDetectionAndRestartUvcAndRestartFaceDetection()
        {
            bool isToDetectFacesPrevious = Settings.IsToDetectFaces.Value;

            if (Settings.IsToDetectFaces.Value != false)
            {
                Settings.IsToDetectFaces.Value = false;
            }

            // NOTE: Wait completion of host face detection
            var sw = Stopwatch.StartNew();

            while (sw.ElapsedMilliseconds < FaceDetectionOnHost.DetectFaceIntervalMillisecondsMinimum.Value * 2 && FaceDetectionOnHost.IsDetecting)
            {
                System.Threading.Thread.Sleep(100);
            }
            ResetHidReportObjects();

            if (CameraViewImageSourceBitmapCapture.IsCameraDeviceConnected)
            {
                CameraViewImageSourceBitmapCapture.SetupCameraDevice();
            }
            // NOTE: Maybe necessary!
            System.Threading.Thread.Sleep(1000);

            if (Settings.IsToDetectFaces.Value != isToDetectFacesPrevious)
            {
                Settings.IsToDetectFaces.Value = isToDetectFacesPrevious;
            }
        }
Пример #3
0
 /// <summary>
 /// This method should be called only from EgsDevicesManager.  This updates only connection state of "Camera".
 /// </summary>
 internal void SetIsCameraDeviceConnectedToFalse()
 {
     Debug.WriteLine("[EgsDevice] TrySetIsConnectedToFalse() called.  DateTime.Now = " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff", CultureInfo.InvariantCulture));
     // This also updates CameraViewImageSourceBitmapCapture.IsCameraDeviceConnected
     if (CameraViewImageSourceBitmapCapture.IsCameraDeviceConnected)
     {
         CameraViewImageSourceBitmapCapture.DisposeWithClearingVideoCaptureDeviceInformationOnDeviceDisconnected();
     }
     CameraViewImageSourceBitmapCapture.UpdateIsUpdatingImageSource();
     ResetHidReportObjects();
 }
Пример #4
0
        internal void InitializeOnceAtStartup()
        {
            if (HidReportsUpdate != null)
            {
                HidReportsUpdate.InitializeOnceAtStartup(this);
            }
            TouchScreenHidReport.InitializeOnceAtStartup(this);
            EgsGestureHidReport.InitializeOnceAtStartup(this);

            AddPropertiesToHidAccessPropertyList();
            InitializePropertiesByDefaultValue();

            TemperatureInCelsius.ValueUpdated    += delegate { OnPropertyChanged(nameof(TemperatureInCelsiusString)); };
            TemperatureInFahrenheit.ValueUpdated += delegate { OnPropertyChanged(nameof(TemperatureInFahrenheitString)); };

            CameraViewImageSourceBitmapCapture.InitializeOnceAtStartup(this);
            FaceDetectionOnHost.InitializeOnceAtStartup(this);
            // static event
            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += EgsGestureHidReport.OnDisplaySettingsChanged;
        }
Пример #5
0
        /// <summary>
        /// This method should be called only from EgsDevicesManager.  This updates only connection state of "Camera".
        /// </summary>
        internal void TrySetIsCameraDeviceConnectedToTrue()
        {
            Debug.WriteLine("[EgsDevice] TrySetIsCameraDeviceConnectedToTrue() called.  DateTime.Now = " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff", CultureInfo.InvariantCulture));

            // NOTE (en): We confirmed there is time lag, from setting "CameraViewImageSourceBitmapSize" to becoming that the app can get correct values related to the "CameraViewImageSourceBitmapSize".
            // NOTE (ja): PCの機種によっては??カメラの解像度設定から、表示領域の内部状態が更新されてHIDで取得できるようになるまで、タイムラグがあることを確認した!!
            System.Threading.Thread.Sleep(300);

            // The next line updates device.CameraViewImageSourceBitmapCapture.IsCameraDeviceConnected
            CameraViewImageSourceBitmapCapture.SetupCameraDevice();
            CameraViewImageSourceBitmapCapture.UpdateIsUpdatingImageSource();
            // MUSTDO: Check if the application works correctly or not, if the next block is activated.  Currently it works correctly.
            if (true)
            {
                System.Threading.Thread.Sleep(300);
                // NOTE: Just in case, I leave the code to get the value again.
                GetReadonlyHidAccessPropertyByGetHidFeatureReport(Settings.CaptureImageSize);
                System.Threading.Thread.Sleep(100);
                GetReadonlyHidAccessPropertyByGetHidFeatureReport(Settings.CameraViewImageSourceRectInCaptureImage);
                EgsGestureHidReport.UpdateImageSizeRelatedProperties();
            }
        }