Prev: Module cam: Onboard Camera
Module cam2: Extended Camera Functions
| | |
| Compatibility of module cam2 |
| Nokia S60 3rd Edition phones and Nokia S60 5th Edition phones. | ok |
|
This module provides extended camera functions for S60 3rd (5th) via the CameraWrapper module, like setting flash and exposure modes, zoom level and performing autofocusing.
- Note 1: To use this module in m, the camera wrapper DLL must be installed on the device (this comes in a separate SISX which can be downloaded from Nokia).
- Note 2: This module should not be used together with module module cam.
- Note 3: module cam2 may not work on some S60 3rd ED FP2 devices.
The functions of module
cam2 are similar to those of module
cam, but not identical. The module
cam2 offers the following functions:
cam2.bright
• function bright() → Number
• function bright(b) → Number
Same as cam.bright - Set and get the brightness.
cam2.contrast
• function contrast() → Number
• function contrast(c) → Number
Same as cam.contrast - Set and get the contrast.
cam2.exposure
• function exposure(null) → Number
• function exposure() → Number
• function exposure(e) → Number
Set and get the exposure mode (see section * ()).
With first parameter null, returns the (theoretically) supported exposure modes (bits).
Without parameter, returns the current exposure mode. With numeric parameter, set the corresponding exposure mode.
cam2.flash
• function flash(null) → Number
• function flash() → Number
• function flash(e) → Number
Set and get the flash mode (see section * ()).
With the first parameter null, returns the (theoretically) supported flash modes (bits).
Without parameter, returns the current flash mode. With a numeric parameter, set the corresponding flash mode.
cam2.focus
• function focus(null) → Number
• function focus(timeout=-1) → Boolean
• function focus(start, range=cam2.focusnormal) → null
Get the supported focus ranges (bits), and perform focusing.
With first parameter null, returns the (theoretically) supported focus ranges (these are often not reliable). A value of 0 indicates that focusing is not supported.
With the first parameter numeric, waits until focusing has completed. If timeout>=0, waits up to that many milliseconds. Returns true if focusing completed, false otherwise.
With the first parameter boolean, starts (start=true) or cancels (start=false) focusing. If start=true, range indicates the focusing range, i.e. one of the bits returned by cam2.focus(null).
cam2.icon
• function icon(on) → Boolean
• function icon(iconOrNull) → Native Object
With a boolean parameter, configures the view finder images to be returned as icons (on=true) or to be drawn directly on the screen (on=false, the default configuration). Returns the previous state of configuration. For information about using icons, see module graph.
With an icon parameter or a null parameter, requests the next view finder image as an icon and returns it. If an icon has been passed, the icon is overwritten with the new image. Note that in order to avoid out of memory problems, the icon returned by the previous call to cam2.icon should be passed again in the next call.
This example draws the view finder with a red rectangle over it:
// turn the camera on
cam2.on()
// configure the view finder for icons
cam2.icon(true)
s=cam2.view()
// initially pass null as icon
i=null
graph.pen(graph.red)
while true do
// get the next view finder frame
i=cam2.icon(i);
// draw it with a red rectangle
graph.put(10, 20, i);
graph.rect(20, 30, s[0]-20, s[1]-20);
graph.show()
end
|
 | Sample m screen |
cam2.index
• function index() → Number
• function index(i) → Number
Same as cam.index - Set and get the selected camera.
cam2.off
• function off() → null
Same as cam.off - Turns the camera off.
cam2.on
• function on(w=640, h=480) → Array
Turns the camera on and prepares it to take images of width (close to) w and height (close to) h. Returns the actual size of the images taken.
cam2.take
• function take(file, quality=75) → Number
Take an image and save it in JPEG/EXIF format with the given JPEG quality.
Returns the size of the created file.
Unlike cam.take, cam2.take does not support taking images as graph.icons. They can however be loaded using graph.icon.
cam2.view
• function view(x=0,y=0,scale=0.25,rotate=0) → Array
• function view(on)) → null
If obtaining view finder contents as an icon has not been configured (see cam2.icon), shows the viewfinder on the current control at x, y, after scaling the image (of the size requested with cam2.on()) by scale and rotating it counterclockwise by rotate degrees (must be a multiple of 90).
If obtaining view finder contents as an icon has been configured, starts requesting view finder contents. Contents (of the size requested with cam2.on()) are scaled by scale and rotated counterclockwise by rotate degrees (must be a multiple of 90). x and y are ignored in this case.
Returns the actual size of the view rectangle.
With a single boolean parameter, turns the view finder on (on=true) or off (on=false).
cam2.zoom
• function zoom() → Number
• function zoom(z)) → Number
Set and get the zoom level.
Without parameter, returns the current zoom level.
With parameter, sets the current zoom level to z, and returns the old level.
cam2 Constants
Number of available cameras (same as cam.count):
• const count =
Known exposure modes:
• const exposureauto =
• const exposurenight =
• const exposurebacklight =
• const exposurecenter =
• const exposuresport =
• const exposurelong =
• const exposuresnow =
• const exposurebeach =
• const exposureprogram =
• const exposureaperture =
• const exposureshutter =
• const exposuremanual =
• const exposuresupernight =
• const exposureinfra =
Known flash modes:
• const flashnone =
• const flashauto =
• const flashforced =
• const flashfillin =
• const flashredeye =
• const flashatstart =
• const flashatend =
Known focus ranges:
• const focusmacro =
• const focusportrait =
• const focusnormal =
• const focusinfinite =
Next: Module video: Playing and Recording Videos© 2004-2011 airbit AG, CH-8008 Zürich
Document AB-M-LIB-888