Go to the documentation of this file.00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <math.h>
00004 #include <assert.h>
00005 #include <FCam/N900.h>
00006
00009
00010 namespace Plat = FCam::N900;
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 int main(int argc, char ** argv) {
00023
00024
00025 Plat::Sensor sensor;
00026 Plat::Lens lens;
00027
00028
00029 sensor.attach(&lens);
00030
00031
00032 lens.setFocus(lens.nearFocus(), lens.maxFocusSpeed());
00033 while (lens.focusChanging());
00034
00035
00036
00037 FCam::Shot shot1;
00038
00039 FCam::Lens::FocusAction sweep(&lens);
00040
00041 sweep.time = 0;
00042 sweep.focus = lens.farFocus();
00043 sweep.speed = lens.maxFocusSpeed()/4;
00044
00045
00046 float duration = 1000000.0f *
00047 (lens.nearFocus() - lens.farFocus()) / sweep.speed;
00048
00049 printf("The lens will sweep from near to far in %f milliseconds\n",
00050 duration / 1000.0);
00051
00052
00053 shot1.exposure = duration;
00054 shot1.gain = 1.0f;
00055
00056 shot1.image = FCam::Image(640, 480, FCam::UYVY);
00057
00058
00059 shot1.addAction(sweep);
00060
00061
00062 sensor.capture(shot1);
00063 assert(sensor.shotsPending() == 1);
00064
00065
00066 FCam::Frame frame = sensor.getFrame();
00067 assert(frame.shot().id == shot1.id);
00068
00069
00070 const FCam::Lens::Tags lensTags(frame);
00071 printf("Aperture : %.4f\n", lensTags.aperture);
00072 printf("Initial focus : %.4f\n", lensTags.initialFocus);
00073 printf("Final focus : %.4f\n", lensTags.finalFocus);
00074
00075
00076 if (argc > 1) FCam::saveJPEG(frame, argv[1]);
00077
00078 assert(sensor.framesPending() == 0);
00079 assert(sensor.shotsPending() == 0);
00080 }