本文整理汇总了C#中PhotoCamera类的典型用法代码示例。如果您正苦于以下问题:C# PhotoCamera类的具体用法?C# PhotoCamera怎么用?C# PhotoCamera使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PhotoCamera类属于命名空间,在下文中一共展示了PhotoCamera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
//Networking.DeleteFile("CurrentGame");
//Networking.DeleteFile("Players");
//Check if a game in progress has already been saved and continue it
string data = Networking.LoadData("CurrentGame");
if (data != "" && MessageBox.Show("Would you like to resume the game with id of " + data, "Continue Game", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
NavigationService.Navigate(new Uri("/GamePage.xaml?gameid=" + data, UriKind.Relative));
else
{
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromMilliseconds(250);
_timer.Tick += (o, arg) => ScanPreviewBuffer();
//The timer auto-starts so it needs to be stopped here
_timer.Stop();
}
//Login to the server
Networking.Login();
_cam = new PhotoCamera();
_cam.Initialized += cam_Initialized;
video.Fill = _videoBrush;
_videoBrush.SetSource(_cam);
_videoBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 90 };
}
示例2: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (_photoCamera == null){
_photoCamera = new PhotoCamera();
_photoCamera.Initialized += OnPhotoCameraInitialized;
_previewVideo.SetSource(_photoCamera);
CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;
}
if (timer == null){
timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };
timer.Tick += (o, arg) => ScanPreviewBuffer();
}
if (scanEffect == null){
var resourceStream = Application.GetResourceStream(new System.Uri("Plugins/com.phonegap.plugins.barcodescanner/beep.wav", UriKind.Relative));
if (resourceStream != null)
{
scanEffect = SoundEffect.FromStream(resourceStream.Stream);
}
}
timer.Start();
}
示例3: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Delayed due to Camera init bug in WP71 SDK Beta 2
// See http://forums.create.msdn.com/forums/p/85830/516843.aspx
Dispatcher.BeginInvoke(() =>
{
// Initialize the webcam
photoCamera = new PhotoCamera();
photoCamera.Initialized += PhotoCameraInitialized;
CameraButtons.ShutterKeyHalfPressed += PhotoCameraButtonHalfPress;
isInitialized = false;
isDetecting = false;
// Fill the Viewport Rectangle with the VideoBrush
var vidBrush = new VideoBrush();
vidBrush.SetSource(photoCamera);
Viewport.Fill = vidBrush;
// Start timer
dispatcherTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(50)};
dispatcherTimer.Tick += (sender, e1) => Detect();
dispatcherTimer.Start();
});
}
示例4: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
_isCameraInitialized = false;
_isTrial = new IsTrialQuery().Get();
if (_isTrial)
{
var menuItem = new ApplicationBarMenuItem("Buy full version");
menuItem.Click += (sender, args) => Deployment.Current.Dispatcher.BeginInvoke(() => new MarketplaceDetailTask().Show());
ApplicationBar.MenuItems.Add(menuItem);
}
OnOrientationChanged(this, new OrientationChangedEventArgs(Orientation));
if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
{
_pixelator = new Pixelator(new PixelationSizeQuery().Get(), true);
_photoCamera = new PhotoCamera(CameraType.Primary);
_photoCamera.Initialized += OnCameraInitialized;
_photoCamera.CaptureImageAvailable += OnCameraCaptureImageAvailable;
_photoCamera.CaptureCompleted += OnCameraCaptureCompleted;
_photoCamera.CaptureStarted += OnCameraCaptureStarted;
ViewfinderBrush.SetSource(_photoCamera);
}
else
{
// TODO: handle possibility of no camera
}
}
示例5: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator)
{
MessageBox.Show("You must deploy this sample to a device, instead of the emulator so that you can get a video stream including a barcode/QR code");
this.IsEnabled = false;
base.NavigationService.GoBack();
}
else
{
string type = "";
if (NavigationContext.QueryString.TryGetValue("type", out type) && type == "qrcode")
{
_reader = new QRCodeReader();
}
else
{
_reader = new EAN13Reader();
}
_photoCamera = new PhotoCamera();
_photoCamera.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(cam_Initialized);
_videoBrush.SetSource(_photoCamera);
BarCodeRectInitial();
base.OnNavigatedTo(e);
}
}
示例6: SetCamera
public void SetCamera()
{
_photoCamera = new PhotoCamera(CameraType.Primary);
cameraViewFinder.SetSource(_photoCamera);
double cameraRotation = _photoCamera.Orientation;
previewTransform.Rotation = _photoCamera.Orientation + 0;
}
示例7: OnNavigatedTo
//Code for initialization, capture completed, image availability events; also setting the source for the viewfinder.
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
// Check to see if the camera is available on the phone.
if ((PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) ||
(PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) == true))
{
// Initialize the camera, when available.
if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
{
// Use front-facing camera if available.
cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
}
else
{
// Otherwise, use standard camera on back of phone.
cam = new Microsoft.Devices.PhotoCamera(CameraType.FrontFacing);
}
// Event is fired when the capture sequence is complete and an image is available.
cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);
//Set the VideoBrush source to the camera.
viewfinderBrush.SetSource(cam);
viewfinderBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 90 };
}
else
{
// The camera is not supported on the phone.
this.Dispatcher.BeginInvoke(delegate()
{
// Write message.
txtDebug.Text = "A Camera is not available on this phone.";
});
// Disable UI.
ShutterButton.IsEnabled = false;
}
}
示例8: OnNavigatedTo
// Load data for the ViewModel Items
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!App.ViewModel.IsDataLoaded)
{
App.ViewModel.LoadData();
}
// Initialize the camera object
_phoneCamera = new PhotoCamera();
_phoneCamera.Initialized += cam_Initialized;
_phoneCamera.AutoFocusCompleted += _phoneCamera_AutoFocusCompleted;
CameraButtons.ShutterKeyHalfPressed += CameraButtons_ShutterKeyHalfPressed;
//Display the camera feed in the UI
viewfinderBrush.SetSource(_phoneCamera);
// This timer will be used to scan the camera buffer every 250ms and scan for any barcodes
_scanTimer = new DispatcherTimer();
_scanTimer.Interval = TimeSpan.FromMilliseconds(250);
_scanTimer.Tick += (o, arg) => ScanForBarcode();
viewfinderCanvas.Tap += new EventHandler<GestureEventArgs>(focus_Tapped);
base.OnNavigatedTo(e);
}
示例9: BarcodeScanningView
/// <summary>
/// Initializes a new instance of the BarcodeScanningView class.
/// </summary>
public BarcodeScanningView()
{
InitializeComponent();
_scannerWorker = new BackgroundWorker();
_scannerWorker.DoWork += scannerWorker_DoWork;
_scannerWorker.RunWorkerCompleted += scannerWorker_RunWorkerCompleted;
Loaded += (sender, args) =>
{
if (_photoCamera == null)
{
_photoCamera = new PhotoCamera();
_photoCamera.Initialized += OnPhotoCameraInitialized;
previewVideo.SetSource(_photoCamera);
CameraButtons.ShutterKeyHalfPressed += (o, arg) => FocusTheCamera();
}
if (_timer == null)
{
_timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };
_timer.Tick +=TimerOnTick;
}
if (_focusTimer == null)
{
_focusTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(4500) };
_focusTimer.Tick += (o, eventArgs) => FocusTheCamera();
}
_timer.Start();
};
}
示例10: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true)
{
camera = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
photoViewfinderVideoBrush.SetSource(camera);
photoViewfinderVideoBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 90 };
camera.CaptureCompleted += new EventHandler<CameraOperationCompletedEventArgs>(captureCompletedHandler);
camera.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(captureImageAvailableHandler);
camera.CaptureThumbnailAvailable += new EventHandler<ContentReadyEventArgs>(captureThumbnailAvailableHandler);
camera.AutoFocusCompleted += new EventHandler<CameraOperationCompletedEventArgs>(autoFocusCompletedHandler);
CameraButtons.ShutterKeyHalfPressed += onButtonHalfPressHandler;
CameraButtons.ShutterKeyPressed += onButtonFullPressHandler;
CameraButtons.ShutterKeyReleased += onButtonReleaseHandler;
}
else
{
Deployment.Current.Dispatcher.BeginInvoke(delegate()
{
MessageBox.Show("Camera not supported in this phone");
});
NavigationService.GoBack();
}
}
示例11: cam_Initialized
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);
});
}
示例12: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if ((PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) ||
(PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) == true))
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing))
{
cam = new Microsoft.Devices.PhotoCamera(CameraType.FrontFacing);
}
else
{
cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
}
viewfinderBrush.SetSource(cam);
cam.Initialized += cam_Initialized;
cam.CaptureCompleted += cam_CaptureCompleted;
cam.CaptureImageAvailable += cam_CaptureImageAvailable;
cam.AutoFocusCompleted += cam_AutoFocusCompleted;
// 当按下快门按钮并保持大约 800 毫秒时。短于该时间的半按压将不会触发该事件。
CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;
// 当快门按钮收到一个完全按压时。
CameraButtons.ShutterKeyPressed += OnButtonFullPress;
// 当松开快门按钮时。
CameraButtons.ShutterKeyReleased += OnButtonRelease;
}
base.OnNavigatedTo(e);
}
示例13: GetBitmapFromVideo
//takes the video input and creates a bitmap of the image
BinaryBitmap GetBitmapFromVideo(PhotoCamera cam)
{
BinaryBitmap binaryBitmap = null;
try
{
// Update buffer size
var pixelWidth = (int)_cam.PreviewResolution.Width;
var pixelHeight = (int)_cam.PreviewResolution.Height;
if (_buffer == null || _buffer.Length != (pixelWidth * pixelHeight))
{
_buffer = new byte[pixelWidth * pixelHeight];
}
_cam.GetPreviewBufferY(_buffer);
var luminance = new RGBLuminanceSource(_buffer, pixelWidth, pixelHeight, true);
var binarizer = new com.google.zxing.common.HybridBinarizer(luminance);
binaryBitmap = new BinaryBitmap(binarizer);
}
catch
{
}
return binaryBitmap;
}
示例14: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
_photoCamera = new PhotoCamera();
_photoCamera.Initialized += OnPhotoCameraInitialized;
_previewVideo.SetSource(_photoCamera);
base.OnNavigatedTo(e);
}
示例15: InitCamera
private void InitCamera()
{
_camera = new PhotoCamera(CameraType.Primary);
_camera.Initialized += _camera_Initialized;
VideoViewfinderBrush.SetSource(_camera);
VideoViewfinderTransform.Rotation = _camera.Orientation;
}