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

examples/example1/example1.cpp

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <assert.h>
00004 
00005 // Select the platform
00006 
00007 #if !defined PLATFORM_N900 && !defined PLATFORM_F2
00008 #define PLATFORM_N900
00009 #endif
00010 
00011 #if defined PLATFORM_N900
00012 #include <FCam/N900.h>
00013 namespace Plat = FCam::N900;
00014 #endif
00015 
00016 #if defined PLATFORM_F2
00017 #include <FCam/F2.h>
00018 namespace Plat = FCam::F2;
00019 #endif
00020 
00023 /***********************************************************/
00024 /* A program that takes a single shot                      */
00025 /*                                                         */
00026 /* This example is a simple demonstration of the usage of  */
00027 /* the FCam API.                                           */
00028 /***********************************************************/
00029 
00030 int main(int argc, char ** argv) {
00031 
00032     // Make the image sensor
00033     Plat::Sensor sensor;
00034     
00035     // Make a new shot
00036     FCam::Shot shot1;
00037     shot1.exposure = 50000; // 50 ms exposure
00038     shot1.gain = 1.0f;      // minimum ISO
00039     
00040     // Specify the output resolution and format, and allocate storage for the resulting image
00041     shot1.image = FCam::Image(2592, 1968, FCam::UYVY);
00042     
00043     // Order the sensor to capture a shot.
00044     //sensor.stream(shot1);
00045     //sensor.stopStreaming();
00046 
00047     sensor.capture(shot1);
00048 
00049     //assert(sensor.shotsPending() == 1); // There should be exactly one shot.
00050     
00051     // Retrieve the frame from the sensor.
00052     FCam::Frame frame = sensor.getFrame();
00053 
00054     // This frame should be the result of the shot we made.
00055     assert(frame.shot().id == shot1.id); 
00056     
00057     // If we were given a filename as a command line arg, save this frame.
00058     if (argc > 1) 
00059         FCam::saveJPEG(frame, argv[1]); 
00060     
00061     // Check that the pipeline is empty.
00062     assert(sensor.framesPending() == 0);
00063     assert(sensor.shotsPending() == 0);
00064 
00065     return 0;
00066 }

Generated on Thu Jul 15 2010 17:51:28 for FCam by  doxygen 1.7.1