00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <assert.h>
00004 #include <FCam/N900.h>
00005 #include <FCam/AutoFocus.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 sensor.attach(&lens);
00026
00027
00028 FCam::AutoFocus autoFocus(&lens);
00029
00030
00031 FCam::Shot stream1;
00032
00033 stream1.exposure = 50000;
00034 stream1.frameTime = 50000;
00035 stream1.gain = 1.0f;
00036
00037
00038 stream1.image = FCam::Image(640, 480, FCam::UYVY);
00039
00040
00041 stream1.sharpness.enabled = true;
00042 stream1.sharpness.size = FCam::Size(16, 12);
00043
00044
00045 int cnt = 0;
00046
00047
00048 sensor.stream(stream1);
00049
00050
00051 autoFocus.startSweep();
00052
00053
00054 FCam::Frame::Ptr frame;
00055
00056 do {
00057
00058 frame = sensor.getFrame();
00059 assert(frame->shot().id == stream1.id);
00060
00061
00062 autoFocus.update(frame);
00063
00064
00065 cnt++;
00066 } while (!autoFocus.idle());
00067
00068
00069 sensor.stopStreaming();
00070 printf("Processed %d frames until autofocus completed!\n", cnt);
00071
00072
00073 while (sensor.shotsPending() > 0) frame = sensor.getFrame();
00074
00075
00076 if (argc > 1) FCam::saveJPEG(frame, argv[1]);
00077
00078
00079 assert(sensor.framesPending() == 0);
00080 assert(sensor.shotsPending() == 0);
00081 }