summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/grab.c19
1 files changed, 18 insertions, 1 deletions
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 <stdio.h>
+#include <stdlib.h>
#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;
}