Skip to content

Instantly share code, notes, and snippets.

@polatengin
Last active July 3, 2017 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polatengin/647b7a895e8b0f06daa4a37935d45c78 to your computer and use it in GitHub Desktop.
Save polatengin/647b7a895e8b0f06daa4a37935d45c78 to your computer and use it in GitHub Desktop.
Windows 10 UWP uygulamalarında ön veya arka kamera'nın görüntüsünü almak
var camera = videoDevices.FirstOrDefault(item => item.EnclosureLocation != null && item.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back);
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
var videoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var camera = videoDevices.FirstOrDefault(item => item.EnclosureLocation != null && item.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);
if (camera != null)
{
var captureSettings = new MediaCaptureInitializationSettings { VideoDeviceId = camera.Id };
var mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(captureSettings);
CameraCaptureElement.Source = mediaCapture;
await mediaCapture.StartPreviewAsync();
}
}
<Page
x:Class="SelectFrontOrBackCamera.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SelectFrontOrBackCamera">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<CaptureElement x:Name="CameraCaptureElement" />
</Grid>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment