This document gives notes related to using the cameras with the camera library.
A new DMA is used to get images taken by the camera.As a result, note that if the AHB bus is accessed with a higher priority than the DMA used by the camera, such as when a DMA is used elsewhere while the camera is still capturing, camera images may not be transferred in time, and a buffer error may occur.
In general, the following steps are used to start capturing with the camera.
CAMERA_DmaRecvAsync function and prepare for a new DMA transfer.
CAMERA_ClearBuffer function to clear the internal camera buffers.
CAMERA_I2CActivate function to start the inner or outer camera.
CAMERA_StartCapture or CAMERA_Start function to start capturing.
Step 3 may be called before steps 1 or 2.
In the CAMERA_DmaRecvAsync function, the completion callback is invoked when all data (the image for a single frame) is finished being transferred. The callback function must therefore call the CAMERA_DmaRecvAsync function in the same way to get the image for the next frame.
void CameraDmaRecvIntr(void* arg)
{
CAMERA_DmaRecvAsync(... CameraDmaRecvIntr, NULL);
}
...
CAMERA_DmaRecvAsync(... CameraDmaRecvIntr, NULL);
CAMERA_ClearBuffer();
CAMERA_StartCapture();
The callback specified by the CAMERA_SetBufferErrorCallback function is invoked if the camera image is not transferred in time and a buffer error occurs. To recover from a buffer error when one occurs, you must stop capturing, stop the new DMA that was in use, and then start capturing again.
void CameraIntrError(CAMERAResult result)
{
CAMERA_StopCapture();
MI_StopNDma(...);
CAMERA_DmaRecvAsync(...);
CAMERA_ClearBuffer();
CAMERA_StartCapture();
}
...
CAMERA_SetBufferErrorCallback(CameraIntrError);
Only one camera configuration function can be called at once. Therefore, if asynchronous camera configuration functions are called consecutively, the second function call fails.
Some configuration functions cannot be used while the camera is capturing. For specific function names, see the CAMERA_IsBusy function reference. To change parameters using these functions during a camera VSync, for example, the callback for the camera VSync interrupt must first call CAMERA_StopCapture, followed by CAMERA_SetXXX, and finally CAMERA_StartCapture.
Consider the following images: one has been trimmed to 256x192 using a function such as CAMERA_SetTrimmingParamsCenter after CAMERA_SIZE_VGA has been specified to the CAMERA_I2CSize function, and the second has been obtained by specifying CAMERA_SIZE_DS_LCD to the CAMERA_I2CSize function. There is no difference in processing load between these two images because they have the same size and consequently cause the same amount of data to be transferred by a new DMA. However, the smaller-size image after trimming and the smaller-size image with a lower resolution have a different angle of view (field angle). Changing the camera resolution alone does not change the area captured in the image, but the captured area is smaller if trimming is used to reduce the image size.
Even if the CAMERA_StopCapture function has been called and CAMERA_I2Activate(CAMERA_SELECT_NONE) has been run, the CAMERA_IsBusy function returns TRUE when processing to shut down the camera is carried out in a certain order or at a particular timing. This does not pose a problem, though, because the CAMERA_IsBusy function will return FALSE if the inner or outer camera is enabled in this state.
To force the CAMERA_IsBusy function to return FALSE reliably, you must first call the CAMERA_StopCapture function, confirm that the CAMERA_IsBusy function returns FALSE and then run CAMERA_I2CActivate(CAMERA_SELECT_NONE).
The camera automatically enters a standby state, CAMERA_I2CActivate(CAMERA_SELECT_NONE), when it goes into sleep mode. To enable the camera after recovering from sleep, the application must call the CAMERA_I2CActivate function or otherwise implement processing to do so.
By the nature of its design, there is a danger that static electricity, mechanical impacts, and other damage may prevent the camera from getting image data. If one of these events occurs, the camera library automatically restarts. The callback function registered by CAMERA_SetRebootCallback is called after the restart process is complete. Restart processing automatically restores camera settings to their state immediately before the restart, so there is no particular processing for the application to run.
A value of CAMERA_ILLEGAL_STATUS is returned if a camera function is run during a restart. If necessary, retry that function after the callback function set by the CAMERA_SetRebootCallback function has been invoked.
If CAMERA_RESULT_FATAL_ERROR is given as an argument to the callback function, it indicates that the restart process has failed and the camera may be physically damaged.
However, you may be able to recover the camera by switching the power off and on, so we recommend that you display a message to this effect to the user.
Show a message like the one below and do not proceed with any further processes with the DSi camera.
An error has occurred.Press POWER on the DSi to turn the power off and then follow the instructions in the User Guide.」
When certain camera configuration functions are called while the camera is capturing an image, the camera image will occasionally shift.
There is no way to detect this phenomenon. Call the following camera configuration functions only after first stopping capture operations. Start capture operations again only after checking that settings have changed.
- CAMERA_I2CActivate*()
- CAMERA_I2CSize*()
- CAMERA_I2CFrameRate*()
- CAMERA_I2CEffect*()
- CAMERA_I2CFlip*()
- CAMERA_I2CPhotoMode*()
- CAMERA_I2CExposure*()
- CAMERA_I2CAutoExposure()
- CAMERA_I2CAutoWhiteBalance()
- CAMERA_I2CContextSwitch*() (Only when switching from CAMERA_CONTEXT_B to CAMERA_CONTEXT_A)
2009/11/11 Explained occasional shifting of captured images.
2009/01/06 Added information on how to handle CAMERA_RESULT_FATAL_ERROR.
2009/01/05 Revised Description for clarity.
2008/09/11 Initial version.
CONFIDENTIAL