From 28873ccf3f3f32486049eb40cd639bbab86e09dc Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 28 Feb 2011 17:48:55 +0100 Subject: Start grab interface --- test/grab.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test/grab.c') diff --git a/test/grab.c b/test/grab.c index 91a3cdc..34453da 100644 --- a/test/grab.c +++ b/test/grab.c @@ -1,5 +1,6 @@ #include +#include #include "uca.h" #include "uca-cam.h" @@ -19,9 +20,25 @@ int main(int argc, char *argv[]) val = 0; cam->set_property(cam, UCA_PROP_DELAY, &val); + uint32_t width, height; + cam->get_property(cam, UCA_PROP_WIDTH, &width); + cam->get_property(cam, UCA_PROP_HEIGHT, &height); + printf("Image dimensions: %ix%i\n", width, height); + if (uca_cam_alloc(cam, 20) != UCA_NO_ERROR) printf("Couldn't allocate buffer memory\n"); - + + uint16_t *buffer = (uint16_t *) malloc(width * height * 2); + + cam->start_recording(cam); + cam->grab(cam, (char *) buffer, width*height*2); + cam->stop_recording(cam); uca_destroy(uca); + + FILE *fp = fopen("out.raw", "wb"); + fwrite(buffer, width*height, 2, fp); + fclose(fp); + + free(buffer); return 0; } -- cgit v1.2.3