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(); }
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(); } }
private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e) { cameraInitialized = true; if (closeAfterCameraInit) { Dispatcher.BeginInvoke(GoBack); return; } 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(); }); }
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); Deployment.Current.Dispatcher.BeginInvoke(() => { if (result != null) { this.Tip.Text = result.Text; } else { this.Tip.Text = "未识别" + DateTime.Now.ToString("HH:mm:ss"); } }); }
private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e) { var width = Convert.ToInt32(_photoCamera.PreviewResolution.Width); var height = Convert.ToInt32(_photoCamera.PreviewResolution.Height); _photoCamera.FlashMode = FlashMode.Off; 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); //if(focusTimer!= null) focusTimer.Start(); }); }