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

examples/example2/example2.cpp

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <assert.h>
00004 #include <FCam/N900.h>
00005 
00008 // Select the platform
00009 namespace Plat = FCam::N900;
00010 // namespace Plat = FCam::F2;
00011 
00012 /***********************************************************/
00013 /* Flash / No-flash                                        */
00014 /*                                                         */
00015 /* This example demonstrates capturing multiple shots with */
00016 /* possibly different settings.                            */
00017 /***********************************************************/
00018 
00019 int main(int argc, char ** argv) {
00020 
00021     // Devices
00022     Plat::Sensor sensor;
00023     Plat::Flash flash;
00024     sensor.attach(&flash); // Attach the flash to the sensor
00025     
00026     
00027     // Make two shots
00028     std::vector<FCam::Shot> shot(2);
00029     
00030     // Set the first shot parameters (to be done with flash)
00031     shot[0].exposure = 80000;
00032     shot[0].gain = 1.0f;
00033     shot[0].image = FCam::Image(2592, 1968, FCam::UYVY);
00034     
00035     // Set the second shot parameters (to be done without flash)
00036     shot[1].exposure = 80000;
00037     shot[1].gain = 1.0f;
00038     shot[1].image = FCam::Image(2592, 1968, FCam::UYVY);
00039     
00040     // Make an action to fire the flash
00041     Plat::Flash::FireAction fire(&flash);
00042     fire.duration = flash.minDuration();          // flash briefly
00043     fire.time = shot[0].exposure - fire.duration; // at the end of the exposure
00044     fire.brightness = flash.maxBrightness();      // at full power
00045     
00046     // Attach the action to the first shot
00047     shot[0].addAction(fire);
00048     
00049     // Order the sensor to capture the two shots
00050     sensor.capture(shot);
00051     assert(sensor.shotsPending() == 2);    // There should be exactly two shots
00052     
00053     // Retrieve the first frame
00054     FCam::Frame frame = sensor.getFrame();
00055     assert(sensor.shotsPending() == 1);    // There should be one shot pending
00056     assert(frame.shot().id == shot[0].id); // Check the source of the request
00057     
00058     // Write out file if needed
00059     if (argc > 1) FCam::saveJPEG(frame, argv[1]);    
00060     
00061     // Retrieve the second frame
00062     frame = sensor.getFrame();
00063     assert(frame.shot().id == shot[1].id); // Check the source of the request
00064     
00065     // Write out file
00066     FCam::saveJPEG(frame, "/home/user/MyDocs/DCIM/example2.jpg"); 
00067     
00068     // Check the pipeline is empty
00069     assert(sensor.framesPending() == 0);
00070     assert(sensor.shotsPending() == 0);
00071 }

Generated on Mon Aug 16 2010 14:25:45 for FCam by  doxygen 1.7.1