Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetPreviewRotation display issue #26

Open
wisien92 opened this issue Apr 27, 2016 · 5 comments
Open

SetPreviewRotation display issue #26

wisien92 opened this issue Apr 27, 2016 · 5 comments

Comments

@wisien92
Copy link

Hi, I wanted to make display portrait so I called
capture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
after capture initialization and I ended up having some strange black part where the rest of camera preview should have been.

Is there something I should do or some different way to achieve my goal?
wp_ss_20160427_0002

@mmaitre314
Copy link
Owner

You should be able to reuse the code there (there is a NuGet, but it might even be simpler to just copy/paste the code): https://github.com/mmaitre314/MediaCaptureExtensions#rotate-preview-without-extra-black-bars

@wisien92
Copy link
Author

wisien92 commented Apr 28, 2016

@ok, I have downloaded NuGet package and change initialization code to:

var settings = new MediaCaptureInitializationSettings();
await settings.SelectVideoDeviceAsync(VideoDeviceSelection.BackOrFirst);

var capture = new MediaCapture();
await capture.InitializeAsync(settings);
await capture.SetPreviewRotationAsync(VideoRotation.Clockwise90Degrees);

I get error message:

A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll

Additional information: Access is denied.

Before I had only webcam selected in capabilities and it worked - do I need to do something more in manifest?

@mmaitre314
Copy link
Owner

On MediaCaptureInitializationSettings you can try setting StreamingCaptureMode to Video.
https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.streamingcapturemode.aspx

@wisien92
Copy link
Author

wisien92 commented Apr 29, 2016

var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Video;
settings.VideoDeviceId = await GetBackOrDefaulCameraIdAsync();

var capture = new MediaCapture();
await capture.InitializeAsync(settings);

This works - but the camera preview is rotated. Adding line

capture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);

after initilization works but there are black bars. But adding

await capture.SetPreviewRotationAsync(VideoRotation.Clockwise90Degrees);

Results in error:

A first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll

WinRT information: PreviewState

Additional information: The stream number provided was invalid.

PreviewState

@wisien92
Copy link
Author

wisien92 commented Apr 29, 2016

OK - I managed to get rid of side black bars by changing xaml to:

<CaptureElement Name="Preview" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin=".5,.5" >
    <CaptureElement.RenderTransform>
        <RotateTransform Angle="90" CenterX="0.5" CenterY="0.5" />
    </CaptureElement.RenderTransform>
</CaptureElement>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants