summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cameras/pco.c24
-rw-r--r--src/grabbers/me4.c18
-rw-r--r--src/uca-cam.h12
-rw-r--r--src/uca-grabber.h12
-rw-r--r--src/uca.c1
5 files changed, 61 insertions, 6 deletions
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index 2547387..f65eb14 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -83,6 +83,9 @@ static uint32_t uca_pco_set_property(struct uca_camera_t *cam, enum uca_property
case UCA_PROP_DELAY:
return uca_pco_set_delay(cam, (uint32_t *) data);
+ case UCA_PROP_TIMESTAMP_MODE:
+ return pco_set_timestamp_mode(GET_PCO(cam), *((uint16_t *) data));
+
default:
return UCA_ERR_PROP_INVALID;
}
@@ -173,6 +176,23 @@ static uint32_t uca_pco_get_property(struct uca_camera_t *cam, enum uca_property
return UCA_NO_ERROR;
}
+uint32_t uca_pco_start_recording(struct uca_camera_t *cam)
+{
+ struct pco_edge_t *pco = GET_PCO(cam);
+ pco_arm_camera(pco);
+ pco_set_rec_state(pco, 1);
+ cam->grabber->acquire(cam->grabber, -1, true);
+}
+
+uint32_t uca_pco_stop_recording(struct uca_camera_t *cam)
+{
+ pco_set_rec_state(GET_PCO(cam), 0);
+}
+
+uint32_t uca_pco_grab(struct uca_camera_t *cam, char *buffer, size_t n_bytes)
+{
+ cam->grabber->grab(cam->grabber, buffer, n_bytes);
+}
uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
{
@@ -195,7 +215,9 @@ uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
uca->destroy = &uca_pco_destroy;
uca->set_property = &uca_pco_set_property;
uca->get_property = &uca_pco_get_property;
- uca->acquire_image = &uca_pco_acquire_image;
+ uca->start_recording = &uca_pco_start_recording;
+ uca->stop_recording = &uca_pco_stop_recording;
+ uca->grab = &uca_pco_grab;
/* Prepare camera for recording */
pco_set_rec_state(pco, 0);
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 5b46c79..2196172 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
+#include <string.h>
#include <clser.h>
#include <fgrab_struct.h>
#include <fgrab_prototyp.h>
@@ -49,6 +50,21 @@ uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t n_buffers)
return UCA_ERR_PROP_GENERAL;
}
+uint32_t uca_me4_acquire(struct uca_grabber_t *grabber, int32_t n_frames, bool async)
+{
+ if (GET_MEM(grabber) != NULL) {
+ if (Fg_AcquireEx(GET_FG(grabber), 0, n_frames, ACQ_STANDARD, GET_MEM(grabber)) != FG_OK)
+ return UCA_NO_ERROR;
+ }
+ return UCA_ERR_PROP_GENERAL;
+}
+
+uint32_t uca_me4_grab(struct uca_grabber_t *grabber, char *buffer, size_t n_bytes)
+{
+ uint32_t last_frame = Fg_getLastPicNumber(GET_FG(grabber), PORT_A);
+ memcpy(buffer, Fg_getImagePtrEx(GET_FG(grabber), last_frame, PORT_A, GET_MEM(grabber)), n_bytes);
+}
+
uint32_t uca_me4_init(struct uca_grabber_t **grabber)
{
/* FIXME: find out if this board/grabber is running */
@@ -66,6 +82,8 @@ uint32_t uca_me4_init(struct uca_grabber_t **grabber)
uca->set_property = &uca_me4_set_property;
uca->get_property = &uca_me4_get_property;
uca->alloc = &uca_me4_alloc;
+ uca->acquire = &uca_me4_acquire;
+ uca->grab = &uca_me4_grab;
*grabber = uca;
return UCA_NO_ERROR;
diff --git a/src/uca-cam.h b/src/uca-cam.h
index 9f0c057..f9db0b7 100644
--- a/src/uca-cam.h
+++ b/src/uca-cam.h
@@ -47,11 +47,11 @@ typedef uint32_t (*uca_cam_set_property) (struct uca_camera_t *cam, enum uca_pro
*/
typedef uint32_t (*uca_cam_get_property) (struct uca_camera_t *cam, enum uca_property_ids property, void *data);
-/**
- * \brief Acquire one frame
- */
-typedef uint32_t (*uca_cam_acquire_image) (struct uca_camera_t *cam, void *buffer);
+typedef uint32_t (*uca_cam_start_recording) (struct uca_camera_t *cam);
+
+typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera_t *cam);
+typedef uint32_t (*uca_cam_grab) (struct uca_camera_t *cam, char *buffer, size_t n_bytes);
enum uca_cam_state {
@@ -67,7 +67,9 @@ struct uca_camera_t {
/* Function pointers to camera-specific methods */
uca_cam_set_property set_property;
uca_cam_get_property get_property;
- uca_cam_acquire_image acquire_image;
+ uca_cam_start_recording start_recording;
+ uca_cam_stop_recording stop_recording;
+ uca_cam_grab grab;
/* Private */
uca_cam_destroy destroy;
diff --git a/src/uca-grabber.h b/src/uca-grabber.h
index 0ae229d..0e203e1 100644
--- a/src/uca-grabber.h
+++ b/src/uca-grabber.h
@@ -1,6 +1,8 @@
#ifndef __UNIFIED_CAMERA_ACCESS_GRABBER_H
#define __UNIFIED_CAMERA_ACCESS_GRABBER_H
+#include <stdbool.h>
+
/*
* --- virtual methods --------------------------------------------------------
*/
@@ -37,6 +39,14 @@ typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enu
*/
typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_t *grabber, uint32_t n_buffers);
+/**
+ * \brief Begin acquiring frames
+ * \param[in] n_frames Number of frames to acquire, -1 means infinite number
+ * \param[in] async Grab asynchronous if true
+ */
+typedef uint32_t (*uca_grabber_acquire) (struct uca_grabber_t *grabber, int32_t n_frames, bool async);
+
+typedef uint32_t (*uca_grabber_grab) (struct uca_grabber_t *grabber, char *buffer, size_t n_bytes);
struct uca_grabber_t {
@@ -47,6 +57,8 @@ struct uca_grabber_t {
uca_grabber_set_property set_property;
uca_grabber_get_property get_property;
uca_grabber_alloc alloc;
+ uca_grabber_acquire acquire;
+ uca_grabber_grab grab;
/* Private */
void *user;
diff --git a/src/uca.c b/src/uca.c
index 7733411..39b45b4 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -91,6 +91,7 @@ struct uca_t *uca_init()
/* FIXME: we don't only want to take the first one */
if (init(&grabber) != UCA_ERR_INIT_NOT_FOUND)
break;
+ i++;
}
if (grabber == NULL) {