int main(int argc, char *argv[])
{   dc1394camera_t *pCamera, **pCameras=NULL;
    int iNumCameras;
    dc1394featureset_t xFeatures;
    int i;
    int err=dc1394_find_cameras(&pCameras, &iNumCameras);

    
    JPEGData *pData;
    
    ExifData * pEd;


    if (err!=DC1394_SUCCESS) {
        fprintf( stderr, "Unable to look for cameras\n\n"
            "Please check \n"
            "  - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
            "  - if you have read/write access to /dev/raw1394\n\n");
        exit(1);
    }


    if (iNumCameras<1) {
        fprintf(stderr, "no cameras found :(\n");
        exit(1);
    }
    pCamera=pCameras[0];
    for (i=1;i<iNumCameras;i++)
        dc1394_free_camera(pCameras[i]);
    free(pCameras);

    if(dc1394_get_camera_feature_set(pCamera, &xFeatures)!=DC1394_SUCCESS)
            fprintf(stdout, "unable to get feature set\n");
    else
            printf("camera's feature set retrieved\n");

    createEXIF(&xFeatures, &pEd);  

    

    
    pData = jpeg_data_new_from_file (FILENAME);  
    if (!pData) {
        printf ("Could not load '%s'!\n", FILENAME);
        return (-1);
    }

    printf("Saving EXIF data to jpeg file\n");
    jpeg_data_set_exif_data (pData, pEd);
    printf("Set the data\n");
    jpeg_data_save_file(pData, "foobar2.jpg");

    return 0;

}
Exemple #2
0
int main(int argc, char **argv)
{
    int verbose = 0;
    int one_shot = 1;
    double rate;

    setlinebuf (stdout);
    setlinebuf (stderr);

    char *optstring = "hr:v";
    char c;
    struct option long_opts[] = { 
        { "help", no_argument, 0, 'h' },
        { "rate", required_argument, 0, 'r' },
        { "verbose", no_argument, 0, 'v' },
        { 0, 0, 0, 0 }
    };

    while( (c = getopt_long( argc, argv, optstring, long_opts, 0 )) >= 0 )
    {
        switch( c ) {
            case 'r':
                one_shot = 0;
                rate = strtof (optarg, NULL);
                printf ("Triggering at %f Hz\n", rate);
                break;
            case 'v':
                verbose = 1;
                break;
            case 'h':
            default:
                usage( argv[0] );
                return 1;
        };
    }

    dc1394camera_t ** cameras;
    unsigned int num_cameras = 0;
    dc1394error_t err = dc1394_find_cameras (&cameras, &num_cameras);
    if (err != DC1394_SUCCESS) {
        fprintf (stderr, "Error: %s\n", dc1394_error_strings[err]);
        return 1;
    }

    if (num_cameras == 0) {
        fprintf (stderr, "No cameras found\n");
        return 0;
    }

    dc1394_camera_set_broadcast (cameras[0], DC1394_ON);
    if (verbose)
        printf ("Triggering...\n");
    dc1394_software_trigger_set_power (cameras[0], DC1394_ON);

    if (one_shot)
        goto abort;

    signal (SIGINT, sig_handler);
    while (!do_quit) {
        usleep (1000000 / rate);
        dc1394_software_trigger_set_power (cameras[0], DC1394_ON);
        if (verbose) {
            printf (".");
            fflush (stdout);
        }
    }
    printf ("\n");

abort:
    for (int i = 0; i < num_cameras; i++)
        dc1394_free_camera (cameras[i]);
    free (cameras);
    return 0;
}