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
Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
Accepted Solution

Bug in the window creation for Z10?

I have an app called Level Camera.  I have just found out that, through a user report, everything is rotated by 90 degrees.

 

The app works on the PlayBook, Dev Alpha A, B, and C without issues.  After some debugging, I noticed that when a new screen is created for the view finder window, it's rotated 90 but that does not occur in the Dev Alphas and PlayBook.  I'm building the app using the 2.1 SDK.  Why is the Z10 returning a screen that is in landscape when all the Dev Alphas do not do that?  Is this a bug?

Sucroid.com
Sweet Apps for the Fans
BlackBerry Development Advisor
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Bug in the window creation for Z10?

The different Z10 hardware platforms do not support the same level of hardware acceleration with respect to some camera features - namely rotation.

However, the video viewfinder should be usable under all rotations.

Are you using the photo viewfinder or the video one?

 

Care to post your camera_set_videovf_property() config ?

Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook

Re: Bug in the window creation for Z10?

camera_set_photovf_property(handle,
                                      CAMERA_IMGPROP_WIN_GROUPID, vf_group,
                                      CAMERA_IMGPROP_WIN_ID, "my_viewfinder");

 

That's all I have for setting property.

 

What I don't understand is why is the screen created 1280 x 720 instead of something that is in portrait?

Sucroid.com
Sweet Apps for the Fans
BlackBerry Development Advisor
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Bug in the window creation for Z10?

[ Edited ]

Because the photo viewfinder on the QC variants of the Z10 does not support rotation.   (calling camera_get_photo_vf_rotations() would tell you this).

 

Since all cameras are landscape devices, you are getting an unrotated window.  If you were to read back camera_get_photovf_property(handle, CAMERA_IMGPROP_ROTATION, &tempInt);   you will find that on PlayBook and TI hardware (Dev Alphas), it is configured to 0, but on QC Z10 hardware, it will be 90 or 270.

 

If you do not need to capture still images, I recommend switching to using the video viewfinder instead.  The video viewfinder runs at a higher framerate, and has many more resolutions available, and also supports all 4 rotation values.  0 should be the default, but you may want to set CAMERA_IMGPROP_ROTATION to 0 just to be sure.

 

If you want to keep using the photo viewfinder, you can simply read back the CAMERA_IMGPROP_ROTATION value and then apply SCREEN_PROPERTY_ROTATION to the viewfinder window to display correctly.

 

I would suggest that if you switch to video mode,  that you call camera_get_video_vf_resolutions() and pick the smallest resolution that is still larger than your screen resolution, in order to not be too wasteful.  (eg. a 1080p video is wasteful, since it is being downscaled to fit on your 1280x720 screen).  This is not strictly necessary, but will save maybe about 20MB of video memory.

 

Cheers,

Sean

 

 

 

Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook

Re: Bug in the window creation for Z10?

[ Edited ]

err = camera_open(unit, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &handle); if (err != CAMERA_EOK) { fprintf(stderr, "camera_open() failed: %d\n", err); return err; } my_angle = atoi(getenv("ORIENTATION")); fprintf(stderr, "init_camera: my_angle = %d\n", my_angle); err = camera_set_photovf_property(handle, CAMERA_IMGPROP_WIN_GROUPID, vf_group, CAMERA_IMGPROP_WIN_ID, "my_viewfinder"); if (err != CAMERA_EOK) { fprintf(stderr, "camera_set_photovf_property() failed: %d\n", err); } else { err = camera_set_device_orientation(handle, my_angle); camera_get_videovf_property( handle, CAMERA_IMGPROP_WIDTH, &videovf_size[0], CAMERA_IMGPROP_HEIGHT, &videovf_size[1], CAMERA_IMGPROP_ROTATION, &my_angle); fprintf(stderr, "videovf size %d, %d, angle %d\n", videovf_size[0], videovf_size[1], my_angle); err = camera_start_photo_viewfinder(handle, NULL, NULL, NULL);

 

Something is still not making sense.  I had the above routine in the initiatialization of the camera.  my_angle is 0, not 90 or 270 as you mentioned from the Z10.  And the screen created is of size 1280 x 720.

 

After working with camera for almost a year, everything is still as clear as mud. :smileyhappy:

 

EDIT: Looks like I was mixing video and photo.  Problem solved!  Thanks.

Sucroid.com
Sweet Apps for the Fans
BlackBerry Development Advisor
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Bug in the window creation for Z10?

thought I replied to this.. but perhaps not..

 

just wanted to point out that your call to camera_set_device_orientation() is not meant for adjusting viewfinder buffer rotation.  it is solely to help the jpeg encoder and face detector know which way is up.  (and in fact, the navigator's view of orientation may be counter-clockwise, whereas the camera frame of reference is clockwise).

 

camera_set_xxxx_property(... CAMERA_IMGPROP_ROTATION ...) is the correct way to request that buffers be rotated, if supported.

 

and screen_set_window_property(... SCREEN_PROPERTY_ROTATION ...) is the prefered way to adjust the window presentation orientation.

 

Cheers,

Sean