• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

tests/testCapabilities.cpp

00001 #include "FCam/N900.h"
00002 #include <vector>
00003 #include <iostream>
00004 
00005 using namespace FCam;
00006 
00007 int main(int argc, char **argv) {
00008     printf("Testing the limits of the N900 sensor. Please leave the lens cover"
00009            " closed for this test.\n");
00010     
00011     N900::Sensor sensor;
00012     Shot shot;
00013     Frame frame;
00014     
00015     
00016     std::vector<Image> targets;
00017     targets.push_back(Image(sensor.minImageSize(), UYVY, Image::AutoAllocate));
00018     targets.push_back(Image(sensor.minImageSize(), RAW, Image::AutoAllocate));
00019     targets.push_back(Image(320, 240, UYVY, Image::AutoAllocate));
00020     targets.push_back(Image(320, 240, RAW, Image::AutoAllocate));
00021     targets.push_back(Image(640, 480, UYVY, Image::AutoAllocate));
00022     targets.push_back(Image(640, 480, RAW, Image::AutoAllocate));
00023     targets.push_back(Image(800, 600, UYVY, Image::AutoAllocate));
00024     targets.push_back(Image(800, 600, RAW, Image::AutoAllocate));
00025     targets.push_back(Image(1280, 960, UYVY, Image::AutoAllocate));
00026     targets.push_back(Image(1280, 960, RAW, Image::AutoAllocate));
00027     targets.push_back(Image(2560, 1920, UYVY, Image::AutoAllocate));
00028     targets.push_back(Image(2560, 1920, RAW, Image::AutoAllocate));
00029     targets.push_back(Image(sensor.maxImageSize(), UYVY, Image::AutoAllocate));
00030     targets.push_back(Image(sensor.maxImageSize(), RAW, Image::AutoAllocate));
00031     for (int i = 0; i < targets.size(); i++) {
00032         Frame f1;
00033         shot.exposure = 30000000;
00034         shot.frameTime = 60000000;
00035         shot.gain = 1.0f;
00036         shot.image = targets[i];
00037         sensor.capture(shot);
00038 
00039         Frame f2;
00040         shot.exposure = 0;
00041         shot.frameTime = 0;
00042         shot.gain = 1.0f;
00043         shot.image = targets[i];
00044         sensor.capture(shot);
00045 
00046         Event e;
00047         while (getNextEvent(&e)) {
00048             std::cout << e.description << std::endl;
00049         }
00050 
00051         f1 = sensor.getFrame();
00052         f2 = sensor.getFrame();
00053 
00054         if (!f1.image().valid() || !f2.image().valid()) {
00055             printf("INVALID IMAGE\n");
00056         } else {            
00057             printf("%dx%d -> %dx%d %s -> Exposure: [%d %d], frame time: [%d %d]\n", 
00058                    targets[i].width(), targets[i].height(),
00059                    f1.image().width(), f1.image().height(), 
00060                    f1.image().type() == RAW ? "raw" : "uyvy",
00061                    f2.exposure(), f1.exposure(), f2.frameTime(), f1.frameTime());
00062         }
00063     }
00064     
00065 
00066     // Check which resolutions are good for UYVY (close the shutter,
00067     // and inspect the output images to see if the noise pattern
00068     // displays significant banding indicating a slight resample)
00069     shot.exposure = 200000;
00070     shot.gain = 32;
00071 
00072     printf("Using exposure = %d, gain = %f\n", shot.exposure, shot.gain);
00073 
00074     int widths[] = {2560, 2576, 2592};
00075     int heights[] = {1954, 1954, 1954};
00076     for (int i = 0; i < sizeof(widths)/sizeof(widths[0]); i++) {
00077         int w = widths[i];
00078         int h = heights[i];
00079         printf("%d %d\n", w, h);
00080         shot.image = Image(w, h, UYVY);
00081         sensor.capture(shot);
00082         Frame f = sensor.getFrame();
00083         char buf[128];
00084         sprintf(buf, "test_%d_%d.jpg", w, h);
00085         saveJPEG(f, buf, 100);
00086     }
00087     
00088     return 0;
00089     
00090 
00091 }

Generated on Fri Sep 24 2010 15:53:00 for FCam by  doxygen 1.7.1