Updated: October 28, 2024 |
Callbacks are used to asynchronously access camera image data and status information.
You can use callbacks to provide custom code to execute when performing camera operations such as accessing encoded video or viewfinder frames. Using callbacks provides a lot of flexibility to control what occurs in your application when a function executes. For example, you can use callbacks to perform image processing or to save data to disk. Callback functions execute in a separate thread, so you need to be sure that your code is thread-safe through the use of appropriate thread synchronization primitives (mutexes, semaphores, condvars, etc.).
Callbacks are deregistered when the operation started by one of the above functions completes. For example, when the camera_stop_viewfinder() function is invoked, any callbacks registered during the camera_start_viewfinder() function call are deregistered.
These are the callback signatures for various Camera library functions:
void function_name( camera_handle_t, camera_devstatus_t, uint16_t, void* );
camera_handle_t — The handle of the camera invoking the callback.
camera_devstatus_t — The status event that occurred.
uint16_t — Any extra data associated with the status event that occurred.
void* — The user-specified arg argument.
void function_name( camera_handle_t, camera_buffer_t*, void* );
camera_handle_t — The handle of the camera invoking the callback.
camera_buffer_t* — A pointer to a camera_buffer_t structure which describes the video frame. This data is only guaranteed to be valid while your callback function is executing.
void* — The user-specified arg argument.
void function_name( camera_handle_t, camera_buffer_t*, void* );
camera_handle_t — The handle of the camera invoking the callback.
camera_buffer_t* — A pointer to a camera_buffer_t structure which describes the viewfinder frame. This data is only guaranteed to be valid while your callback function is executing.
void* — The user-specified arg argument.
void function_name( camera_handle_t, camera_buffer_t*, void* );
camera_handle_t: The handle of the camera invoking the callback.
camera_buffer_t*: A pointer to a camera_buffer_t structure which describes the encoded frame. This data is only guaranteed to be valid while your callback function is executing.
void*: The user-specified arg argument.
void function_name( camera_handle_t, camera_buffer_t*, void* );
camera_handle_t: The handle of the camera invoking the callback.
camera_buffer_t*: A pointer to a camera_buffer_t structure which describes the encoded frame. This data is only guaranteed to be valid when your callback function executes.
void*: The user-specified arg argument.