summaryrefslogtreecommitdiffstats
path: root/test/grab.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-28 17:48:55 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-28 17:48:55 +0100
commit28873ccf3f3f32486049eb40cd639bbab86e09dc (patch)
tree1411086a03efeee7ce8051a362bc2f83ac2a929b /test/grab.c
parentf6f2bafe19fd57c56201e79be6b7692f16f16099 (diff)
downloaduca-28873ccf3f3f32486049eb40cd639bbab86e09dc.tar.gz
uca-28873ccf3f3f32486049eb40cd639bbab86e09dc.tar.bz2
uca-28873ccf3f3f32486049eb40cd639bbab86e09dc.tar.xz
uca-28873ccf3f3f32486049eb40cd639bbab86e09dc.zip
Start grab interface
Diffstat (limited to 'test/grab.c')
-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;
}