# Camera Library Overview

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

## Basic Camera Specifications

The basic camera specifications are listed below.

- Aperture: F2.8 (fixed)
- Angles of view (when photographing at maximum resolution):
  Diagonal: 66°
  Horizontal: approximately 54°
  Vertical: approximately 42°
- Depth of field: 20cm to infinity (Pan focus. Cameras do not contain a macro switch.)
- Maximum resolution: VGA
- Maximum frame rate: 30 fps (fps: frames per second)
- Output format: YCrYCb (a YUV->RGB conversion circuit also makes it possible to output in RGB555)
- Resolution settings (supports fast configuration changes)
- Frame rate settings
- Effect processing (supports fast configuration changes)
- Flipping (supports fast configuration changes)
- Photo mode settings
- White balance settings
- Exposure settings
- Sharpness setting

Of these specifications, Resolution, Effects, and Flipping are capable of handling two contexts for each camera. It can be faster to switch contexts than to set the specifications 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 are rounded off if they are less than 0 or more than 255. Then they are scaled to the range [0-31], after which they are in RGB555 format.
The formulas for the reverse conversion (that is, 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

2009/06/09 Updated Basic Camera Specifications.
2008/10/06 Described the Camera library's CODEC mode restrictions.
2008/09/11 Added a description of the camera's initial values.
2008/04/21 Added photo mode to the camera's initial values.
2008/03/17 Added a description of operations during hardware reset and during sleep mode.
2007/11/14 Initial version.

CONFIDENTIAL