112 | | The following test program is supplied with `libuca` and demonstrates the general functionality of the library: |
113 | | |
114 | | {{{ |
115 | | #!c |
116 | | #include <stdio.h> |
117 | | #include <stdlib.h> |
118 | | #include "uca.h" |
119 | | #include "uca-cam.h" |
120 | | |
121 | | int main(int argc, char *argv[]) |
122 | | { |
123 | | struct uca_t *uca = uca_init(); |
124 | | if (uca == NULL) |
125 | | return 1; |
126 | | |
127 | | /* take first camera */ |
128 | | struct uca_camera_t *cam = uca->cameras; |
129 | | |
130 | | uint32_t val = 5000; |
131 | | cam->set_property(cam, UCA_PROP_EXPOSURE, &val); |
132 | | val = 0; |
133 | | cam->set_property(cam, UCA_PROP_DELAY, &val); |
134 | | |
135 | | uint32_t width, height; |
136 | | cam->get_property(cam, UCA_PROP_WIDTH, &width); |
137 | | cam->get_property(cam, UCA_PROP_HEIGHT, &height); |
138 | | |
139 | | uca_cam_alloc(cam, 20); |
140 | | uint16_t *buffer = (uint16_t *) malloc(width * height * 2); |
141 | | |
142 | | cam->start_recording(cam); |
143 | | cam->grab(cam, (char *) buffer); |
144 | | cam->stop_recording(cam); |
145 | | uca_destroy(uca); |
146 | | |
147 | | FILE *fp = fopen("out.raw", "wb"); |
148 | | fwrite(buffer, width*height, 2, fp); |
149 | | fclose(fp); |
150 | | |
151 | | free(buffer); |
152 | | return 0; |
153 | | } |
154 | | }}} |
155 | | |
| 112 | * `enum` lists the available property of a camera |
| 113 | * `grab` tries to record twenty frames |
| 114 | * `control` is GUI to change properties and show frames |