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: 651
Registered: ‎11-29-2011
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!

Please use plain text.
Developer
HorizonXP
Posts: 133
Registered: ‎03-28-2011
My Carrier: Bell

Re: Camera Sample Code

Fantastic! I'm going to start playing with this ASAP and see if I can port it to the PlayBook as well.

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.
Developer
Innovatology
Posts: 1,276
Registered: ‎03-03-2011
My Carrier: Vodafone

Re: Camera Sample Code

Good stuff Sean!

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 651
Registered: ‎11-29-2011
My Carrier: other

Re: Camera Sample Code

Here comes another sample:

 

https://github.com/blackberry/Cascades-Community-Samples/tree/master/NativeCamera

 

This one is called NativeCamera, and contrary to the repository that it is currently checked-in under, this is a non-cascades BB10 example of how to start the camera viewfinder and manipulate the viewfinder window using libscreen. 

 

This is similar to the HelloCamera Cascades demo in that it starts a viewfinder and saves photos to the camera roll when you tap the screen.  To change between front and rear cameras, you will have to modify the code to select a different camera unit.

 

This sample should also work on the 2.1 beta NDK.

 

Cheers,

Sean

Please use plain text.
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Carrier: None

Re: Camera Sample Code

I'm getting all kinds of undefined references linking under 2.1.0 beta SDK.  What am I missing?

 

In function `still_callback':

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:161: undefined reference to `camera_roll_open_photo'

src/main.o: In function `run_state_machine':

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:208: undefined reference to `camera_take_photo'

src/main.o: In function `init_camera':

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:233: undefined reference to `camera_open'

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:240: undefined reference to `_camera_set_photovf_property'

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:246: undefined reference to `camera_start_photo_viewfinder'

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:263: undefined reference to `camera_close'

src/main.o: In function `main':

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:320: undefined reference to `camera_stop_photo_viewfinder'

/Users/kcheung/ndk-2.1.0-workspace/NativeCamera/Device-Debug/../src/main.c:321: undefined reference to `camera_close'

cc: /Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/ntoarm-ld error 1

 

 

Sucroid.com
Sweet Apps for the Fans
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 651
Registered: ‎11-29-2011
My Carrier: other

Re: Camera Sample Code

I will download the 2.1 NDK and give it a go tonight.  You're just missing -lcamapi (libcamapi.so).

If I import it into BB10.0.4 NDK, it works fine.  The NDK is supposed to sort out dependencies as part of the managed build solution.. it's possible the 2.1 NDK is missing this magic.

 

Cheers,

Sean

 

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

Re: Camera Sample Code

FYI, I just updated the github repo.  The .cproject file only was including libcamapi for Device-Release builds instead of all builds. 

I will still verify with the 2.1 NDK.

Please use plain text.
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Carrier: None

Re: Camera Sample Code

I found out what's wrong with the 2.1 NDK.  If you try to add the library using "Add Library" under Project in Momentics (I'm using a Mac, BTW), the library is nowhere to be found.

 

However, if I go to Project->Properties->C/C++ Build->Settings->Tool Settings->QCC Linker->Lbraries and add in camapi, then the project linked fine.

 

So it looks like the list in Add Library needs to be updated.

 

Great sample app!  Now I know what to do with the camera.  The first thing I am going to do is to change the shutter sound to something barely legal, whatever "legal" is. :smileyhappy:

Sucroid.com
Sweet Apps for the Fans
Please use plain text.
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Carrier: None

Re: Camera Sample Code

I am doing an experiment and the results are somewhat unexpected.

 

In the NativeCamera sample, I changed the zorder of the viewfinder to be 1 LESS than the application window (i.e. the view finder appear BELOW the application window) and modified the colour of the application window using the following code in main

 

int attribs[] = { SCREEN_BLIT_COLOR, 0x00FF11, SCREEN_BLIT_GLOBAL_ALPHA, 50, SCREEN_BLIT_END };

    screen_fill(screen_ctx, screen_buf, attribs);

    screen_post_window(screen_win, screen_buf, 1, rect, 0);

 

In theory, this should give a transparent green window on top of the view finder window.  But it doesn't do that.  What is wrong?

Sucroid.com
Sweet Apps for the Fans
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 651
Registered: ‎11-29-2011
My Carrier: other

Re: Camera Sample Code

[ Edited ]

Did you set SCREEN_PROPERTY_TRANSPARENCY for your overlay window?

 

Docs are not very verbose, but here are the available modes:

https://developer.blackberry.com/native/beta/reference/screen_libref/topic/screen_anonymous_enum_at1...

 

Please use plain text.