2016-03-02 34 views
0

我想知道如何设置一个相机分辨率在16; 9纵横比在Windows通用应用程序,我已经尝试过不同的代码,但没有人正在工作,我失去了一点点的帧率,当我使用下面的一些代码,我不知道如何设置一个摄像头的分辨率为16; 9这是一个问题,有没有任何功能VideoeEcodingProporties帮助我完成这一点。如何设置相机分辨率长宽比16; 9在Windows 10通用APP

XAML UWP CODE; 
    <Page 
     x:Class="whatchado_recorder.Video.Capture" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:local="using:whatchado_recorder" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     mc:Ignorable="d" 
     SizeChanged="Page_SizeChanged"> 

     <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
      <StackPanel x:Name="CaptureStack" Visibility="Collapsed" Margin="0,12,0,0" HorizontalAlignment="Stretch" MaxWidth="720"> 
       <ProgressBar x:Name="RecordProgress" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="6" Minimum="0" Maximum="90"/> 
       <TextBlock x:Name="CameraErrorTextBlock" x:Uid="NoCameraFound" Margin="0,120,0,24" HorizontalAlignment="Center" Text="No camera found :(" VerticalAlignment="Center" FontSize="24" Visibility="Collapsed"/> 

       <Grid x:Name="CaptureGrid" Margin="0,12,0,0"> 
        <CaptureElement x:Name="CaptureElement" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="360" Tapped="captureElement_Tapped"/> 

        <Border Background="Black" Padding="6" Opacity="0.5" HorizontalAlignment="Center" VerticalAlignment="Top"> 
         <TextBlock Foreground="White" FontSize="12"> 
          <Run x:Uid="MaxTime" Text="Max. Time: "/> 
          <Run Text="{Binding Path=Args.SelectedQuestionOnRecordStart.MaxVideoLength, Converter={StaticResource DoubleToStringConverter}}"/> 
         </TextBlock> 
        </Border> 

        <local:MouseOver x:Name="BackgroundCircle" HorizontalAlignment="Center" VerticalAlignment="Center"> 
         <local:MouseOver.NormalState> 
          <Ellipse Fill="Black" Opacity="0.25" HorizontalAlignment="Center" VerticalAlignment="Center" Width="192" Height="192" Tapped="captureElement_Tapped"/> 
         </local:MouseOver.NormalState> 
         <local:MouseOver.MouseOverState> 
          <Ellipse Fill="Black" Opacity="0.5" HorizontalAlignment="Center" VerticalAlignment="Center" Width="192" Height="192" Tapped="captureElement_Tapped"/> 
         </local:MouseOver.MouseOverState> 
        </local:MouseOver> 

        <Ellipse x:Name="RecordCircle" Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Center" Width="36" Height="36" Tapped="captureElement_Tapped"/> 

        <local:MouseOver x:Name="BackgroundStopCircle" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,24"> 
         <local:MouseOver.NormalState> 
          <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="64" Height="64"> 
           <Ellipse Fill="Black" Opacity="0.25" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Tapped="captureElement_Tapped"/> 
           <Rectangle Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" Tapped="captureElement_Tapped"/> 
          </Grid> 
         </local:MouseOver.NormalState> 
         <local:MouseOver.MouseOverState> 
          <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="64" Height="64"> 
           <Ellipse Fill="Black" Opacity="0.5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Tapped="captureElement_Tapped"/> 
           <Rectangle Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" Tapped="captureElement_Tapped"/> 
          </Grid> 
         </local:MouseOver.MouseOverState> 
        </local:MouseOver> 


        <TextBlock x:Name="CountdownText" Visibility="Collapsed" Foreground="White" FontSize="72" Margin="0, -48, 0, 0" Text="3" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
        <TextBlock x:Name="ExplanationText" x:Uid="LookIntoCamera" Visibility="Collapsed" Foreground="White" FontSize="12" Margin="0, 48, 0, 0" Text="Look into the camera" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
       </Grid> 

       <Button x:Name="CancelButton" x:Uid="Cancel" Content="Cancel" Style="{StaticResource NormalButtonStyle}" Margin="0,12,0,0" Padding="24,0,24,0" HorizontalAlignment="Right" Click="cancelButton_Click"/> 
      </StackPanel> 
     </Grid> 
    </Page> 

UWP CS.CODE;

var maxPreviewResolution = mc.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Aggregate((i1, i2) => (i1 as VideoEncodingProperties).Height > (i2 as VideoEncodingProperties).Height ? i1 : i2); 
await mc.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, maxPreviewResolution); 
         ` 

回答

0

你可以看看在camera resolution sample

参见:一旦你有你可以看看这里

width/16 == height/9 

找到所有决议案的mediaStream性能

IEnumerable<StreamResolution> allPreviewProperties = _previewer.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Select(x => new StreamResolution(x)); 

与您的比例相匹配

相关问题