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: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Camera Sample Code

Hi folks!

I've published the first of several camera samples here:

 

https://github.com/blackberry/Cascades-Community-Samples

 

The app is called HelloCamera and is a BB10 Cascades sample.  This is a very bare-bones camera app which demonstrates how to start a ForeignWindow viewfinder and save photos to the camera rolll.

It will build with the BB10.0.4 NDK and will run on BB10 devices (eg. Dev Alpha).

 

Some of you will notice that libcamapi.so now ships on the 2.1 PlayBook beta firmware, however the 2.1 NDK is not yet released which targets this functionality.  If you are particularly savvy, you can probably get by with the camera_api.h file from the BB10.0.4 NDK and the libcamapi.so file from the 2.1 PlayBook beta firmware until the 2.1 NDK ships out some time later next week.

 

I promise* over the coming weeks to get more samples published -- specifically samples which do not require the use of Cascades.

 

Cheers,

Sean

 

/Disclaimer: *promise may not be an actual promise.. but I'm trying real hard!

//Appologies for the cross-post, but there are 2 relevant forums for this info :smileyhappy:

Please use plain text.
New Contributor
plepleus
Posts: 7
Registered: ‎05-25-2012
My Device: Torch 9850
My Carrier: Verizon Wireless

Re: Camera Sample Code

I must be an idi ot because I've been trying far too long and I can't get your sample code to work.  When I try to build it I get the following error:

MAKEFILE_GENERATORC:\...\ntox86-ld: o-g/.obj/cameraapp.o: undefined reference to symbol 'screen_set_window_property_iv'

make[2]: Leaving directory `C:/.../x86'

C:\...\ntox86-ld: note: 'screen_set_window_property_iv' is defined in DSO

C:/.../libscreen.so.1 so try adding it to the linker command line
make[1]: Leaving directory `C:/...x86'
C:/.../libscreen.so.1: could not read symbols: Invalid operation
cc: C:/.../ntox86-ld caught signal 1

 

Any ideas what I might be doing wrong here?

Please use plain text.
Developer
HorizonXP
Posts: 133
Registered: ‎03-28-2011
My Device: BlackBerry 9900 & PlayBook
My Carrier: Bell

Re: Camera Sample Code

Do you have the latest NDK installed? Did you add it to your path? There should be a script in the NDK to run the necessary commands to add the environment variables.


Founder of Pulsecode Inc. and taab
Authomator - Two-factor authentication codes on BlackBerry 10 - http://www.xitijpatel.com/ - Follow @xitijpatel
Is there a helpful or useful post in this thread? Click the thumbs up on it so that other people can find it more easily!
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Camera Sample Code

Are you using the BB10.0.4 NDK?  Are you building Device-Release?

I can't help but notice that ntox86-ld is being invoked, which leads me to believe you may be doing a simulator build, which I am not supporting.

Please use plain text.
New Contributor
plepleus
Posts: 7
Registered: ‎05-25-2012
My Device: Torch 9850
My Carrier: Verizon Wireless

Re: Camera Sample Code

Yup, there you go, I knew it was something obvious like that, Thanks Sean

Please use plain text.
Contributor
matteob
Posts: 12
Registered: ‎06-11-2012
My Device: 9900
My Carrier: Telus

Re: Camera Sample Code

That is awesome, I am going to go through it and let you know if I find anything.

 

Thanks!

Please use plain text.
Contributor
nico411
Posts: 34
Registered: ‎12-20-2010
My Device: DevAlpha Beta 2
My Carrier: Orange

Re: Camera Sample Code

Did you add the libraries to your .pro project file ?

 

In my app, I've added the following libraries : 

 

LIBS += -lbbsystem -lbbmultimedia -lmmrndclient -lstrm -lasound -lscreen

 

I'm not sure which one is the one you need but I think it's one of them.

Please use plain text.
New Contributor
nhuang
Posts: 8
Registered: ‎09-27-2012
My Device: BB 10 Dev Alpha
My Carrier: Roger

Re: Camera Sample Code

Thanks for your example.

Do you know how to set the image size? Because after I take a photo, I have to display it to Images, but the image size is to large to display on Image View, is possible to set the size as 360*240 or resize the Image file?

 

 

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

Re: Camera Sample Code

The only supported still capture resolutions are full-size.

You would have to resize after it is captured.  Consider decompressing the jpeg buffer, scaling, and recompressing before saving.  The implementation of this is beyond the scope of these samples, but you could do it with libjpeg, libimg, etc.

 

Cheers,

Sean

Please use plain text.
Developer
noahhuang
Posts: 100
Registered: ‎10-01-2012
My Device: BB10 Dev Alpha
My Carrier: Roger

Re: Camera Sample Code

Thanks, I found the way to resize the image

 

// resize image
QImage image;
image.load(copyTo.fileName(), "JPG");
QFile resizedTo(QDir::home().currentPath() + "/app/native/assets/images/vehicle.jpg");
// remove the exist image
if (resizedTo.exists()) {
QDir dir(resizedTo.fileName());
dir.remove(resizedTo.fileName());
}
image.scaled(320, 240, Qt::IgnoreAspectRatio, Qt::FastTransformation).save(resizedTo.fileName(), 0, 100);

Please use plain text.