summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-16 12:24:35 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-16 12:24:35 +0100
commit426687c80bbc52474a53939d7034d45180adc1f5 (patch)
tree589a722bee8a55d7b0c58be9d55e73bf31530f5d /src
parent42cf4c6d95639b785b5c4f0f704e3552df22ed9e (diff)
downloaduca-426687c80bbc52474a53939d7034d45180adc1f5.tar.gz
uca-426687c80bbc52474a53939d7034d45180adc1f5.tar.bz2
uca-426687c80bbc52474a53939d7034d45180adc1f5.tar.xz
uca-426687c80bbc52474a53939d7034d45180adc1f5.zip
Remember current frame number and remove frame dimensions in dummy.c
Diffstat (limited to 'src')
-rw-r--r--src/cameras/dummy.c30
-rw-r--r--src/cameras/pco.c2
-rw-r--r--src/cameras/pf.c2
-rw-r--r--src/grabbers/me4.c3
-rw-r--r--src/uca-cam.h2
-rw-r--r--src/uca-grabber.h4
6 files changed, 22 insertions, 21 deletions
diff --git a/src/cameras/dummy.c b/src/cameras/dummy.c
index 93952a9..dd96688 100644
--- a/src/cameras/dummy.c
+++ b/src/cameras/dummy.c
@@ -6,11 +6,8 @@
#include "uca-grabber.h"
struct dummy_cam_t {
- uint32_t width;
- uint32_t height;
uint32_t bitdepth;
uint32_t framerate;
- uint32_t current_frame;
char* buffer;
};
@@ -22,17 +19,15 @@ static uint32_t uca_dummy_set_property(struct uca_camera_t *cam, enum uca_proper
return UCA_NO_ERROR;
}
-static uint32_t uca_dummy_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+static uint32_t uca_dummy_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data, size_t num)
{
- struct dummy_cam_t *dummy_cam = (struct dummy_cam_t *) cam->user;
-
switch (property) {
case UCA_PROP_NAME:
- strcpy((char *) data, "dummy");
+ strncpy((char *) data, "dummy", num);
break;
case UCA_PROP_WIDTH:
- set_void(data, uint32_t, dummy_cam->width);
+ set_void(data, uint32_t, cam->frame_width);
break;
case UCA_PROP_WIDTH_MIN:
@@ -44,7 +39,7 @@ static uint32_t uca_dummy_get_property(struct uca_camera_t *cam, enum uca_proper
break;
case UCA_PROP_HEIGHT:
- set_void(data, uint32_t, dummy_cam->height);
+ set_void(data, uint32_t, cam->frame_height);
break;
case UCA_PROP_HEIGHT_MIN:
@@ -67,7 +62,7 @@ static uint32_t uca_dummy_get_property(struct uca_camera_t *cam, enum uca_proper
uint32_t uca_dummy_start_recording(struct uca_camera_t *cam)
{
- GET_DUMMY(cam)->current_frame = 0;
+ cam->current_frame = 0;
return UCA_NO_ERROR;
}
@@ -139,14 +134,14 @@ static const char digits[10][20] = {
0xff, 0xff, 0xff, 0x00 }
};
-static void uca_dummy_print_number(struct dummy_cam_t *dummy, int number, int x, int y)
+static void uca_dummy_print_number(struct dummy_cam_t *dummy, int number, int x, int y, int width)
{
const int digit_width = 4;
const int digit_height = 5;
char *buffer = dummy->buffer;
for (int i = 0; i < digit_width; i++) {
for (int j = 0; j < digit_height; j++) {
- buffer[(y+j)*dummy->width + (x+i)] = digits[number][j*digit_width+i];
+ buffer[(y+j)*width + (x+i)] = digits[number][j*digit_width+i];
}
}
}
@@ -157,16 +152,16 @@ uint32_t uca_dummy_grab(struct uca_camera_t *cam, char *buffer)
dummy->buffer = buffer;
/* print current frame number */
- unsigned int number = dummy->current_frame;
+ unsigned int number = cam->current_frame;
unsigned int divisor = 100000000;
int x = 10;
while (divisor > 1) {
- uca_dummy_print_number(dummy, number / divisor, x, 10);
+ uca_dummy_print_number(dummy, number / divisor, x, 10, cam->frame_width);
number = number % divisor;
divisor = divisor / 10;
x += 5;
}
- dummy->current_frame++;
+ cam->current_frame++;
return UCA_NO_ERROR;
}
@@ -186,10 +181,11 @@ uint32_t uca_dummy_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber
uca->stop_recording = &uca_dummy_stop_recording;
uca->grab = &uca_dummy_grab;
uca->state = UCA_CAM_CONFIGURABLE;
+ uca->frame_width = 320;
+ uca->frame_height = 240;
+ uca->current_frame = 0;
struct dummy_cam_t *dummy_cam = (struct dummy_cam_t *) malloc(sizeof(struct dummy_cam_t));
- dummy_cam->width = 320;
- dummy_cam->height = 240;
dummy_cam->bitdepth = 8;
dummy_cam->framerate = 100;
dummy_cam->buffer = NULL;
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index a789762..0c13ca6 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -215,7 +215,7 @@ uint32_t uca_pco_stop_recording(struct uca_camera_t *cam)
uint32_t uca_pco_grab(struct uca_camera_t *cam, char *buffer)
{
uint16_t *frame;
- uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame);
+ uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame);
if (err != UCA_NO_ERROR)
return err;
/* FIXME: choose according to data format */
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index c1267e3..1ea3d3c 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -174,7 +174,7 @@ uint32_t uca_pf_stop_recording(struct uca_camera_t *cam)
uint32_t uca_pf_grab(struct uca_camera_t *cam, char *buffer)
{
uint16_t *frame;
- uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame);
+ uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame);
if (err != UCA_NO_ERROR)
return err;
/* FIXME: choose according to data format */
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 7bb687b..23eed29 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -131,7 +131,7 @@ uint32_t uca_me4_stop_acquire(struct uca_grabber_t *grabber)
return UCA_NO_ERROR;
}
-uint32_t uca_me4_grab(struct uca_grabber_t *grabber, void **buffer)
+uint32_t uca_me4_grab(struct uca_grabber_t *grabber, void **buffer, uint32_t *frame_number)
{
int32_t last_frame;
if (grabber->asynchronous)
@@ -142,6 +142,7 @@ uint32_t uca_me4_grab(struct uca_grabber_t *grabber, void **buffer)
if (last_frame <= 0)
return UCA_ERR_PROP_GENERAL;
+ *frame_number = last_frame;
*buffer = Fg_getImagePtrEx(GET_FG(grabber), last_frame, PORT_A, GET_MEM(grabber));
return UCA_NO_ERROR;
}
diff --git a/src/uca-cam.h b/src/uca-cam.h
index f668e54..c7e88a2 100644
--- a/src/uca-cam.h
+++ b/src/uca-cam.h
@@ -140,6 +140,7 @@ typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera_t *cam);
* coming from the camera, which the frame grabber is not able to do.
*
* \param[in] buffer Destination buffer
+ *
*/
typedef uint32_t (*uca_cam_grab) (struct uca_camera_t *cam, char *buffer);
@@ -197,6 +198,7 @@ struct uca_camera_t {
enum uca_cam_state state; /**< camera state */
uint32_t frame_width;
uint32_t frame_height;
+ uint32_t current_frame;
void *user; /**< private user data to be used by the camera driver */
};
diff --git a/src/uca-grabber.h b/src/uca-grabber.h
index a10d463..fdcd488 100644
--- a/src/uca-grabber.h
+++ b/src/uca-grabber.h
@@ -94,8 +94,10 @@ typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber_t *grabber);
* This method is usually called through the camera interface and not directly.
*
* \param[in] buffer The pointer of the frame buffer is set here
+ *
+ * \param[out] frame_number Number of the grabbed frame
*/
-typedef uint32_t (*uca_grabber_grab) (struct uca_grabber_t *grabber, void **buffer);
+typedef uint32_t (*uca_grabber_grab) (struct uca_grabber_t *grabber, void **buffer, uint32_t *frame_number);
/**
* Function pointer to a grab callback.