SetRecordRotation() public method

public SetRecordRotation ( [ value ) : void
value [
return void
        private async void This_Loaded( object sender, RoutedEventArgs e )
        {
            try
            {
                _camera = new MediaCapture();
                await _camera.InitializeAsync( new MediaCaptureInitializationSettings
                {
                    VideoDeviceId = ( await GetBackCameraAsync() ).Id,
                    StreamingCaptureMode = StreamingCaptureMode.Video,
                    PhotoCaptureSource = PhotoCaptureSource.VideoPreview
                } );
                _camera.VideoDeviceController.FlashControl.Enabled = false;
                _camera.SetPreviewRotation( VideoRotation.Clockwise90Degrees );
                _camera.SetRecordRotation( VideoRotation.Clockwise90Degrees );

                CameraPreview.Source = _camera;
                await _camera.StartPreviewAsync();

                StartScanning();
            }
            catch
            {
                ErrorMessage.Visibility = Visibility.Visible;
            }
        }
        private void PrepareForVideoRecording()
        {
            if (m_mediaCaptureMgr == null)
            {
                return;
            }

            bool counterclockwiseRotation = m_bReversePreviewRotation;

            if (m_bRotateVideoOnOrientationChange)
            {
                m_mediaCaptureMgr.SetRecordRotation(VideoRotationLookup(Windows.Graphics.Display.DisplayProperties.CurrentOrientation, counterclockwiseRotation));
            }
            else
            {
                m_mediaCaptureMgr.SetRecordRotation(Windows.Media.Capture.VideoRotation.None);
            }
        }
Ejemplo n.º 3
0
        private async void initCamera()
        {
            if (camera == null)
            {
                camera = new MediaCapture();
                await camera.InitializeAsync();

                camera.SetPreviewRotation(VideoRotation.Clockwise270Degrees);
                camera.SetRecordRotation(VideoRotation.Clockwise270Degrees);
            }

            CameraPreview.Source = camera;
            await camera.StartPreviewAsync();
        }
        private async Task SwitchCameras(object sender, RoutedEventArgs e)
        {
            await mediaCaptureMgr.StopPreviewAsync();
            mediaCaptureMgr.Dispose();
            mediaCaptureMgr = null;
            mediaCaptureMgr = new MediaCapture();

            if (isUsingFrontCam)
            {
                await mediaCaptureMgr.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = rearCam.Id });

                mediaCaptureMgr.SetRecordRotation(VideoRotation.Clockwise90Degrees);
                mediaCaptureMgr.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            }
            else
            {
                await mediaCaptureMgr.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = frontCam.Id });

                mediaCaptureMgr.SetRecordRotation(VideoRotation.Clockwise270Degrees);
                mediaCaptureMgr.SetPreviewRotation(VideoRotation.Clockwise270Degrees);
            }

            isUsingFrontCam = !isUsingFrontCam;

            StartPreview();
        }
Ejemplo n.º 5
0
        private async Task CaptureImage()
        {

            cameraCapture = new MediaCapture();
            cameraCapture.Failed += cameraCapture_Failed;

            await cameraCapture.InitializeAsync();

#if WINDOWS_PHONE_APP
    cameraCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
    cameraCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees);
#endif

            captureGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
            previewElement.Visibility = Windows.UI.Xaml.Visibility.Visible;
            previewElement.Source = cameraCapture;
            await cameraCapture.StartPreviewAsync();
        }
Ejemplo n.º 6
0
        private async Task InitializeQrCode()
        {
            string error = null;
            try
            {
                //if (_mediaCapture == null)  
                //{  
                // Find all available webcams  
                DeviceInformationCollection webcamList = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);


                // Get the proper webcam (default one)  
                DeviceInformation backWebcam = (from webcam in webcamList where webcam.IsEnabled && webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back select webcam).FirstOrDefault();


                // Initializing MediaCapture  


                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
                {
                    VideoDeviceId = backWebcam.Id,
                    AudioDeviceId = "",
                    StreamingCaptureMode = StreamingCaptureMode.Video,
                    PhotoCaptureSource = PhotoCaptureSource.VideoPreview
                });


                // Adjust camera rotation for Phone  
                _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
                _mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees);


                // Set the source of CaptureElement to MediaCapture  
                captureElement.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();


                //_mediaCapture.FocusChanged += _mediaCapture_FocusChanged;


                // Seetting Focus & Flash(if Needed)  


                var torch = _mediaCapture.VideoDeviceController.TorchControl;
                if (torch.Supported) torch.Enabled = true;


                await _mediaCapture.VideoDeviceController.FocusControl.UnlockAsync();
                var focusSettings = new FocusSettings();
                focusSettings.AutoFocusRange = AutoFocusRange.FullRange;
                focusSettings.Mode = FocusMode.Continuous;
                focusSettings.WaitForFocus = true;
                focusSettings.DisableDriverFallback = false;
                _mediaCapture.VideoDeviceController.FocusControl.Configure(focusSettings);
                await _mediaCapture.VideoDeviceController.FocusControl.FocusAsync();


                //}  
            }
            catch (Exception ex)
            {
                dialog = new MessageDialog("Error: " + ex.Message);
                dialog.ShowAsync();
            }
        }