10-31-2012 06:58 AM
I want to set aspect ratio of the camera control. Is there any method avaible to do this?
I am using custom control of camera. https://developer.blackberry.com/cascades/referenc
11-02-2012 05:16 PM
According to the docs:
"The camera preview is displayed and scaled to fit within this control's display area while maintaining its aspect ratio. Setting this control's width and height to values coinciding with the aspect ratio of the capture resolution will display this control with its display area completely filled."
The camera tends to only support 16:9 and 4:3 aspect ratios, so it sounds like if you set the width & height of the control accordingly, then it should just work. You can poke around at supportedCaptureResolutions() and use that to determine the supported aspect ratios.
If this doesn't work for you, I can ping the appropriate folks.
11-05-2012 01:41 AM - edited 11-05-2012 01:44 AM
supportedCaptureResolutions() returns null.
( QVariantList resolutions = camera->supportedCaptureResolutions(
We tried following ways..
// horizontalAlignment: HorizontalAlignment.Fill
// verticalAlignment: VerticalAlignment.Fill Not Working
preferredHeight: 1280 //1200
preferredWidth: 768 //675
Camera *camera = root->findChild<Camera*>("myCamera"); Not Working
CameraSettings* cameraSettings = new CameraSettings(); Not Working
cameraSettings->setCameraMode(CameraMode::Video); Working fullscreen view in case of Video Mode
11-05-2012 10:59 AM
Okay.. I've asked the folks who maintain the Cascades API to have a look at this.
I'm going to spit out a few notes here first though...
-768x1280 is not a supported camera preview resolution. the supported resolutions are 720x1280 and 600x800.
-the capture resolutions should be returning LARGE numbers (eg. 1836x3264, 2448x3264, 1152x2048, 1536x2048).
-is it possible you are in video mode? capture is not supported in video mode, so that may explain why supportedCaptureResolutions() returned null?
-have you tried just setting your aspect ratio to exactly 3:4 or 9:16 sizes (or 4:3 / 16:9)? 1280x768 is not 16:9, so maybe that is why you were having grief? the docs led me to believe that it would magically adjust based on window size, and maybe they are being strict on aspect ratio matching, instead of applying a "close enough" check. There should really be a way to interrogate what is possible though, and I will follow up with the appropriate guys.
11-05-2012 11:24 AM
here's the reply I got from the Cascades API guys:
The aspect ratio should be determined from the capture resolution that is used, we will set the viewfinder resolution to match the aspect ratio of the captured image and also size the vf window accordingly. I’m assuming they are not getting valid capture resolutions because the camera isn’t opened yet (this is mentioned in the function header). They need to connect a slot to the Camera::cameraOpened signal and then call Camera::supportedCaptureResolutions in there or ensure in another way (using a state machine) that the camera has opened before calling that function.
11-06-2012 02:07 AM - edited 11-06-2012 02:07 AM
I'm getting null from supportedCaptureResolutions() when the mode is Photo only. And I'm calling it after opening camera.
Applying 16:9 ratio also didn't provide full screen camera view, I tried: preferredHeight: 1280, preferredWidth: 720 for camera component inside QML.
I tried setting capture resolution also. (before and after camera opening both)
Camera *camera = root->findChild<Camera*>("myCamera"); CameraSettings* cameraSettings = new CameraSettings(); cameraSettings->setCameraMode(CameraMode::Photo); cameraSettings->setCaptureResolution(QSize(1152,2048)); //camera has not preferred height/width set in QML // QSize(1536,2048) camera->applySettings(cameraSettings); camera->open(CameraUnit::Rear); QVariantList resolutions = camera->supportedCaptureResolutions( bb::cascades::multimedia::CameraMode::Photo); qDebug() << "resolutions: " << resolutions;
But no change.
11-06-2012 10:19 AM
it's expected that a 16:9 viewfinder will not fill the screen completely because the screen resolution is not exactly 16:9 on dev alpha.
In your code sample, you applied the settings before opening the camera. Have you check the error codes returned by the functions you're calling?
Also, I'm not sure if that's the correct way to change settings. I haven't played with the Cascades API, so I'm not 100% familiar with the usage, but aren't you supposed to read the settings, make the changes, and then apply them? Again, all of this has to be done after opening a camera because the settings for the front and rear cameras differ.
I can ping the Cascades guys again, but please try out my suggestions first.
11-20-2012 03:30 PM
I've noticed in any QML based sample application that uses the camera shows the veiwfinder like in the picture above (not full screen) but the samples using C++ display the viewfinder in the full window, i've looked through several camera apps and could find nothing in the c++ verions that differed from the QML versions they both stated the viewfinder should fill its container area.....
So is it even possible to display the viewfinder in the entire window using QML? or should we just create the camera component(s) in C++
11-20-2012 07:01 PM - edited 11-20-2012 07:04 PM
Let me give you the appropriate background and explain what you are seeing...
The specs for the camera call for 4:3 and 16:9 viewfinder support on all devices. 16:9 is a standard HDTV (ATSC I believe) aspect-ratio, and 4:3 is a standard NTSC aspect ratio.
The specs for BB10 devices call for either 1:1 screens or 16:9 screens for all future devices.
The FIRST devices (Dev Alpha, Dev Alpha B, and the first BB10 phones) will not be meeting this display aspect ratio spec, but will instead ship with resolutions of 1280x768. This is actually a 15:9 aspect ratio. This has been shared publicly via the devblog or similar. (sorry, I don't have the link handy).
So, what you are seeing from the Cascades API is that it is providing an in-spec 16:9 viewfinder. The problem is that the screen is actually 15:9, so you will be seeing a 24 pixel crop on each side of a full-screen viewfinder.
The native C examples that I published may appear to be using the full screen, but that it because I was being lazy and didn't bother to properly define the window dimensions.. instead, I was just relying on libscreen to do this for me. So the camera is still operating at 16:9 spec, but the picture is being stretched (distorted) to fit the full 15:9 screen. This is likely not desirable, as it is not presenting the true camera aspect ratio.
So... to answer your question... you should be able to get the Cascades camera to take up the full screen, but to do so, you will effectively have to oversize the window by 6.6666% (eg. set to 768x1366 or so). This will lead to some of the image being cut-off at the top & bottom of the screen, but you will no longer have the black padding to the left & right. This will likely also introduce scaling artifacts.
Hopefully this clarifies the situation.. it all boils down to a requirements mismatch on early hardware which is supposed to be corrected for future BB10 devices.
EDIT: I just noticed you were pointing out bars above and below the viewfinder.. that is slightly different from what I'm describing. If I can find some spare time, I will see if I can slap together some sample code to reproduce that -- I have never used the Cascades camera myself, as that is maintained by a different team. Have you checked Paul Bernhardt's barcode-scanning sample to see if it exhibits this problem?
11-20-2012 07:07 PM
Also, regarding the above sample code, I still don't know why Megha_9_dec is trying to change camera settings prior to opening a camera, which probably explains the problems they are experiencing.