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

examples/example6/example6.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 
00006 #include "SoundPlayer.h"
00007 
00010 // Select the platform
00011 namespace Plat = FCam::N900;
00012 // namespace Plat = FCam::F2;
00013 
00014 /***********************************************************/
00015 /* Shutter sound                                           */
00016 /*                                                         */
00017 /* This example shows how to declare and attach a device,  */
00018 /* and write the appropriate actions. In this example, the */
00019 /* camera will trigger two actions at the beginning of the */
00020 /* exposure: a flash, and a shutter sound.                 */
00021 /* See SoundPlayer class for more information.             */
00022 /***********************************************************/
00023 int main(int argc, char ** argv) {
00024 
00025     // Devices
00026     Plat::Sensor sensor;
00027     Plat::Flash flash;
00028     
00029     // We defined a custom device to play a sound during the
00030     // exposure. See SoundPlayer.h/cpp for details.
00031     SoundPlayer audio; 
00032     
00033     sensor.attach(&flash); // Attach the flash to the sensor
00034     sensor.attach(&audio); // Attach the sound player to the sensor
00035     
00036     // Set the shot parameters
00037     FCam::Shot shot1;
00038     shot1.exposure = 400000;
00039     shot1.gain = 1.0f;
00040     shot1.image = FCam::Image(2592, 1968, FCam::UYVY);
00041     
00042     // Action (Flash)
00043     FCam::Flash::FireAction fire(&flash);
00044     fire.time = 0; 
00045     fire.duration = 60000;
00046     fire.brightness = flash.maxBrightness();
00047     
00048     // Action (Sound)
00049     SoundPlayer::SoundAction click(&audio);
00050     click.time = 0; // Start at the beginning of the exposure
00051     click.setWavFile("/usr/share/sounds/camera_snd_title_1.wav");
00052     
00053     // Attach actions
00054     shot1.addAction(fire);
00055     shot1.addAction(click);
00056     
00057     // Order the sensor to capture a shot.
00058     // The flash and the shutter sound should happen simultaneously.
00059     sensor.capture(shot1);
00060     assert(sensor.shotsPending() == 1); // There should be exactly one shot
00061     
00062     // Retrieve the frame from the sensor
00063     FCam::Frame frame = sensor.getFrame();
00064     assert(frame.shot().id == shot1.id); // Check the source of the request
00065     
00066     // Write out the file
00067     FCam::saveJPEG(frame, "/home/user/MyDocs/DCIM/example6.jpg");
00068     
00069     // Check that the pipeline is empty
00070     assert(sensor.framesPending() == 0);
00071     assert(sensor.shotsPending() == 0);
00072 }

Generated on Fri Sep 24 2010 15:52:59 for FCam by  doxygen 1.7.1