locked
Jpeg Rotation always 90 degrees in on screen image RRS feed

  • Question

  • User372481 posted

    Hi,

    I'm posting this in Xamarin.Android as I'm not sure if it's related to the camera2 api or the xamarin forms .

    Basically, I have the camera preview working in my SurfaceView, but when I create a still image capture request using an ImageReader and display it in an xamarin.forms element by saving the output of the ImageReader to a file and setting the Image.Source property to it, it is always 90 degrees to the orientation of the screen.

    As an example of the output, here is what I get (orange is the camera preview, green is the resulting image from the still capture request):

    Here is the xaml for the display:

    <AbsoluteLayout IsVisible="{Binding CameraMode}"
                             AbsoluteLayout.LayoutBounds="0,0,1,1"
                             AbsoluteLayout.LayoutFlags="All"
                             Margin="0"
                             Padding="0">
    
                <controls:CameraPreview x:Name="CameraPreview"
                                        AbsoluteLayout.LayoutBounds="0,0,1,1"
                                        AbsoluteLayout.LayoutFlags="All" />
    
                 <Image Source="{Binding PreviewImage}" Aspect="AspectFill" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" Opacity="0.8" />
    
                <Button Text="Timer" 
                        BorderRadius="20"
                        BackgroundColor="{StaticResource PrimaryLight}"
                        AbsoluteLayout.LayoutBounds="0, 1.0, -1, -1"
                        AbsoluteLayout.LayoutFlags="PositionProportional"
                        Clicked="TimerButton_Clicked" />
    
                <Button Text="Capture" 
                        BorderRadius="20"
                        AbsoluteLayout.LayoutBounds="0.5, 1.0, -1, -1"
                        AbsoluteLayout.LayoutFlags="PositionProportional"
                        Clicked="CaptureButton_Clicked"/>
    
                <Button Text="Switch" 
                        BorderRadius="20"
                        BackgroundColor="{StaticResource PrimaryLight}"
                        AbsoluteLayout.LayoutBounds="1, 1.0, -1, -1"
                        AbsoluteLayout.LayoutFlags="PositionProportional"
                        Clicked="SwitchButton_Clicked"/>
            </AbsoluteLayout>
    

    I know that the jpeg is rotated the correct way as I can save it to the gallery and open it there and I indeed see the photo upright. So I know that I'm setting the JpegRotation correctly when building the capture request. I've attached the code that does the whole preview / capture request here for you to see.

    Any ideas are welcome as I've been at this for weeks now :(

    Thanks, Nick

    Saturday, September 22, 2018 2:23 PM

All replies

  • User364855 posted

    @NickCullen

    There is some missing code. Could you provide your project?

    Monday, September 24, 2018 10:02 AM