From 6de83f98c5f4d5fb696f413aa9dbe49ab4515661 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 17 Mar 2011 15:38:38 +0100 Subject: Expose grab-by-callback via camera and add asynchronous grabbing example --- src/uca-cam.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/uca-cam.h') diff --git a/src/uca-cam.h b/src/uca-cam.h index 822f011..ca80ec9 100644 --- a/src/uca-cam.h +++ b/src/uca-cam.h @@ -128,6 +128,28 @@ typedef uint32_t (*uca_cam_start_recording) (struct uca_camera *cam); */ typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera *cam); +/** + * Function pointer to a grab callback. + * + * Register such a callback function with uca_cam_register_callback() to + * receive data as soon as it is delivered. + * + * \param[in] image_number Current frame number + * + * \param[in] buffer Image data + */ +typedef void (*uca_cam_grab_callback) (uint32_t image_number, void *buffer); + +/** + * Register callback for given frame grabber. To actually start receiving + * frames, call uca_grabber_acquire(). + * + * \param[in] grabber The grabber for which the callback should be installed + * + * \param[in] cb Callback function for when a frame arrived + */ +typedef uint32_t (*uca_cam_register_callback) (struct uca_camera *cam, uca_cam_grab_callback cb); + /** * \brief Grab one image from the camera * @@ -182,6 +204,13 @@ typedef struct uca_camera { */ uca_cam_grab grab; + /** + * Method to register an frame acquisition callback. + * + * \see uca_cam_register_callback + */ + uca_cam_register_callback register_callback; + /* Private */ /** * Method to close the camera. @@ -189,11 +218,13 @@ typedef struct uca_camera { */ uca_cam_destroy destroy; - struct uca_grabber *grabber; /**< grabber associated with this camera */ - enum uca_cam_state state; /**< camera state */ + /* private */ + struct uca_grabber *grabber; /**< grabber associated with this camera */ + enum uca_cam_state state; /**< camera state */ uint32_t frame_width; /**< current frame width */ uint32_t frame_height; /**< current frame height */ uint32_t current_frame; /**< last grabbed frame number */ + uca_cam_grab_callback callback; void *user; /**< private user data to be used by the camera driver */ } uca_camera_t; -- cgit v1.2.3