Windows runtime 旋转摄影机ReviewImageSource

Windows runtime 旋转摄影机ReviewImageSource,windows-runtime,windows-phone-8.1,video-capture,nokia-imaging-sdk,lumia-imaging-sdk,Windows Runtime,Windows Phone 8.1,Video Capture,Nokia Imaging Sdk,Lumia Imaging Sdk,我正在尝试旋转CameraPreviewImageSource以使其(仅)在纵向模式下显示: private async Task InitializeAsync() { this.cameraPreviewImageSource = new CameraPreviewImageSource(); DeviceInformationCollection devices = await Windows.Devices.Enumeration.Dev

我正在尝试旋转CameraPreviewImageSource以使其(仅)在纵向模式下显示:

    private async Task InitializeAsync()
    {
        this.cameraPreviewImageSource = new CameraPreviewImageSource();

        DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);
        String backCameraId = devices.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back).Id;
        await cameraPreviewImageSource.InitializeAsync(backCameraId);

        VideoEncodingProperties properties = await this.cameraPreviewImageSource.StartPreviewAsync();

        double width = 1280;
        double height = 720;

        this.writeableBitmap = new WriteableBitmap( (int)width, (int)height );
        this.capturePreview.Source = this.writeableBitmap;

        this.writeableBitmapRenderer = new WriteableBitmapRenderer();
        this.jpegRenderer = new JpegRenderer();

        this.cameraPreviewImageSource.PreviewFrameAvailable += OnPreviewFrameAvailable;
    }
我也在文件中尝试过,但大多数时候结果都很奇怪(比如90%的图片被隐藏):



有什么想法吗?

既然您正在使用诺基亚图像SDK来实现这一点,您是否尝试过在渲染链中添加旋转过滤器,并在需要时旋转它


然后,您的链将是:CameraPreviewSource->FilterEffect[rotateFilter]->WriteableBitmapRenderer。

尝试此开关,宽度和高度,并添加旋转设置为90的旋转过滤器。同时将设备方向设置为纵向。 如果希望在应用程序的其余部分中支持其他方向,只需在OnNavigatedTo/OnNavigatedFrom中设置方向


什么意思?让它只在纵向模式下出现?你的意思是说,无论他们朝哪个方向转动它,它总是看起来像是在肖像模式?或者你的意思是,除非在肖像模式下,否则不可见?“无论他们以何种方式转动它,它总是看起来好像在肖像模式下”很抱歉,我昨天遵循了这一点,它起了作用。谢谢你迟来的回复,我昨天做了一件非常类似的事情,效果很好,谢谢你的支持。
<Image x:Name="capturePreview" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Width="auto"  Height="auto" Canvas.ZIndex="0" >
    <Image.RenderTransform>
        <CompositeTransform CenterX="0.5" CenterY="0.5" Rotation="90" />
    </Image.RenderTransform>
</Image> 
private async Task InitializeAsync()
{
    this.cameraPreviewImageSource = new CameraPreviewImageSource();

    DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);
    String backCameraId = devices.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back).Id;
    await cameraPreviewImageSource.InitializeAsync(backCameraId);

    VideoEncodingProperties properties = await this.cameraPreviewImageSource.StartPreviewAsync();

    double width = 1280;
    double height = 720;

    this.writeableBitmap = new WriteableBitmap( (int)height, (int)width );
    this.capturePreview.Source = this.writeableBitmap;
    var effect = new FilterEffect(m_cameraPreviewImageSource);
    effect.Filters = new IFilter[] { new RotationFilter(90) };

    this.writeableBitmapRenderer = new WriteableBitmapRenderer(effect);
    this.jpegRenderer = new JpegRenderer();

    this.cameraPreviewImageSource.PreviewFrameAvailable += OnPreviewFrameAvailable;
}


protected override void OnNavigatedTo(NavigationEventArgs e)
{
    m_displayOrientations = DisplayInformation.AutoRotationPreferences;
    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
    NavigationHelper.OnNavigatedTo(e);
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    DisplayInformation.AutoRotationPreferences = m_displayOrientations;
    NavigationHelper.OnNavigatedFrom(e);
}