Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleDirectToDisk.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 /** @example ExampleDirectToDisk.cpp
27  @relates VideoSource_DCAM,ImageConvert
28  @ingroup g_examples
29  @ingroup g_videosource
30  @brief Example for using the videosource dcam and writing direct to disk
31  @author MIP
32 */
33 
34 #include <Image/Camera.hh>
35 #include <Base/Image/ImageConvert.hh>
36 #include <Base/Image/ImageIO.hh>
37 #include <VideoSource/VideoSource_DCAM.hh>
38 #include <Base/Debug/TimeMeasure.hh>
39 
40 #ifdef WIN32
41 # include <windows.h>
42 #else
43 # include <unistd.h>
44 # include <getopt.h>
45 #endif
46 
47 using namespace BIAS;
48 using namespace std;
49 
50 #define StorageType unsigned char
51 
52 int main(int /*argc*/, char** /*argv*/)
53 {
54  int res = -1;
55  TimeMeasure t1;
56  unsigned int loopcount = 100;
57  VideoSource_DCAM cam;
58 
59  cout <<"Warning: Improper use can freeze your system and especially your filesystem "<<endl;
60 
61  // cam.SetSize(1600,1200);
62  // cam.SetLeftTop(174,32);
63  // cam.SetFormat7(0,2400,1);
64  cam.SetDebugLevel(D_DTD | D_DCAM | D_DCAM_F7);
65  // cam.SetBinning(true);
66  // res = cam.OpenDevice() ;
67 
68 
69  // cam.ForceFormat7(true);
70  // cam.SetSize(1200,1200);
71  // cam.SetSize(1024, 768);
72  // cam.SetLeftTop(0,0);
73  cam.SetFPS(7.5);
74  res = cam.OpenDevice() ;
75 
76  //cout <<"Openresult: "<<res<<endl;
77  // cam.ExternalTrigger(true);
78  if (res <0) {
79  cerr<<" Can not open camera. res="<<res<<endl;
80  exit(1);
81  }
82  // if (cam.SetWhiteBalance(rgain, bgain)!=0){
83  // BIASERR("error setting white balance");}
84  // cam.AutoMode(FEATURE_WHITE_BALANCE, true);
85 
86  // cam.ShowCapabilities();
87  cam.SetShutter(float(1.0/50.0));
89  cam.InitImage(img);
90  cam.SetDirectToDisk("VideoStream.miv");
91  cam.PreGrab();
92 
93 
94  cam.SetDebugLevel(0);
95  // cam.SetFeature(FEATURE_SHARPNESS,0);
96  t1.Start();
97  for (unsigned int i=0;i<loopcount; i++) {
98  cout <<"Grabing image "<<i;
99  cam.GrabSingle(img);
100  cout <<" UID: "<<img.GetUID()<<endl;
101  }
102  t1.Stop();
103  float fps = float(loopcount / (t1.GetRealTime()/1000000.0));
104  cout <<"FPS: "<<fps<<endl;
105 
106  cam.PostGrab();
107  cam.CloseDevice();
108 
109  return 0;
110 }
virtual int InitImage(BIAS::ImageBase &Image)
void SetFPS(float fps)
Set frame per second for image capturing.
int GrabSingle(BIAS::Camera< unsigned char > &image)
Select the port (bus-id) to use, only valid before OpenDevice()
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
int OpenDevice()
Opens a dc1394 device.
const BIAS::UUID & GetUID() const
returns the UUID of the image
Definition: ImageBase.hh:449
int SetShutter(float exptime)
set value for shutter
int SetDirectToDisk(const std::string &filename)
Enables the very fast direct-to-disk mode.
void SetDebugLevel(const long int lv)
Definition: Debug.hh:318
double GetRealTime() const
return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user...
int CloseDevice()
closes a camera device and cleans up
int PostGrab()
stops iso transmission of a camera.
int PreGrab()
initializes the iso transmission of a camera.
class TimeMeasure contains functions for timing real time and cpu time.
Definition: TimeMeasure.hh:111