Changes between Version 26 and Version 27 of UnifiedCameraAccess


Ignore:
Timestamp:
Mar 1, 2011, 8:56:28 AM (14 years ago)
Author:
Matthias Vogelgesang
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UnifiedCameraAccess

    v26 v27  
    102102#!c
    103103#include <stdio.h>
     104#include <stdlib.h>
    104105#include "uca.h"
     106#include "uca-cam.h"
    105107
    106108int main(int argc, char *argv[])
    107109{
    108110    struct uca_t *uca = uca_init();
    109     if (uca == NULL) {
    110         printf("Couldn't find a camera\n");
     111    if (uca == NULL)
    111112        return 1;
    112     }
    113113
    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;
    117116
    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);
    120121
    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);
    122125
     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);
    123132    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);
    124139    return 0;
    125140}