Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: How to adjust the camera preview when screen is rotated?

[ Edited ]

ah.. so if you are doing video recording, then you will need to eventually update the camera properties.. you've got that part right.  you cannot do this while already recording.. just keep that in mind.

 

you do not need to alter the camera resolution, but you will need to alter the libscreen window resolution (swap w/h).

 

the steps would then be:

1. update CAMERA_IMGPROP_ROTATION using camera_set_videovf_rotation() AND camera_set_video_rotation().  these 2 need to be kept in sync when dealing with recordings on a device with CAMERA_FEATURE_PREVIEWISVIDEO.

2. after you've confirmed that the above works, don't bother rotating your screen window.. just update SCREEN_PROPERTY_SIZE on the window to deal with the now rotated buffer being rendered into that window.

 

That should hopefully give you what you want.  You would only bother rotating the screen window if you don't care about rotating the camera buffer.  Still, what you posted earlier probably should have worked.  (I will double check that tonight)

Please use plain text.
Developer
smiley
Posts: 1,417
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to adjust the camera preview when screen is rotated?

Ok. getting closer.

 

Now I can record properly but the viewfinder goes back to portrait as soon as I start the recording and doesn't show landscape.

 

is there such api camera_set_video_rotation()   can't find it in the camera_api.h

 

I do this just before recording and then the view finder switch back to portrait.

 

            if (camera_set_videovf_property(mCameraHandle,
                                            CAMERA_IMGPROP_ROTATION, 90,
                                            CAMERA_IMGPROP_END) != 0)

 

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: How to adjust the camera preview when screen is rotated?

camera_set_video_property() is used to apply the video rotation.  it doesn't do much though on this hardware.  we just have a check to ensure that you specified the same rotation for the vf and the video.

 

Show me the rotation code you are applying when the device rotates (camera & screen), and show me the code you are applying when the recording starts.  Sounds like you are overdoing it.

 

Please use plain text.
Developer
smiley
Posts: 1,417
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to adjust the camera preview when screen is rotated?

when rotation changes

 

    if (m_orientation != oldOrientation)
    {
        angle = (m_orientation -1  )*90;

        screen_set_window_property_iv(mViewfinderWindow->windowHandle(), SCREEN_PROPERTY_ROTATION, &angle);

     }

 

on recording

 

     // 90 just hardcode for testing

            if (camera_set_videovf_property(mCameraHandle,
                                            CAMERA_IMGPROP_ROTATION, 90,
                                            CAMERA_IMGPROP_END) != 0)

thanks

 

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: How to adjust the camera preview when screen is rotated?

OK, there's your problem :smileyhappy:

Remember: these rotations stack up!

To make things look right, you need to either rotate the window OR rotate the camera buffers. (Or actually, do something such that the sum of the rotations adds up to the desired angle:  eg. SCREEN_PROPERTY_ROTATION=180, CAMERA_IMGPROP_ROTATION=270 would give you the same effect as setting either of those to 90).

So when you applied your window rotation, that looked fine.

Then you applied an image rotation.  That means that the total rotation will be the sum of the 2, which is why you are back to portrait again.

 

Since you NEED camera rotation in your case (you are doing video recording), what you should do is just solve the equation:  Rscreen + Rcamera = angle.

 

The other way to deal with this is to always use CAMERA_IMGPROP_ROTATION instead of SCREEN_PROPERTY_ROTATION if you are starting to get confused.  The only reason you may not want to do this is that it will cause the window to blank while buffers are re-allocated.  That, and it takes time.

 

And note that any time you rotate things, you likely need to re-size the screen window, unless you are dealing with a square viewfinder :smileyhappy:

Please use plain text.
Developer
smiley
Posts: 1,417
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to adjust the camera preview when screen is rotated?

I'm really confused now.  Changing the code doesn't work and i'm back to square one.

 

So from the beginning.  Have the following handles

 

mCameraHandle

mViewfinderWindow->windowHandle()

 

I have event to handle rotation change.  When the device is rotated in any direction which handle should I change?

I have tried

 

        camera_set_videovf_property(mCameraHandle,
                                           CAMERA_IMGPROP_ROTATION, &angle,
                                    CAMERA_IMGPROP_END);
and it does not work.

 

If you have time can you do an example?  thanks

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: How to adjust the camera preview when screen is rotated?

I'll see if I can find time on the weekend.

Please use plain text.
Developer
smiley
Posts: 1,417
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to adjust the camera preview when screen is rotated?

hi,

 

did you find any spare time over the weekend?

 

I'm getting really stressed over this. thanks

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: How to adjust the camera preview when screen is rotated?

zero extra time.

The information is already all here in this thread. 

I am under the gun for BB10 deliverables and all of my spare time is currently taken up with preparing content for the conference in 2 weeks.

are you looking for an example using ForeignWindow or libscreen?

Please use plain text.
Developer
smiley
Posts: 1,417
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to adjust the camera preview when screen is rotated?

I'm using ForeignWindowControl in my c++ cascade app.

 

when i rotate the screen i use this call

 

        screen_set_window_property_iv(mViewfinderWindow->windowHandle(), SCREEN_PROPERTY_ROTATION, &angle);

everything works except that the recorded landscape video is not in landscape.

 

so somehow I need to rotate the camera buffer?

 

 

Please use plain text.