int
main(int argc, char **argv) {
	Camera	*canon;
	int	retval;
	GPContext *canoncontext = sample_create_context();

	gettimeofday(&starttime,NULL);
	gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
	gp_camera_new(&canon);

	/* When I set GP_LOG_DEBUG instead of GP_LOG_ERROR above, I noticed that the
	 * init function seems to traverse the entire filesystem on the camera.  This
	 * is partly why it takes so long.
	 * (Marcus: the ptp2 driver does this by default currently.)
	 */
	printf("Camera init.  Takes about 10 seconds.\n");
	retval = gp_camera_init(canon, canoncontext);
	if (retval != GP_OK) {
		printf("  Retval: %d\n", retval);
		exit (1);
	}
	canon_enable_capture(canon, TRUE, canoncontext);
	/*set_capturetarget(canon, canoncontext);*/
	capture_to_file(canon, canoncontext, "foo.jpg");
	gp_camera_exit(canon, canoncontext);
	return 0;
}
Beispiel #2
0
int cameraFunction(int command) {
    int i, retval, ss, commandint;

    gp_camera_new(&canon);
    canoncontext = gp_context_new();
    gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
    printf("Camera init.  Takes about 3 seconds.\n");
    retval = gp_camera_init(canon, canoncontext);
    if (retval != GP_OK) {
        printf("  Retval: %d\n", retval);
        exit(1);
    } else {
        printf("okay");
    }

    canon_enable_capture(canon, TRUE, canoncontext);


    printf("ready to rock\n");

    //i = getchar();
    //getchar();
    //commandint = atoi(command);
    switch (command) {
    case 'c': {
        capture(canon, canoncontext);
        break;
    }
    case 's': {
        ss = getchar();
        getchar();
        printf("ss is %c\n", ss);
        shutterchange(canon, canoncontext, ss);
        break;
    }
    case 'a': {
        int ap;
        ap = getchar();
        getchar();
        aperturechange(canon, canoncontext, ap);
        printf("aperture: %d", ap);
        break;
    }
    case 'i': {
        int iso;
        iso = getchar();
        getchar();
        isochange(canon, canoncontext, iso);
        printf("iso: %d", iso);
        break;
    }
    case 'l': {
        while (1) {
            liveview(canon, canoncontext);
        }
        break;
    }
    case 'q': {
        gp_camera_exit(canon, canoncontext);
        break;
    }
    default:
        capture(canon, canoncontext);
        return 0;

    }

    return 0;
} //end of code
Beispiel #3
0
int
main(int argc, char **argv) {
	Camera	*canon;
	int	i, retval;
	GPContext *canoncontext = sample_create_context();

	gp_log_add_func(GP_LOG_ERROR, errordumper, 0);
	gp_camera_new(&canon);

	/* When I set GP_LOG_DEBUG instead of GP_LOG_ERROR above, I noticed that the
	 * init function seems to traverse the entire filesystem on the camera.  This
	 * is partly why it takes so long.
	 * (Marcus: the ptp2 driver does this by default currently.)
	 */
	printf("Camera init.  Takes about 10 seconds.\n");
	retval = gp_camera_init(canon, canoncontext);
	if (retval != GP_OK) {
		printf("  Retval: %d\n", retval);
		exit (1);
	}
	canon_enable_capture(canon, TRUE, canoncontext);
	retval = camera_eosviewfinder(canon,canoncontext,1);
	if (retval != GP_OK) {
		fprintf(stderr,"camera_eosviewfinder(1): %d\n", retval);
		exit(1);
	}
	/*set_capturetarget(canon, canoncontext);*/
	printf("Taking 100 previews and saving them to snapshot-XXX.jpg ...\n");
	for (i=0;i<100;i++) {
		CameraFile *file;
		char output_file[32];

		fprintf(stderr,"preview %d\n", i);
		retval = gp_file_new(&file);
		if (retval != GP_OK) {
			fprintf(stderr,"gp_file_new: %d\n", retval);
			exit(1);
		}

		/* autofocus every 10 shots */
		if (i%10 == 9) {
			camera_auto_focus (canon, canoncontext, 1);
			/* FIXME: wait a bit and/or poll events ? */
			camera_auto_focus (canon, canoncontext, 0);
		} else {
			camera_manual_focus (canon, (i/10-5)/2, canoncontext);
		}
#if 0 /* testcase for EOS zooming */
		{
			char buf[20];
			if (i<10) set_config_value_string (canon, "eoszoom", "5", canoncontext);
			sprintf(buf,"%d,%d",(i&0x1f)*64,(i>>5)*64);
			fprintf(stderr, "%d - %s\n", i, buf);
			set_config_value_string (canon, "eoszoomposition", buf, canoncontext);
		}
#endif
		retval = gp_camera_capture_preview(canon, file, canoncontext);
		if (retval != GP_OK) {
			fprintf(stderr,"gp_camera_capture_preview(%d): %d\n", i, retval);
			exit(1);
		}
		sprintf(output_file, "snapshot-%03d.jpg", i);
		retval = gp_file_save(file, output_file);
		if (retval != GP_OK) {
			fprintf(stderr,"gp_camera_capture_preview(%d): %d\n", i, retval);
			exit(1);
		}
		gp_file_unref(file);
	/*
		sprintf(output_file, "image-%03d.jpg", i);
	        capture_to_file(canon, canoncontext, output_file);
	*/
	}
	retval = camera_eosviewfinder(canon,canoncontext,0);
	if (retval != GP_OK) {
		fprintf(stderr,"camera_eosviewfinder(0): %d\n", retval);
		exit(1);
	}

	sleep(10);
	gp_camera_exit(canon, canoncontext);
	return 0;
}