×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    13

    Imaging SDK problems

    Hello.
    I am having a problem related with the SDK. I would appreciate it if someone could give me a solution about it.

    When calling the following function, I get my image rotated by 90 degrees.
    Code:
    camera.GetPreviewBufferArgb(cameraBitmap.Pixels);
    Even if I call the following before the GetPreviewBufferArgb, it doesn't seem to work.
    Code:
    camera.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation,
                    camera.SensorLocation == CameraSensorLocation.Back
                    ? camera.SensorRotationInDegrees : -camera.SensorRotationInDegrees);
    The weird thing is that the above SetProperty works when I do the following and it works for both the Thumbnail and the normal resolution capture (strange isn't it?):
    Code:
    CameraCaptureSequence cs = camera.CreateCaptureSequence(1);
                MemoryStream st = new MemoryStream();
                MemoryStream st2 = new MemoryStream();
                cs.Frames[0].CaptureStream = st.AsOutputStream();
                cs.Frames[0].ThumbnailStream = st2.AsOutputStream();
                
                await camera.PrepareCaptureSequenceAsync(cs);
                await camera.FocusAsync();
                await cs.StartCaptureAsync();
    Do I miss anything in order to get in the correct angle the image from GetPreviewBufferArgb or do I have to rotate it manually by code?

    Best regards

    Efthymios Kalyviotis

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Re: Imaging SDK problems

    To my knowledge you will have to rotate it manually when working with the PreviewBuffer. It's different from regular capture as you have already found out.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,696

    Re: Imaging SDK problems

    Indeed, EncodeWithOrientation sounds like something which is applied when encoding the image. When you get an array of pixels, no encoding is involved.
    You can just remap the pixels with a pair of loops, something like
    Code:
    // int orig[] is the original, size is width*height
    int rotated[]=new int[height*width];
    for(int x=0;x<width;x++)
        for(int y=0;y<height;y++)
            rotated[y+x*height]=orig[x+y*width];

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: Imaging SDK problems

    you can use SDK to do it with StepRotationFilter

  5. #5
    Registered User
    Join Date
    Apr 2013
    Posts
    13

    Re: Imaging SDK problems

    I imagine that I will have first to check if the sensor is rotated by using the camera.SensorRotationInDegrees and if it is rotate it probably to the negative of it, right?

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: Imaging SDK problems

    for the preview ? in reality in don't know. Every sample given by microsoft suppose same orientation for the preview picture.
    To rotate the preview buffer i do it :

    Code:
    m_captureDevice.GetPreviewBufferArgb(m_preview.Pixels);
    using (var session = new EditingSession(m_preview.AsBitmap()))
    {
        if (m_cameraType == CameraSensorLocation.Back)
        {
            session.AddFilter(FilterFactory.CreateStepRotationFilter(Rotation.Rotate90));
        }
        else
        {
            session.AddFilter(FilterFactory.CreateStepRotationFilter(Rotation.Rotate270));
            session.AddFilter(FilterFactory.CreateFlipFilter(FlipMode.Horizontal));
        }
    ...
    }

  7. #7
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Re: Imaging SDK problems

    This MSDN article: http://msdn.microsoft.com/en-us/magazine/hh708750.aspx shows a calculation based on the rotation property and sets the Rotation accordingly. However I've not come across a device with a different Camera orientation (although the existence of the Orientation property hints at that being possible).

Similar Threads

  1. Two new imaging competitions.
    By hamishwillee in forum News and Announcements
    Replies: 0
    Last Post: 2013-07-12, 02:14
  2. uses of byte array in imaging??
    By devvvved in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2006-09-26, 00:41
  3. Imaging & Video Player
    By odnalor62 in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-09-21, 11:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×