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 int main(int argc, char ** argv) {
00021
00022
00023 Plat::Sensor sensor;
00024 Plat::Lens lens;
00025
00026
00027 sensor.attach(&lens);
00028
00029
00030 lens.setFocus(lens.nearFocus(), lens.maxFocusSpeed());
00031 while (lens.focusChanging());
00032
00033
00034
00035 FCam::Shot shot1;
00036
00037 FCam::Lens::FocusAction sweep(&lens);
00038
00039 sweep.time = 0;
00040 sweep.focus = lens.farFocus();
00041 sweep.speed = lens.maxFocusSpeed()/4;
00042
00043 float duration = 1000000.f *
00044 (lens.nearFocus() - lens.farFocus()) / sweep.speed;
00045
00046
00047 shot1.exposure = duration;
00048 shot1.gain = 1.0f;
00049
00050 shot1.image = FCam::Image(640, 480, FCam::UYVY);
00051
00052
00053 shot1.actions.insert(&sweep);
00054
00055
00056 sensor.capture(shot1);
00057 assert(sensor.shotsPending() == 1);
00058
00059
00060 FCam::Frame::Ptr frame = sensor.getFrame();
00061 assert(frame->shot().id == shot1.id);
00062
00063
00064 const FCam::Lens::Tags *lensTags = frame->tags(&lens);
00065 printf("Aperture : %.4f\n", lensTags->aperture);
00066 printf("Initial focus : %.4f\n", lensTags->initialFocus);
00067 printf("Final focus : %.4f\n", lensTags->finalFocus);
00068
00069
00070 if (argc > 1) FCam::saveJPEG(frame, argv[1]);
00071
00072 assert(sensor.framesPending() == 0);
00073 assert(sensor.shotsPending() == 0);
00074 }