flipped images with front camera for wp8

泪湿孤枕 提交于 2019-12-13 03:38:09

问题


I am using lumia imaging sdk for my windows phone app. I mainly use the front camera for it. Also am using the VideoBrush to capture the images. When I am trying to take picture with front camera, it works perfectly but when the image is captured, the image is flipped and saved(like a mirror effect).

<Canvas x:Name="VideoCanvas" Width="480" Height="640" RenderTransformOrigin="0.5,0.5">
    <Canvas.RenderTransform>
        <CompositeTransform ScaleX="-1"/>
    </Canvas.RenderTransform>
    <Canvas.Background>
        <VideoBrush x:Name="videoBrush"/>
    </Canvas.Background>                
</Canvas>

The Scale="-1" above is helpful for initializing the camera but the capture task storing it as its mirror image. Below is the code that is used to capture the image. Is this mirror effect can be manipulated here?

private async Task Capture()
{
        if (!_capturing)
        {
            _capturing = true;

            MemoryStream stream = new MemoryStream();

            CameraCaptureSequence sequence = _dataContext.Device.CreateCaptureSequence(1);
            sequence.Frames[0].CaptureStream = stream.AsOutputStream();

            await _dataContext.Device.PrepareCaptureSequenceAsync(sequence);
            await sequence.StartCaptureAsync();

            _dataContext.ImageStream = stream;

            _capturing = false;
        }
}

Or is there any way to flip and save the captured image(like the LumiaSelfie app does)? Please help me with this. Thanks in advance.


回答1:


In your Lumia Imaging SDK rendering chain you can add a Flipfilter: https://msdn.microsoft.com/en-us/library/lumia.imaging.transforms.flipfilter.aspx

Example:

using (var source = ...)
using (var effect = new FilterEffect(source))
using (var renderer = new JpegRenderer(effect))
{
   effect.Filters = new [] { new FlipFilter(FlipMode.Horizontal) };

   var result = await renderer.RenderAsync();
}


来源:https://stackoverflow.com/questions/31169881/flipped-images-with-front-camera-for-wp8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!