Пример #1
0
        private void OnCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            if (e.Succeeded)
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    this.phoneCamera.FlashMode = FlashMode.Auto;
                    this.phoneCamera.Focus();

                    this.previewBuffer = new WriteableBitmap((int)this.phoneCamera.PreviewResolution.Width, (int)this.phoneCamera.PreviewResolution.Height);
                    this.barcodeReader = new BarcodeReader();

                    // By default, BarcodeReader will scan every supported barcode type
                    // If we want to limit the type of barcodes our app can read,
                    // we can do it by adding each format to this list object

                    //var supportedBarcodeFormats = new List<BarcodeFormat>();
                    //supportedBarcodeFormats.Add(BarcodeFormat.QR_CODE);
                    //supportedBarcodeFormats.Add(BarcodeFormat.DATA_MATRIX);
                    //_bcReader.PossibleFormats = supportedBarcodeFormats;

                    this.barcodeReader.Options.TryHarder = true;

                    this.barcodeReader.ResultFound += this.OnBarcodeResultFound;
                    this.scanTimer.Start();
                });
            }
            else
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    this.BarcodeScannerPlugin.OnScanFailed("Unable to initialize the camera");
                });
            }
        }
Пример #2
0
 void _phoneCamera_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     if (e.Exception != null)
     {
         Debug.WriteLine("{0}", e.Exception.Message);
     }
 }
Пример #3
0
 private void camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
 {
     if (e.Succeeded)
     {
         cameraInitialized = true;
     }
 }
        private void cam_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            if (!e.Succeeded)
            {
                cam = null;
                return;
            }

            try
            {
                cam = (PhotoCamera)sender;
                cam.Resolution = cam.AvailableResolutions.First();
            }
            catch (Exception)
            {
                cam = null;
                return;
            }

            this.Dispatcher.BeginInvoke(delegate()
            {
                if (cam == null)
                    return;

                WriteableBitmap bitmap = new WriteableBitmap((int)cam.PreviewResolution.Width,
                                                             (int)cam.PreviewResolution.Height);
                frameStart = DateTime.Now;
                cam.GetPreviewBufferArgb32(bitmap.Pixels);
                detectFaces(bitmap);
            });
        }
Пример #5
0
        void Camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            try
            {
                if (e.Succeeded)
                {
                    this.Camera.FlashMode = FlashMode.Off;
                    var resx = this.Camera.AvailableResolutions;

                    this.Camera.Resolution = resx.ElementAt(0);
                }
                else
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show("Something Error with your camera");
                    });
                }
            }
            catch (Exception ex)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show("Something Error with your camera");
                });
            }
        }
Пример #6
0
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            MobileBarcodeScanner.Log("Initialized Camera");

            if (_photoCamera == null)
            {
                return;
            }

            MobileBarcodeScanner.Log("Creating Luminance Source");

            var width  = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
            var height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);

            _luminance = new PhotoCameraLuminanceSource(width, height);

            if (_photoCamera.IsFlashModeSupported(FlashMode.On))
            {
                _photoCamera.FlashMode = FlashMode.Off;
            }

            _initialized = true;

            MobileBarcodeScanner.Log("Luminance Source Created");

            OnCameraInitialized(_initialized);
        }
        private void CameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            if (e.Succeeded)
            {
                try
                {
                    // available resolutions are ordered based on number of pixels in each resolution
                    CameraWidth  = (int)Camera.PreviewResolution.Width;
                    CameraHeight = (int)Camera.PreviewResolution.Height;


                    if (CamInitialized != null)
                    {
                        CamInitialized.Invoke(this, e);
                    }

                    _cameraInitializedEvent.Set();
                    _pauseFramesEvent.Set();
                }
                catch (ObjectDisposedException)
                {
                    // If the camera was disposed, try initializing again
                }
            }
        }
Пример #8
0
		private void OnCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
		{
			if (e.Succeeded)
			{
				this.Dispatcher.BeginInvoke(() =>
				{
					this.phoneCamera.FlashMode = FlashMode.Auto;
					this.phoneCamera.Focus();

					this.previewBuffer = new WriteableBitmap((int)this.phoneCamera.PreviewResolution.Width, (int)this.phoneCamera.PreviewResolution.Height);
					this.barcodeReader = new BarcodeReader();

					// By default, BarcodeReader will scan every supported barcode type
					// If we want to limit the type of barcodes our app can read, 
					// we can do it by adding each format to this list object

					//var supportedBarcodeFormats = new List<BarcodeFormat>();
					//supportedBarcodeFormats.Add(BarcodeFormat.QR_CODE);
					//supportedBarcodeFormats.Add(BarcodeFormat.DATA_MATRIX);
					//_bcReader.PossibleFormats = supportedBarcodeFormats;

					this.barcodeReader.Options.TryHarder = true;

					this.barcodeReader.ResultFound += this.OnBarcodeResultFound;
					this.scanTimer.Start();
				});
			}
			else
			{
				this.Dispatcher.BeginInvoke(() =>
				{
					this.BarcodeScannerPlugin.OnScanFailed("Unable to initialize the camera");
				});
			}
		}
Пример #9
0
        /// <summary>
        /// Called when device camera initialized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="CameraOperationCompletedEventArgs"/> instance containing the event data.</param>
        private void CameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            if (e.Succeeded)
            {
                // Start scan process in separate thread
                Deployment.Current.Dispatcher.BeginInvoke(
                    () =>
                        {
                            while (result == null)
                            {
                                var cameraBuffer = new WriteableBitmap(
                                    (int)camera.PreviewResolution.Width,
                                    (int)camera.PreviewResolution.Height);

                                camera.GetPreviewBufferArgb32(cameraBuffer.Pixels);
                                cameraBuffer.Invalidate();

                                reader.Decode(cameraBuffer);
                            }
                        });
            }
            else
            {
                this.result = new BarcodeScannerTask.ScanResult(TaskResult.None);
                NavigationService.GoBack();
            }
        }
Пример #10
0
 void _phoneCamera_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     Deployment.Current.Dispatcher.BeginInvoke(delegate()
     {
         focusBrackets.Visibility = Visibility.Collapsed;
     });
 }
        private void Camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            int width  = Convert.ToInt32(Camera.PreviewResolution.Width);
            int height = Convert.ToInt32(Camera.PreviewResolution.Height);

            decoder.Init(width, height);
        }
Пример #12
0
        /// <summary>
        /// The camera object has been initialised.
        /// </summary>
        /// <param name="sender">
        /// The sender object is not used.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void CameraInitialised(object sender, CameraOperationCompletedEventArgs e)
        {
            if (e.Succeeded)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    this.camera.FlashMode = FlashMode.Off;
                    this.camera.Focus();

                    var pixelWidth     = (int)this.camera.PreviewResolution.Width;
                    var pixelHeight    = (int)this.camera.PreviewResolution.Height;
                    this.previewBuffer = new WriteableBitmap(pixelWidth, pixelHeight);

                    this.barcodeReader = new BarcodeReader();
                    this.barcodeReader.Options.TryHarder = true;
                    this.barcodeReader.ResultFound      += this.BarcodeReaderResultFound;

                    this.scanTimer.Start();
                });
            }
            else
            {
                Dispatcher.BeginInvoke(() =>
                {
                    this.ResolveWithError("Unable to initialize the camera");
                });
            }
        }
Пример #13
0
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            try
            {
                if (_photoCamera == null)
                {
                    return;
                }

                var width  = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
                var height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);

                _luminance = new PhotoCameraLuminanceSource(width, height);

                _photoCamera.FlashMode = FlashMode.Off;

                _initialized = true;

                OnCameraInitialized(_initialized);
            }
            catch
            {
                InitializeCamera(); //Re-Initialize Camera
            }
        }
        /// <summary>
        /// Called when device camera initialized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="CameraOperationCompletedEventArgs"/> instance containing the event data.</param>
        private void CameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            if (e.Succeeded)
            {
                // Start scan process in separate thread
                Deployment.Current.Dispatcher.BeginInvoke(
                    () =>
                {
                    while (result == null)
                    {
                        var cameraBuffer = new WriteableBitmap(
                            (int)camera.PreviewResolution.Width,
                            (int)camera.PreviewResolution.Height);

                        camera.GetPreviewBufferArgb32(cameraBuffer.Pixels);
                        cameraBuffer.Invalidate();

                        reader.Decode(cameraBuffer);
                    }
                });
            }
            else
            {
                this.result = new BarcodeScannerTask.ScanResult(TaskResult.None);
                NavigationService.GoBack();
            }
        }
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            MobileBarcodeScanner.Log("Initialized Camera");

            if (_photoCamera == null)
            {
                return;
            }

            MobileBarcodeScanner.Log("Creating Luminance Source");

            var width  = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
            var height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);

            _luminance = new PhotoCameraLuminanceSource(width, height);

            var supportedCameraModes = AudioVideoCaptureDevice.GetSupportedPropertyValues(_photoCamera.SensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode);

            if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
            {
                _photoCamera.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.Off);
            }

            _initialized = true;

            MobileBarcodeScanner.Log("Luminance Source Created");

            OnCameraInitialized(_initialized);
        }
Пример #16
0
 void _phoneCamera_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     Deployment.Current.Dispatcher.BeginInvoke(delegate()
     {
         focusBrackets.Visibility = Visibility.Collapsed;
     });
 }
Пример #17
0
 private void Camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
 {
     width     = Convert.ToInt32(Camera.PreviewResolution.Width);
     height    = Convert.ToInt32(Camera.PreviewResolution.Height);
     luminance = new PhotoCameraLuminanceSource(width, height);
     Camera.Focus();
 }
Пример #18
0
        void Camera_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
        {
            var luminance = new PhotoCameraLuminanceSource(this.CameraW, this.CameraH);

            this.Camera.GetPreviewBufferY(luminance.PreviewBufferY);
            luminance.Cutout((int)this.RR.Left, (int)this.RR.Top, (int)this.RR.Width, (int)this.RR.Height);
            var result = this.Reader.Decode(luminance);


            //this.Tip = result != null ? result.Text : DateTime.Now.ToString("不能识别 HH:mm:ss");
            if (result != null)
            {
                VibrateController.Default.Start(new TimeSpan(0, 0, 0, 0, 200));
                this.IsScanning        = false;
                this.ScanBtnVisibility = Visibility.Visible;
                this.Tip = result.Text;
                this.NotifyOfPropertyChange(() => this.Tip);
                this.NotifyOfPropertyChange(() => this.IsScanning);
                this.NotifyOfPropertyChange(() => this.ScanBtnVisibility);
            }
            else
            {
                this.SetFocus();
            }
        }
Пример #19
0
 /// <summary>
 /// The auto focus has completed event.
 /// </summary>
 /// <param name="sender">
 /// This parameter is ignored.
 /// </param>
 /// <param name="e">
 /// The event arguments.
 /// </param>
 private void CameraAutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     if (e.Succeeded && !this.barcodeFound)
     {
         // no barcode was found so lets try again
         this.camera.Focus();
     }
 }
Пример #20
0
 /// <summary>
 /// Called when the camera is initialized.
 /// </summary>
 private void Camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
 {
     Dispatcher.BeginInvoke(() =>
     {
         PreviewTransform.Rotation = _camera.Orientation;
         _timer.Start();
     });
 }
Пример #21
0
 void cam_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     Deployment.Current.Dispatcher.BeginInvoke(delegate()
     {
         // Write message to UI.
         txtDebug.Text = "Auto focus has completed.";
     });
 }
Пример #22
0
        private void PhotoCamera_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
        {
            var eventHandler = CaptureCompleted;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
 void camera_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     if (!e.Succeeded)
     {
         photoContainer.Fill = new SolidColorBrush(Colors.Gray);
         imageDetails.Text = "Camera capture failed.\n" + e.Exception.Message;
     }
     CleanUpCamera();
 }
Пример #24
0
 void _currentCamera_Initialized(object sender, CameraOperationCompletedEventArgs e)
 {
     Dispatcher.BeginInvoke(() =>
     {
         //Start the timer that should always be initialiazed before the camera
         //once the camera ready we start the timer
         ResumeScan();
     });
 }
 void camera_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     if (!e.Succeeded)
     {
         photoContainer.Fill = new SolidColorBrush(Colors.Gray);
         imageDetails.Text   = "Camera capture failed.\n" + e.Exception.Message;
     }
     CleanUpCamera();
 }
Пример #26
0
        /// <summary>
        /// Called when device camera initialized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="CameraOperationCompletedEventArgs"/> instance containing the event data.</param>
        private void CameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            this.isInit = true;

            if (this.shouldDispose)
            {
                CleanUp();
                return;
            }

            if (e.Succeeded)
            {
                if (this.camera.IsFlashModeSupported(FlashMode.Off))
                {
                    this.camera.FlashMode = FlashMode.Off;
                }

                // Start scan process in separate thread
                Task.Factory.StartNew(async
                                          (_) =>
                {
                    while (this.result == null)
                    {
                        var waitTask = Task.Delay(1500);

                        if (this.camera.IsFocusSupported)
                        {
                            this.camera.Focus();
                        }

                        await waitTask;

                        int width        = (int)this.camera.PreviewResolution.Width;
                        int height       = (int)this.camera.PreviewResolution.Height;
                        int size         = width * height;
                        var cameraBuffer = new int[size];
                        this.camera.GetPreviewBufferArgb32(cameraBuffer);

                        var converted = new byte[size * sizeof(int)];
                        Buffer.BlockCopy(cameraBuffer, 0, converted, 0, converted.Length);

                        try
                        {
                            this.reader.Decode(converted, width, height, RGBLuminanceSource.BitmapFormat.BGRA32);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }, TaskCreationOptions.LongRunning | TaskCreationOptions.DenyChildAttach, CancellationToken.None);
            }
            else
            {
                this.result = new BarcodeScannerTask.ScanResult(TaskResult.None);
                NavigationService.GoBack();
            }
        }
Пример #27
0
        void cam_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            Dictionary<object, object> zxingHints 
                = new Dictionary<object, object>() { { DecodeHintType.TRY_HARDER, true } };
            _cam.FlashMode = FlashMode.Auto;
            _reader = new MultiFormatUPCEANReader(zxingHints);

            _cam.Focus();                    
        }
Пример #28
0
 void Camera_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     // Increments the savedCounter variable used for generating JPEG file names.
     SavedCounter++;
     Debug.WriteLine(SavedCounter.ToString());
     if (IsActive)
     {
         Camera.CaptureImage();
     }
 }
Пример #29
0
 void camAutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     try
     {
         cam.CaptureImage();
         System.Diagnostics.Debug.WriteLine("CaptureImage()");
     }
     catch
     {
     }
 }
Пример #30
0
        private void PhotoCamera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            State = PhotoCameraServiceState.Started;

            var eventHandler = Initialized;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
        void camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
            {
                imageDetails.Text += string.Format("{0} supported resolutions.\n", camera.AvailableResolutions.Count());
                imageDetails.Text += string.Format("Current resolution: {0}\n", camera.Resolution);
                imageDetails.Text += string.Format("Preview resolution: {0}\n", camera.PreviewResolution);
            });

            camera.Initialized -= camera_Initialized;
        }
Пример #32
0
        void cam_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                // Write message to UI.
                txtDebug.Text = "Auto focus has completed.";

                // Hide the focus brackets.
                focusBrackets.Visibility = Visibility.Collapsed;
            });
        }
Пример #33
0
        void Camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            this.Camera.Resolution = this.Camera.AvailableResolutions.First();
            this.Camera.FlashMode  = FlashMode.Off;

            this.CameraW           = Convert.ToInt32(this.Camera.Resolution.Width);
            this.CameraH           = Convert.ToInt32(this.Camera.Resolution.Height);
            this.CameraInitialized = true;
            this.ScanBtnVisibility = Visibility.Visible;
            this.NotifyOfPropertyChange(() => this.ScanBtnVisibility);
        }
Пример #34
0
 private void PhotoCameraOnAutoFocusCompleted(object sender, CameraOperationCompletedEventArgs cameraOperationCompletedEventArgs)
 {
     try
     {
         ScanPreviewBuffer();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Пример #35
0
 private void CamOnInitialized(object sender, CameraOperationCompletedEventArgs eventArgs)
 {
     Dispatcher.BeginInvoke(() =>
     {
         if (eventArgs.Succeeded)
         {
             TurnOffFlash();
             StartFocusing();
             StartScanning();
         }
     });
 }
Пример #36
0
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            int width = Convert.ToInt32(PhotoCamera.PreviewResolution.Width);
            int height = Convert.ToInt32(PhotoCamera.PreviewResolution.Height);

            luminance = new PhotoCameraLuminanceSource(width, height);
            qrReader = new QRCodeReader();
            ean13Reader = new EAN13Reader();
            code39Reader = new Code39Reader();

            timer = new Timer((s) => ScanPreviewBuffer(), null, 0, 250);
        }
Пример #37
0
        void photoCamera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            // Initialize the Detector
            //This need to be done AFTER the camera is initialized
            arDetector = new GrayBufferMarkerDetector();

            // Setup both markers
            Marker[] markers = GameState.getInstance().getMarkers();

            arDetector.Initialize(System.Convert.ToInt32(photoCamera.PreviewResolution.Width), System.Convert.ToInt32(photoCamera.PreviewResolution.Height), 1, 4000, markers);
            isInitialized = true;
        }
Пример #38
0
        //------------QR CODE -----------------

        private void camera_Initialised(object sender, CameraOperationCompletedEventArgs e)
        {
            // set the camera resolution
            if (e.Succeeded)
            {
                var res = from resolution in camera.AvailableResolutions
                          where resolution.Width == 640
                          select resolution;

                camera.Resolution = res.First();
            }
        }
Пример #39
0
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            int width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
            int height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);
            
            _luminance = new PhotoCameraLuminanceSource(width, height);
            _reader = new QRCodeReader();

            Dispatcher.BeginInvoke(() => {
                _previewTransform.Rotation = _photoCamera.Orientation;
                _timer.Start();
            });
        }
Пример #40
0
 private void CameraAutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     Action action = () => {
                         lock (this) {
                             try {
                                 camera.CaptureImage();
                             } catch (Exception exception) {
                                 Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show(exception.ToString()));
                             }
                         }
                     };
     Deployment.Current.Dispatcher.BeginInvoke(action);
 }
Пример #41
0
		void _camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
		{
			if (e.Succeeded == true)
			{
				Dispatcher.BeginInvoke(() =>
				{
					VisualStateManager.GoToState(this, StartCaptureState.Name, false);
				});
			}
			else
			{
				//TODO : 카메라 초기화 실패시에 재시도 처리가 필요함.
			}
		}
Пример #42
0
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            int width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
            int height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);

            this._luminance = new PhotoCameraLuminanceSource(width, height);
            this._reader = new BarcodeReader();
            _reader.Options.TryHarder = true;

            Dispatcher.BeginInvoke(() => _previewTransform.Rotation = _photoCamera.Orientation);

            _photoCamera.Resolution = _photoCamera.AvailableResolutions.First();

            _isInitialized = true;
        }
Пример #43
0
        void cam_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            //int width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
            //int height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);
            int width = 640;
            int height = 480;
            _luminance = new PhotoCameraLuminanceSource(width, height);

            Dispatcher.BeginInvoke(() =>
            {
                _previewTransform.Rotation = _photoCamera.Orientation;
                _timer.Start();
            });
            _photoCamera.FlashMode = FlashMode.Auto;
            _photoCamera.Focus();
        }
Пример #44
0
        void CollectCameraCaps(object sender, CameraOperationCompletedEventArgs e)
        {
            var camera = sender as PhotoCamera;
            if (camera == null)
                return;

            if (camera.CameraType == CameraType.Primary)
            {
                CurrentCameraResolution = camera.Resolution;
                HasFocusAtPoint = camera.IsFocusAtPointSupported;
                HasFocus = camera.IsFocusSupported;
                PhotoPixelLayout = camera.YCbCrPixelLayout;
                SupportedResolutions = camera.AvailableResolutions;
            }

            UninitializeCamera(camera);
        }
Пример #45
0
        private void cam_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            if (e.Succeeded)
            {
                Dispatcher.BeginInvoke(delegate
                {
                    _phoneCamera.FlashMode = FlashMode.Off;
                    _previewBuffer = new WriteableBitmap((int)_phoneCamera.PreviewResolution.Width,
                        (int)_phoneCamera.PreviewResolution.Height);

                    _barcodeReader = new BarcodeReader { Options = { TryHarder = true } };

                    _barcodeReader.ResultFound += _bcReader_ResultFound;
                    _scanTimer.Start();
                });
            }
            else
                Dispatcher.BeginInvoke(() => MessageBox.Show("No se ha podido inicializar la cámara!"));

        }
Пример #46
0
 private void CamCaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     _savedCounter++;
 }
      void camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
      {
         Dispatcher.BeginInvoke(() =>
         {
            imageDetails.Text += string.Format("{0} supported resolutions.\n", camera.AvailableResolutions.Count());
            imageDetails.Text += string.Format("Current resolution: {0}\n", camera.Resolution);
            imageDetails.Text += string.Format("Preview resolution: {0}\n", camera.PreviewResolution);
         });

         camera.Initialized -= camera_Initialized;
      }
Пример #48
0
 private void myCam_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     //todo stuff when photo taken
 }
Пример #49
0
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
            {
               _timer = new DispatcherTimer();
               _timer.Interval = TimeSpan.FromMilliseconds(250);
               _timer.Tick += (o, arg) => ScanPreviewBuffer();

               int width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
               int height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);

               _luminance = new PhotoCameraLuminanceSource(width, height);
               _reader = new BarcodeReader(null, bmp => _luminance, null);
            });

             Dispatcher.BeginInvoke(() =>
            {
               _previewTransform.Rotation = _photoCamera.Orientation;
               _timer.Start();
            });
        }
Пример #50
0
 /// <summary>
 /// Called when [camera capture completed].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="Microsoft.Devices.CameraOperationCompletedEventArgs"/> instance containing the event data.</param>
 private void OnCameraCaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("CaptureCompleted");
 }
Пример #51
0
      private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
      {
         var width = Convert.ToInt32(photoCamera.PreviewResolution.Width);
         var height = Convert.ToInt32(photoCamera.PreviewResolution.Height);

         Dispatcher.BeginInvoke(() =>
         {
            previewTransform.Rotation = photoCamera.Orientation;
            // create a luminance source which gets its values directly from the camera
            // the instance is returned directly to the reader
            luminance = new PhotoCameraLuminanceSource(width, height);
            reader = new BarcodeReader(null, bmp => luminance, null);
         });
      }
Пример #52
0
 /// <summary>
 /// Called when [camera initialized].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="Microsoft.Devices.CameraOperationCompletedEventArgs"/> instance containing the event data.</param>
 private void OnCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
 {
     this.camera.FlashMode = FlashMode.Off;
 }
 void _phoneCamera_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     if (e.Exception != null)
     {
         Debug.WriteLine("{0}", e.Exception.Message);
     }
 }
Пример #54
0
 //camera setup
 void cam_Initialized(object sender, CameraOperationCompletedEventArgs e)
 {
     _cam.FlashMode = FlashMode.Auto;
     _cam.Focus();
 }
        private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
        {
            var width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
            var height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);

            _luminance = new PhotoCameraLuminanceSource(width, height);

            _photoCamera.FlashMode = FlashMode.Off;

            _initialized = true;

            OnCameraInitialized(_initialized);
        }
Пример #56
0
        void cam_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
        {
            Debug.WriteLine("cam_CaptureCompleted");

            switch (cm)
            {
                case CaptureMode.CaptureFrame:
                    cm = CaptureMode.CapturePhoto;
                    break;
                case CaptureMode.CapturePhoto:
                    cm = CaptureMode.PostView;
                    //cm = CaptureMode.CaptureFrame;
                    //Deployment.Current.Dispatcher.BeginInvoke(delegate()
                    //{
                    //    NavigationService.Navigate(new Uri("/Postview.xaml", UriKind.Relative));
                    //    lastView.Visibility = Visibility.Collapsed;
                    //    GuidelineIn.Begin();
                    //});
                    break;
            }

            // Increments the savedCounter variable used for generating JPEG file names.
            savedCounter++;
            savedCounter %= 2; // toggle 0 and 1
        }
Пример #57
0
 void cam_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
 {
     // Increments the savedCounter variable used for generating JPEG file names.
     savedCounter++;
 }
        private void PhotoCamera_Initialized(object sender, CameraOperationCompletedEventArgs e)
        {
            State = PhotoCameraServiceState.Started;

            var eventHandler = Initialized;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
        private void PhotoCamera_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
        {
            var eventHandler = CaptureCompleted;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
Пример #60
0
        //searches for QRCode in bitmap
        void cam_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e)
        {
            if (result == null)
            { 
            try
            {
                _nbTry++;
                watch.Reset();
                watch.Start();

                while ((result == null) && (watch.ElapsedMilliseconds < 1500))
                {
                    var binaryBitmap = GetBitmapFromVideo(_cam);
                    if (binaryBitmap != null)
                    {
                        try
                        {
                            //decodes QRcode
                            result = BarCodeManager.ZXingReader.decode(binaryBitmap);
                        }
                        catch
                        {
                            // Wasn't able to find a barcode
                        }
                    }
                }

                if (result != null)
                {
                    BarCodeManager._onBarCodeFound(result.Text);
                }
                else
                {
                    // Try to focus again
                    if (_nbTry < BarCodeManager.MaxTry)
                    {
                        _cam.Focus();
                    }
                    else
                    {
                        BarCodeManager._onError(new VideoScanException("Nothing was found during the scan"));
                    }
                }
            }
            catch (Exception exc)
            {
                BarCodeManager._onError(exc);
            }
        }
      }