Changes between Version 26 and Version 27 of UnifiedCameraAccess
- Timestamp:
- Mar 1, 2011, 8:56:28 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UnifiedCameraAccess
v26 v27 102 102 #!c 103 103 #include <stdio.h> 104 #include <stdlib.h> 104 105 #include "uca.h" 106 #include "uca-cam.h" 105 107 106 108 int main(int argc, char *argv[]) 107 109 { 108 110 struct uca_t *uca = uca_init(); 109 if (uca == NULL) { 110 printf("Couldn't find a camera\n"); 111 if (uca == NULL) 111 112 return 1; 112 }113 113 114 uint32_t width = 800, height = 600; 115 uca->cam_set_property(uca, UCA_PROP_WIDTH, &width); 116 uca->cam_set_property(uca, UCA_PROP_HEIGHT, &height); 114 /* take first camera */ 115 struct uca_camera_t *cam = uca->cameras; 117 116 118 char camera_name[256] = "foobar"; 119 uca->cam_get_property(uca, UCA_PROP_NAME, camera_name); 117 uint32_t val = 5000; 118 cam->set_property(cam, UCA_PROP_EXPOSURE, &val); 119 val = 0; 120 cam->set_property(cam, UCA_PROP_DELAY, &val); 120 121 121 printf("Camera name: %s\n", camera_name); 122 uint32_t width, height; 123 cam->get_property(cam, UCA_PROP_WIDTH, &width); 124 cam->get_property(cam, UCA_PROP_HEIGHT, &height); 122 125 126 uca_cam_alloc(cam, 20); 127 uint16_t *buffer = (uint16_t *) malloc(width * height * 2); 128 129 cam->start_recording(cam); 130 cam->grab(cam, (char *) buffer); 131 cam->stop_recording(cam); 123 132 uca_destroy(uca); 133 134 FILE *fp = fopen("out.raw", "wb"); 135 fwrite(buffer, width*height, 2, fp); 136 fclose(fp); 137 138 free(buffer); 124 139 return 0; 125 140 }