示例#1
0
 public void stop()
 {
     if (imageReader != null)
     {
         imageReader.Close();
         closeCamera();
         stopBackgroundThread();
         imageReader = null;
     }
 }
        public override bool OnUnbind(Intent Intent)
        {
            Stop();

            Instance       = null;
            ServiceStarted = false;

            _imageReader?.Close();
            _imageReader = null;

            return(base.OnUnbind(Intent));
        }
示例#3
0
        /// <summary>
        /// 刷新虚拟显示
        /// </summary>
        private void StartVirtualDisplay()
        {
            _imageReader?.Close();
            _virtualDisplay?.Release();
            _mediaProjection?.Stop();

            _mediaProjection = _mediaProjectionManager.GetMediaProjection((int)Result.Ok, _intent);

            //屏幕宽高
            var screenHeight = ScreenMetrics.Instance.GetOrientationAwareScreenHeight();
            var screenWidth  = ScreenMetrics.Instance.GetOrientationAwareScreenWidth();

            InitVirtualDisplay(screenWidth, screenHeight, (int)ScreenMetrics.Instance.DeviceScreenDensity);
        }
示例#4
0
 // Closes the current {@link CameraDevice}.
 public void CloseCamera()
 {
     try
     {
         mCameraOpenCloseLock.Acquire();
         if (null != mCaptureSession)
         {
             mCaptureSession.Close();
             mCaptureSession = null;
         }
         if (null != mCameraDevice)
         {
             mCameraDevice.Close();
             mCameraDevice = null;
         }
         if (null != mImageReader)
         {
             mImageReader.Close();
             mImageReader = null;
         }
     }
     catch (InterruptedException e)
     {
         Crashes.TrackError(e);
         throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
     }
     finally
     {
         mCameraOpenCloseLock.Release();
         StopBackgroundThread();
     }
 }
示例#5
0
 public void CloseCamera()
 {
     try
     {
         CameraOpenCloseLock.Acquire();
         if (null != CaptureSession)
         {
             CaptureSession.Close();
             CaptureSession = null;
         }
         if (null != Device)
         {
             Device.Close();
             Device = null;
         }
         if (null != mImageReader)
         {
             mImageReader.Close();
             mImageReader = null;
         }
     }
     catch (InterruptedException e)
     {
         throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
     }
     finally
     {
         CameraOpenCloseLock.Release();
     }
 }
示例#6
0
 void CloseCamera()
 {
     try
     {
         if (null != captureSession)
         {
             captureSession.Close();
             captureSession = null;
         }
         if (null != cameraDevice)
         {
             cameraDevice.Close();
             cameraDevice = null;
         }
         if (null != imageReader)
         {
             imageReader.Close();
             imageReader = null;
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine($"{e.Message} {e.StackTrace}");
     }
 }
 /** Closes the current {@link CameraDevice}. */
 private void closeCamera()
 {
     try
     {
         cameraOpenCloseLock.Acquire();
         if (null != captureSession)
         {
             captureSession.Close();
             captureSession = null;
         }
         if (null != cameraDevice)
         {
             cameraDevice.Close();
             cameraDevice = null;
         }
         if (null != imageReader)
         {
             imageReader.Close();
             imageReader = null;
         }
     }
     catch (Java.Lang.InterruptedException e)
     {
         throw new Java.Lang.RuntimeException("Interrupted while trying to lock camera closing.", e);
     }
     finally
     {
         cameraOpenCloseLock.Release();
     }
 }
示例#8
0
 // Closes the current {@link CameraDevice}.
 private void CloseCamera()
 {
     try
     {
         mCameraOpenCloseLock.WaitOne();
         if (null != mCaptureSession)
         {
             mCaptureSession.Close();
             mCaptureSession = null;
         }
         if (null != mCameraDevice)
         {
             mCameraDevice.Close();
             mCameraDevice = null;
         }
         if (null != mImageReader)
         {
             mImageReader.Close();
             mImageReader = null;
         }
     }
     catch (InterruptedException e)
     {
         throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
     }
     finally
     {
         mCameraOpenCloseLock.Release();
     }
 }
        // Closes the current {@link CameraDevice}.
        protected void CloseCamera()
        {
            if (CaptureSession == null)
            {
                return;
            }

            try
            {
                CameraOpenCloseLock.Acquire();
                if (null != CaptureSession)
                {
                    try
                    {
                        CaptureSession.StopRepeating();
                        CaptureSession.AbortCaptures();
                    }
                    catch (CameraAccessException ex)
                    {
#if DEBUG
                        ex.PrintStackTrace();
#endif
                    }
                    catch (IllegalStateException ex)
                    {
#if DEBUG
                        ex.PrintStackTrace();
#endif
                    }

                    CaptureSession.Close();
                    CaptureSession = null;
                }

                if (null != CameraDevice)
                {
                    CameraDevice.Close();
                    CameraDevice = null;
                }

                if (null != _imageReader)
                {
                    _imageReader.Close();
                    _imageReader = null;
                }
            }
            catch (InterruptedException ex)
            {
                throw new RuntimeException("Interrupted while trying to lock camera closing.", ex);
            }
            finally
            {
                CameraOpenCloseLock.Release();
            }
        }
        // Closes the current {@link CameraDevice}.
        private void CloseCamera()
        {
            if (mCaptureSession == null)
            {
                return;
            }

            try
            {
                mCameraOpenCloseLock.Acquire();
                if (mCaptureSession != null)
                {
                    try
                    {
                        mCaptureSession.StopRepeating();
                        mCaptureSession.AbortCaptures();
                    }
                    catch (CameraAccessException e)
                    {
                        e.PrintStackTrace();
                    }
                    catch (IllegalStateException e)
                    {
                        e.PrintStackTrace();
                    }

                    mCaptureSession.Close();
                    mCaptureSession = null;
                }

                if (mCameraDevice != null)
                {
                    mCameraDevice.Close();
                    mCameraDevice = null;
                }

                if (mImageReader != null)
                {
                    mImageReader.Close();
                    mImageReader = null;
                }
            }
            catch (InterruptedException e)
            {
                throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
            }
            finally
            {
                mCameraOpenCloseLock.Release();
            }
        }
示例#11
0
        public void Dispose()
        {
            _convertedMat.Release();
            _colorCorrectedMat.Release();

            _convertedMat = _colorCorrectedMat = null;

            _lastestPattern?.Dispose();
            _lastestPattern = null;

            _readBitmap?.Recycle();
            _readBitmap = null;

            _virtualDisplay?.Release();
            _virtualDisplay = null;

            _imageReader?.Close();
            _imageReader = null;

            _mediaProjection?.Stop();
            _mediaProjection = null;
        }
示例#12
0
        // Undone: Call from Dispose()
        /// <inheritdoc />
        protected override async Task CloseCamera()
        {
            try
            {
                await CameraOpenCloseLock.WaitAsync().ConfigureAwait(false);

                await base.CloseCamera().ConfigureAwait(false);

                if (_imageReader != null)
                {
                    _imageReader.Close();
                    _imageReader = null;
                }
            }
            catch (InterruptedException e)
            {
                throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
            }
            finally
            {
                CameraOpenCloseLock.Release();
            }
        }
示例#13
0
 private void Stop()
 {
     _imageAvailableListener.ImageAvailable -= PreviewImageAvailable;
     _imageReader.Close();
 }