summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;