summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-10-20 17:25:53 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-10-20 17:25:53 +0200
commit7e1ec3056d1fdb6786c452ba6ed7e978355a98c2 (patch)
tree3e423903d8ad51c115db17f699e071a162447c24
parentf3fdc154a50516dc969942594e884cd0be0b29d0 (diff)
downloadlibuca-7e1ec3056d1fdb6786c452ba6ed7e978355a98c2.tar.gz
libuca-7e1ec3056d1fdb6786c452ba6ed7e978355a98c2.tar.bz2
libuca-7e1ec3056d1fdb6786c452ba6ed7e978355a98c2.tar.xz
libuca-7e1ec3056d1fdb6786c452ba6ed7e978355a98c2.zip
Add: auto transfer property and readout function
-rw-r--r--src/cameras/pco.c30
-rw-r--r--src/uca-cam.h1
-rw-r--r--src/uca.c11
-rw-r--r--src/uca.h15
-rw-r--r--test/grab.c2
5 files changed, 56 insertions, 3 deletions
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index e7ef365..cfaa573 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -90,6 +90,9 @@ static uint32_t uca_pco_set_property(struct uca_camera_priv *cam, enum uca_prope
case UCA_PROP_DELAY:
return uca_pco_set_delay(cam, (uint32_t *) data);
+ case UCA_PROP_GRAB_AUTO:
+ return pco_set_auto_transfer(GET_PCO(cam), *(uint32_t *) data);
+
case UCA_PROP_TRIGGER_MODE:
/* XXX: We have a 1:1 mapping between UCA_TRIGGER_* and
* TRIGGER_MODE_*
@@ -224,6 +227,16 @@ static uint32_t uca_pco_get_property(struct uca_camera_priv *cam, enum uca_prope
uca_set_void(data, uint32_t, 16);
break;
+ case UCA_PROP_GRAB_AUTO:
+ {
+ int value = 0;
+ uint32_t err = pco_get_auto_transfer(pco, &value);
+ if (err != PCO_NOERROR)
+ return UCA_ERR_CAMERA | UCA_ERR_PROP | UCA_ERR_INVALID;
+ uca_set_void(data, uint32_t, value);
+ }
+ break;
+
case UCA_PROP_GRAB_TIMEOUT:
{
uint32_t timeout;
@@ -278,14 +291,26 @@ static uint32_t uca_pco_grab(struct uca_camera_priv *cam, char *buffer, void *me
return err;
if (GET_PCO_DESC(cam)->type == CAMERATYPE_PCO_EDGE)
- /* GET_PCO(cam)->reorder_image((uint16_t *) buffer, frame, cam->frame_width, cam->frame_height); */
- ;
+ pco_get_reorder_func(GET_PCO(cam))((uint16_t *) buffer, frame, cam->frame_width, cam->frame_height);
else
memcpy(buffer, (char *) frame, cam->frame_width * cam->frame_height * 2);
return UCA_NO_ERROR;
}
+static uint32_t uca_pco_readout(struct uca_camera_priv *cam)
+{
+ uint16_t active_segment;
+ uint32_t num_images = 0;
+ pco_handle pco = GET_PCO(cam);
+
+ /* TODO: error handling */
+ pco_get_active_segment(pco, &active_segment);
+ pco_get_num_images(pco, active_segment, &num_images);
+ pco_read_images(pco, active_segment, 1, num_images);
+ return UCA_NO_ERROR;
+}
+
static uint32_t uca_pco_register_callback(struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user)
{
if (cam->callback == NULL) {
@@ -330,6 +355,7 @@ uint32_t uca_pco_init(struct uca_camera_priv **cam, struct uca_grabber_priv *gra
uca->stop_recording = &uca_pco_stop_recording;
uca->trigger = &uca_pco_trigger;
uca->grab = &uca_pco_grab;
+ uca->readout = &uca_pco_readout;
uca->register_callback = &uca_pco_register_callback;
/* Prepare camera for recording */
diff --git a/src/uca-cam.h b/src/uca-cam.h
index 8b6fc0d..1e51c6d 100644
--- a/src/uca-cam.h
+++ b/src/uca-cam.h
@@ -47,6 +47,7 @@ typedef struct uca_camera_priv {
uint32_t (*trigger) (struct uca_camera_priv *cam);
uint32_t (*register_callback) (struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user);
uint32_t (*grab) (struct uca_camera_priv *cam, char *buffer, void *meta_data);
+ uint32_t (*readout) (struct uca_camera_priv *cam);
struct uca_grabber_priv *grabber; /**< grabber associated with this camera */
enum uca_cam_state state; /**< camera state handled in uca.c */
diff --git a/src/uca.c b/src/uca.c
index ec8ad07..191092c 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -86,6 +86,7 @@ static struct uca_property property_map[UCA_PROP_LAST+1] = {
{ "Gain.ADC.Step", uca_na, uca_uint32t, uca_read },
{ "Grabber.Timeout", uca_s, uca_uint32t, uca_readwrite },
{ "Grabber.Synchronous", uca_bool, uca_uint32t, uca_readwrite },
+ { "Grabber.Auto", uca_bool, uca_uint32t, uca_readwrite },
{ "Mode.Timestamp", uca_na, uca_uint32t, uca_readwrite },
{ "Mode.Scan", uca_na, uca_uint32t, uca_readwrite },
{ "Mode.Hotpixel", uca_na, uca_uint32t, uca_readwrite },
@@ -331,3 +332,13 @@ uint32_t uca_cam_grab(struct uca_camera *cam, char *buffer, void *meta_data)
return priv->grab(priv, buffer, meta_data);
}
+uint32_t uca_cam_readout(struct uca_camera *cam)
+{
+ struct uca_camera_priv *priv = cam->priv;
+ if (priv->state == UCA_CAM_RECORDING)
+ return UCA_ERR_CAMERA | UCA_ERR_IS_RECORDING;
+ if (priv->readout == NULL)
+ return UCA_ERR_CAMERA | UCA_ERR_NOT_IMPLEMENTED;
+ return priv->readout(priv);
+}
+
diff --git a/src/uca.h b/src/uca.h
index e1e0ae1..03d0f4f 100644
--- a/src/uca.h
+++ b/src/uca.h
@@ -108,6 +108,7 @@ enum uca_property_ids {
/* grabber specific */
UCA_PROP_GRAB_TIMEOUT,
UCA_PROP_GRAB_SYNCHRONOUS,
+ UCA_PROP_GRAB_AUTO,
/* pco.edge specific */
UCA_PROP_TIMESTAMP_MODE,
@@ -295,6 +296,7 @@ extern const char *uca_unit_map[]; /**< maps unit numbers to corresponding
#define UCA_ERR_NOT_RECORDING 0x10000008
#define UCA_ERR_FRAME_TRANSFER 0x10000009
#define UCA_ERR_ALREADY_REGISTERED 0x1000000A
+#define UCA_ERR_NOT_IMPLEMENTED 0x1000000B
struct uca_camera_priv;
/**
@@ -462,6 +464,19 @@ uint32_t uca_cam_register_callback(struct uca_camera *cam, uca_cam_grab_callback
*/
uint32_t uca_cam_grab(struct uca_camera *cam, char *buffer, void *meta_data);
+/**
+ * \brief Initiate read out for recording based cameras like pco.dimax or
+ * Photron SAx
+ *
+ * This function merely starts read out and requires that recording has stopped
+ * with uca_cam_stop_recording. To retrieve the image data, you have still have
+ * to use uca_cam_grab.
+ *
+ * \param[in] cam A uca_camera object
+ * \return Error code
+ */
+uint32_t uca_cam_readout(struct uca_camera *cam);
+
#define uca_set_void(p, type, value) { *((type *) p) = (type) value; }
#ifdef __cplusplus
diff --git a/test/grab.c b/test/grab.c
index 6ade84a..59a4fb3 100644
--- a/test/grab.c
+++ b/test/grab.c
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
int counter = 0;
while ((error == UCA_NO_ERROR) && (counter < 20)) {
- handle_error(uca_cam_grab(cam, (char *) buffer, NULL));
+ error = uca_cam_grab(cam, (char *) buffer, NULL);
snprintf(filename, FILENAME_MAX, "frame-%08i.raw", counter++);
FILE *fp = fopen(filename, "wb");
fwrite(buffer, width*height, pixel_size, fp);