当前位置: 首页>>代码示例>>C#>>正文


C# MediaCapture.SetPreviewRotation方法代码示例

本文整理汇总了C#中Windows.Media.Capture.MediaCapture.SetPreviewRotation方法的典型用法代码示例。如果您正苦于以下问题:C# MediaCapture.SetPreviewRotation方法的具体用法?C# MediaCapture.SetPreviewRotation怎么用?C# MediaCapture.SetPreviewRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Media.Capture.MediaCapture的用法示例。


在下文中一共展示了MediaCapture.SetPreviewRotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: This_Loaded

        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;
            }
        }
开发者ID:ValentinMinder,项目名称:pocketcampus,代码行数:25,代码来源:CodeScanView.xaml.cs

示例2: StartPreviewAsync

 public async Task StartPreviewAsync(VideoRotation videoRotation)
 {
     try
     {
         if (mediaCapture == null)
         {
             var cameraDevice = await FindCameraDeviceByPanelAsync(Panel.Back);
             mediaCapture = new MediaCapture();
             var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
             await mediaCapture.InitializeAsync(settings);
             captureElement.Source = mediaCapture;
             await mediaCapture.StartPreviewAsync();
             isPreviewing = true;
             mediaCapture.SetPreviewRotation(videoRotation);
             displayRequest.RequestActive();
         }
         //DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
     }
     catch (UnauthorizedAccessException)
     {
         // This will be thrown if the user denied access to the camera in privacy settings
         Debug.WriteLine("The app was denied access to the camera");
     }
     catch (Exception ex)
     {
         Debug.WriteLine("MediaCapture initialization failed. {0}", ex.Message);
     }
 }
开发者ID:builttoroam,项目名称:BuildIt,代码行数:28,代码来源:CameraFeedUtility.cs

示例3: IniciaPreviaCapturaFoto

        async private void IniciaPreviaCapturaFoto(object sender, RoutedEventArgs e)
        {
            GerenteCaptura = new Windows.Media.Capture.MediaCapture();
            await GerenteCaptura.InitializeAsync();

            GerenteCaptura.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            CapturaPrevia.Source = GerenteCaptura;
            await GerenteCaptura.StartPreviewAsync();
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:9,代码来源:MainPage.xaml.cs

示例4: initCamera

        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();
        }
开发者ID:Benjin,项目名称:Selfie,代码行数:14,代码来源:MainPage.xaml.cs

示例5: InitializeAsync

        public async Task InitializeAsync()
        {
            // Discover all the cameras
            await EnumerateCamerasAsync();

            // Create a camera preview image source (from Imaging SDK)
            captureManager = new MediaCapture();
            MediaCaptureInitializationSettings captureSettings = new MediaCaptureInitializationSettings();
            captureSettings.VideoDeviceId = backCamera.Id;

            await captureManager.InitializeAsync(captureSettings);

            CameraPreview.Source = captureManager;
            captureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            await captureManager.StartPreviewAsync();
        }
开发者ID:powerytg,项目名称:prism,代码行数:16,代码来源:CameraBackgroundView.xaml.cs

示例6: IniciaPreviaCapturaFoto

        async private void IniciaPreviaCapturaFoto(object sender, RoutedEventArgs e)
        {
            GerenteCaptura = new Windows.Media.Capture.MediaCapture();
            var cameraID = await GetCameraID(Windows.Devices.Enumeration.Panel.Front);

            await GerenteCaptura.InitializeAsync(new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
                PhotoCaptureSource = PhotoCaptureSource.Photo,
                AudioDeviceId = string.Empty,
                VideoDeviceId = cameraID.Id,
            });

            GerenteCaptura.SetPreviewRotation(VideoRotation.Clockwise270Degrees);
            CapturaPrevia.Source = GerenteCaptura;
            await GerenteCaptura.StartPreviewAsync();
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:17,代码来源:MainPage.xaml.cs

示例7: Initialize

        public async Task<MediaCapture> Initialize(CaptureUse primaryUse = CaptureUse.Photo)
        {
            var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
            mediaCapture = new MediaCapture();
            if (devices.Count() > 0)
            {
                await this.mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = devices.ElementAt(1).Id, PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.VideoPreview });
            }  
            mediaCapture.VideoDeviceController.PrimaryUse = primaryUse;
            mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);

            imgEncodingProperties = ImageEncodingProperties.CreateJpeg();
            imgEncodingProperties.Width = 640;
            imgEncodingProperties.Height = 480;

            videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto); 

            return mediaCapture;
        }
开发者ID:vandersmissenc,项目名称:AirStream,代码行数:19,代码来源:CameraCapture.cs

示例8: OnNavigatedTo

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.

            // Create MediaCapture and init
            mediaCapture = new MediaCapture();
            await mediaCapture.InitializeAsync();
            mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            

            // Assign to Xaml CaptureElement.Source and start preview
            capturePreview.Source = mediaCapture;
            await mediaCapture.StartPreviewAsync();
        }
开发者ID:IPGPTP,项目名称:neon_windows_prototypes,代码行数:25,代码来源:MainPage.xaml.cs

示例9: InitCamera

        //private void orientView()
        //{
        //    var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
        //    grid.Height = bounds.Height;
        //    grid.Width = bounds.Width;

        //    var displayInfo = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
        //    switch (displayInfo.CurrentOrientation)
        //    {
        //        case Windows.Graphics.Display.DisplayOrientations.Landscape:
        //            mediaCapture.SetPreviewRotation(VideoRotation.None);
        //            break;
        //        case Windows.Graphics.Display.DisplayOrientations.LandscapeFlipped:
        //            mediaCapture.SetPreviewRotation(VideoRotation.Clockwise180Degrees);
        //            break;
        //        case Windows.Graphics.Display.DisplayOrientations.Portrait:
        //            mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
        //            break;
        //        case Windows.Graphics.Display.DisplayOrientations.PortraitFlipped:
        //            mediaCapture.SetPreviewRotation(VideoRotation.Clockwise270Degrees);
        //            break;
        //    }
        //}

        async private void InitCamera()
        {
            if (App.APP_SETTINGS.Cameras.Count > 0)
            {
                try
                {
                    mediaCapture = new MediaCapture();
                    await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = App.APP_SETTINGS.Cameras[App.APP_SETTINGS.SelectedCamera].ID, PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.VideoPreview, StreamingCaptureMode = StreamingCaptureMode.Video });
                    SetResolution();

                    capturePreview.Source = mediaCapture;
                    //orientView();

                    if(App.IsMobile)
                        mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);

                    await mediaCapture.StartPreviewAsync();
                    if (mediaCapture.VideoDeviceController.FocusControl.Supported)
                    {
                        await mediaCapture.VideoDeviceController.FocusControl.SetPresetAsync(Windows.Media.Devices.FocusPreset.AutoNormal);
                    }
                    else
                    {
                        FocusText.Visibility = Visibility.Collapsed;
                    }
             
                    if(!mediaCapture.VideoDeviceController.TorchControl.Supported)
                    {
                        btnTorch.Visibility = Visibility.Collapsed;
                    }
                    
                    beginCapture();
                }
                catch (Exception ex)
                {

                }
            }
            else
            {
                NoCamera.Visibility = Visibility.Visible;
            }
        }
开发者ID:lorenzofar,项目名称:Rewards-Wallet,代码行数:67,代码来源:Capture.xaml.cs

示例10: InitializePreview

        public async Task InitializePreview(CaptureElement captureElement)
        {
            captureManager = new MediaCapture();

            var cameraID = await GetCameraID(Panel.Back);

            if (cameraID == null)
            {
                return;
            }

            await captureManager.InitializeAsync(new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
                PhotoCaptureSource = PhotoCaptureSource.Photo,
                AudioDeviceId = string.Empty,
                VideoDeviceId = cameraID.Id
            });

            await
                captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo,
                    maxResolution());

            captureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);

            StartPreview(captureElement);
        }
开发者ID:iot-alex,项目名称:virtual-shields-universal,代码行数:27,代码来源:Camera.cs

示例11: InitialAsync

        public async Task InitialAsync(CaptureElement captureElement, MediaEncodingProfile profile = null, bool BackCamera = false)
        {
            if (initialized)
                Dispose(true);
            initialized = true;

            this.captureElement = captureElement;
            this.activeProfile = profile;
            if (CameraDeviceList == null)
                await EnumerateCameras();

            mediaCapture = null;
            mediaCapture = new MediaCapture();

            IsBackCamera = BackCamera;
            captureInitSettings = InitCaptureSettings(IsBackCamera);
            await mediaCapture.InitializeAsync(captureInitSettings);
            mediaCapture.VideoDeviceController.DesiredOptimization = MediaCaptureOptimization.LatencyThenQuality;
            mediaCapture.CameraStreamStateChanged += MediaCapture_CameraStreamStateChanged;
            mediaCapture.Failed += MediaCapture_Failed;
            mediaCapture.FocusChanged += MediaCapture_FocusChanged;
            mediaCapture.PhotoConfirmationCaptured += MediaCapture_PhotoConfirmationCaptured;
            mediaCapture.RecordLimitationExceeded += MediaCapture_RecordLimitationExceeded;
            mediaCapture.ThermalStatusChanged += MediaCapture_ThermalStatusChanged;
            await SetResolutionAsync();

            if (Manager.DeviceService.CurrentDevice() == DeviceTypes.Mobile)
            {
                if (IsBackCamera)
                {
                    mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
                }
                else
                {
                    mediaCapture.SetPreviewRotation(VideoRotation.Clockwise270Degrees);
                }
            }
            activeProfile = CreateProfile();
            mediaCapture.VideoDeviceController.PrimaryUse = CaptureUse.Video;

            captureElement.Source = mediaCapture;
        }
开发者ID:sutoentertainment,项目名称:BaoViet,代码行数:42,代码来源:BasicCameraService.cs

示例12: InitiateCameraCaptureObject

        private async Task InitiateCameraCaptureObject(Panel deviceLocation)
        {
            try
            {
                if (_bInitializingCamera || _cameraCapture != null) return;
                _bInitializingCamera = true;
                await InitCaptureSettings(deviceLocation);
                _cameraCapture = new MediaCapture();
                await _cameraCapture.InitializeAsync(_captureInitSettings);
                //Enable QR Detector
                if (_qrDetectionModeEnabled)
                {
                    var formats = _cameraCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo);
                    var format = (VideoEncodingProperties)formats.OrderBy((item) =>
                    {
                        var props = (VideoEncodingProperties)item;
                        return Math.Abs(props.Height - ActualWidth) + Math.Abs(props.Width - ActualHeight);
                    }).First();
                    await _cameraCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, format);
                    var definition = new LumiaAnalyzerDefinition(ColorMode.Yuv420Sp, format.Width >= format.Height ? format.Width : format.Height, AnalyzeImage);
                    await _cameraCapture.AddEffectAsync(MediaStreamType.VideoPreview, definition.ActivatableClassId, definition.Properties);
                    _barcodeReader = _barcodeReader ?? new BarcodeReader
                    {
                        Options = new DecodingOptions
                        {
                            PossibleFormats = new[] { BarcodeFormat.QR_CODE, BarcodeFormat.CODE_128 },
                            TryHarder = true
                        }
                    };
                }

                PhotoPreview.Source = _cameraCapture;
                await _cameraCapture.StartPreviewAsync();
                _cameraCapture.Failed += CameraCaptureOnFailed;
                _scannerAutoFocus = await ScannerAutoFocus.StartAsync(_cameraCapture.VideoDeviceController.FocusControl);
                _cameraCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            }
            catch (Exception ex)
            {
                WindowsPhoneUtils.Log(ex.Message);
            }
            _bInitializingCamera = false;
        }
开发者ID:Appverse,项目名称:appverse-mobile,代码行数:43,代码来源:CameraViewPage.xaml.cs

示例13: CaptureImage

        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();
        }
开发者ID:cealmees,项目名称:Appdoptame,代码行数:18,代码来源:MainPage.xaml.cs

示例14: Start_Capture_Preview_Click

        async private void Start_Capture_Preview_Click()
        {
            //var cameraDevice = await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Front);
            var Videodevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
            var cameraDevice = Videodevices.FirstOrDefault(item => item.EnclosureLocation != null && item.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back);
            if (cameraDevice == null)
            {
                Debug.WriteLine("No camera device found!");
                return;
            }

            // Create MediaCapture and its settings
            captureManager = new MediaCapture();

            var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };

            // Initialize MediaCapture
            try
            {
                await captureManager.InitializeAsync(settings);
                // just after initialization
                var maxResolution = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate(
                                    (i1, i2) => (i1 as VideoEncodingProperties).Width > (i2 as VideoEncodingProperties).Width ? i1 : i2);
                await captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, maxResolution);
                captureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
                _isInitialized = true;                
            }
            catch (UnauthorizedAccessException)
            {
                Debug.WriteLine("The app was denied access to the camera");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception when initializing MediaCapture with {0}: {1}", cameraDevice.Id, ex.ToString());
            }
            
            capturePreview.Source = captureManager;   //Start preiving on CaptureElement  
            await captureManager.StartPreviewAsync();  //Start camera capturing   
        }        
开发者ID:jigneshjain25,项目名称:CamDictionary,代码行数:39,代码来源:MainPage.xaml.cs

示例15: StartCamera

        async void StartCamera()
        {
            var cameraID = await GetCameraID(Windows.Devices.Enumeration.Panel.Back);
            mediaCapture = new MediaCapture();
            await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
                PhotoCaptureSource = PhotoCaptureSource.VideoPreview,
                AudioDeviceId = string.Empty,
                VideoDeviceId = cameraID.Id

            });
            //var maxResolution = mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate((i1, i2) => (i1 as VideoEncodingProperties).Width > (i2 as VideoEncodingProperties).Width ? i1 : i2);
            //await mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, maxResolution);

            var maxResolution = mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate(
                    (i1, i2) => (i1 as VideoEncodingProperties).Width > (i2 as VideoEncodingProperties).Width ? i1 : i2);
            await mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, maxResolution);

            mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            //mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees);
            CameraPreview.Source = mediaCapture;
            await mediaCapture.StartPreviewAsync();
        }
开发者ID:ReecePatterson,项目名称:Synergy,代码行数:24,代码来源:CameraPage.xaml.cs


注:本文中的Windows.Media.Capture.MediaCapture.SetPreviewRotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。