summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-21 16:33:40 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-21 16:33:40 +0100
commitc8d39cd185b8ba5fa7e178924b6db9e8819fc528 (patch)
tree02d068d590f167c1bedbbe31a6bc47a6c92508e7
parent2e13f2b9911db58cd3c4a7c06175c1cf2b2ceaf1 (diff)
downloadlibuca-c8d39cd185b8ba5fa7e178924b6db9e8819fc528.tar.gz
libuca-c8d39cd185b8ba5fa7e178924b6db9e8819fc528.tar.bz2
libuca-c8d39cd185b8ba5fa7e178924b6db9e8819fc528.tar.xz
libuca-c8d39cd185b8ba5fa7e178924b6db9e8819fc528.zip
Fix me4 callback grabbing
-rw-r--r--src/grabbers/me4.c2
-rw-r--r--test/grab-async.c37
2 files changed, 27 insertions, 12 deletions
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 874df32..aea67f0 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -154,7 +154,7 @@ uint32_t uca_me4_grab(struct uca_grabber *grabber, void **buffer, uint32_t *fram
static int uca_me4_callback(frameindex_t frame, struct fg_apc_data *apc)
{
- apc->callback(frame, Fg_getImagePtr(apc->fg, frame, PORT_A), apc->meta_data, apc->user);
+ apc->callback(frame, Fg_getImagePtrEx(apc->fg, frame, PORT_A, apc->mem), apc->meta_data, apc->user);
return 0;
}
diff --git a/test/grab-async.c b/test/grab-async.c
index 1e0a90b..5f3694e 100644
--- a/test/grab-async.c
+++ b/test/grab-async.c
@@ -5,9 +5,24 @@
#include "uca.h"
#include "uca-cam.h"
+struct image_props {
+ uint32_t width;
+ uint32_t height;
+ uint32_t bits;
+};
+
void grab_callback(uint32_t image_number, void *buffer, void *meta_data, void *user)
{
- printf("got picture number %i\n", image_number);
+ struct image_props *props = (struct image_props *) user;
+ const int pixel_size = props->bits == 8 ? 1 : 2;
+ char filename[256];
+
+ sprintf(filename, "out-%04i.raw", image_number);
+ FILE *fp = fopen(filename, "wb");
+ fwrite(buffer, props->width * props->height, pixel_size, fp);
+ fclose(fp);
+
+ printf("grabbed picture %i at %p (%ix%i @ %i bits)\n", image_number, buffer, props->width, props->height, props->bits);
}
int main(int argc, char *argv[])
@@ -21,25 +36,25 @@ int main(int argc, char *argv[])
/* take first camera */
struct uca_camera *cam = u->cameras;
- uint32_t val = 1;
+ uint32_t val = 5000;
cam->set_property(cam, UCA_PROP_EXPOSURE, &val);
val = 0;
cam->set_property(cam, UCA_PROP_DELAY, &val);
- val = 10;
- cam->set_property(cam, UCA_PROP_FRAMERATE, &val);
- uint32_t width, height, bits;
- cam->get_property(cam, UCA_PROP_WIDTH, &width, 0);
- cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0);
- cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0);
+ struct image_props props;
+ cam->get_property(cam, UCA_PROP_WIDTH, &props.width, 0);
+ cam->get_property(cam, UCA_PROP_HEIGHT, &props.height, 0);
+ cam->get_property(cam, UCA_PROP_BITDEPTH, &props.bits, 0);
uca_cam_alloc(cam, 10);
- cam->register_callback(cam, &grab_callback, NULL);
+ cam->register_callback(cam, &grab_callback, &props);
cam->start_recording(cam);
- printf("waiting for 5 seconds\n");
- sleep(5);
+ printf("grabbing for 2 seconds\n");
+ sleep(2);
cam->stop_recording(cam);
+ printf("done\n");
+ fflush(stdout);
uca_destroy(u);
return 0;