# Camera Library: Overview

The TWL system includes two cameras. Although cameras can be controlled separately, it is not possible to obtain images from both cameras simultaneously.
The camera library cannot be used in CODEC-DS mode. Always use CODEC-TWL mode.
Use the API to control camera operations.

## Basic Camera Specifications

The basic camera specifications are listed below.

- Aperture: F2.8 (Fixed)
- Focal length: 20 cm–infinity
- Maximum resolution: VGA (variable)
- Maximum frame rate: 30 fps (fps: frames per second)
- Output format: YCrCb422 (RGB conversion circuit available)
- Effect processing
- Flipping
- Capture mode setting
- White balance setting
- Exposure (illumination time) setting
- Sharpness setting

Of these, the resolution, effect, and flipping are handled in two contexts for each camera. It can be faster to switch contexts than to set these separately.
The library automatically puts the cameras in standby mode when the hardware is reset or put to sleep. To enable the camera after recovering from sleep, the application must implement the process.

## Default Camera Settings

Contexts handle the following default values when the cameras are started (when the `CAMERA_Init` function is called).

Inner Camera: Context A

Resolution | CAMERA_SIZE_DS_LCD
Effect | CAMERA_EFFECT_NONE
Flipping | CAMERA_FLIP_HORIZONTAL

Inner Camera: Context B

Resolution | CAMERA_SIZE_VGA
Effect | CAMERA_EFFECT_NONE
Flipping | CAMERA_FLIP_HORIZONTAL

Outer Camera: Context A

Resolution | CAMERA_SIZE_DS_LCD
Effect | CAMERA_EFFECT_NONE
Flipping | CAMERA_FLIP_NONE

Outer Camera: Context B

Resolution | CAMERA_SIZE_VGA
Effect | CAMERA_EFFECT_NONE
Flipping | CAMERA_FLIP_NONE

By default, both the inner and outer cameras are in context A.
Contexts do not handle the following default values.

Inner Camera

Frame rate | CAMERA_FRAME_RATE_15
Photo mode | CAMERA_PHOTO_MODE_PORTRAIT

Outer Camera

Frame rate | CAMERA_FRAME_RATE_15
Photo mode | CAMERA_PHOTO_MODE_NORMAL

Common settings for the inner and outer cameras take the following default values.

Output Format | CAMERA_OUTPUT_YUV
Number of Lines to Transfer | 1 line

See the links for specific descriptions of the parameter meanings.

## RGB Conversion

The camera gets image data in the YCrYCb (YUV4:2:2) format or the RGB (RGB5:5:5) format.
YUV422 is converted into RGB8:8:8 as follows.

    R = 1.000 x Y                     + 1.402 x (V - 128)
    G = 1.000 x Y - 0.344 x (U - 128) - 0.714 x (V - 128)
    B = 1.000 x Y + 1.772 x (U - 128)

The results of the calculation will be rounded off if they are less than 0 or exceed 255. Then they will be scaled to the range [0–31], after which they will be in RGB555 format.
The formulas for the reverse conversion (i.e., converting RGB555 to YUV422) are shown below:

    Y =  0.299 x R + 0.587 x G + 0.114 x B
    U = -0.169 x R - 0.331 x G + 0.500 x B + 128
    V =  0.500 x R - 0.419 x G - 0.081 x B + 128

## See Also

`CAMERA Function List
`

## Revision History

2008/10/06 Described camera library CODEC mode restrictions.
2008/09/11 Added a description of initial values of the camera.
2008/04/21 Added shooting mode for initial values of camera settings.
2008/03/17 Added a description of operations during hardware reset and during sleep mode.
2007/11/14 Initial version.

CONFIDENTIAL