1 #include <Image/Camera.hh>
2 #include <Base/Image/ImageConvert.hh>
3 #include <Base/Image/ImageIO.hh>
4 #include <VideoSource/VideoSource_DV2.hh>
5 #include <Gui/GuiCV.hh>
12 #define StorageType unsigned char
14 #include <Base/Debug/TimeMeasure.hh>
25 int i,savedframes, savecounter=0;
28 bool color, pause, autosave=
false;
35 sprintf(title,
"MyWindow");
52 gettimeofday(&now, NULL);
54 start = (now.tv_sec % 1000) * 1000 + (now.tv_usec / 1000);
55 fps = 1.0 / (float)(start-end) * 1000.0 ;
68 if (autosave) cerr <<
"\nstarted saving sequence at frame "<<i<<endl;
69 else cerr <<
"\nstopped saving sequence at frame "<<i<<endl;
76 if (color) cerr <<
"\nshowing color image" << endl;
77 else cerr <<
"\nshowing grey image" << endl;
80 if (c!=-1) cerr <<
"unknown key "<<c<<endl;
102 os <<
"frame" << setfill(
'0') << setw(5) << savecounter;
104 BIASERR(
"error saving frame "<<i<<
" at file "<<os.str()<<
".pgm");
111 cout <<
"Frame: "<<i<<
" Showing fps: "<<fps<<
"\r";
120 int main(
int argc,
char *argv[])
134 cout <<
"Openresult: "<<res<<endl;
137 cerr<<
" Can not open camera"<<endl;
144 cout <<
" s : save an image \n";
145 cout <<
" S : save sequence\n";
146 cout <<
"SPC : Stop/Resume\n";
147 cout <<
" e : toggle between slow and fast conversion\n";
148 cout <<
" q : Quit \n";
virtual int InitImage(BIAS::ImageBase &Image)
virtual void SetTitle(std::string const &Title)
int PostGrab()
Stop anything started in PreGrab()
int OpenDevice()
selects the first available device to open (e.g.
Gui based on OpenCV is a simple windowing environment...
int GrabSingle(BIAS::Camera< unsigned char > &image)
void SetDebugLevel(const long int lv)
unsigned int GetHeight() const
This class extends VideoSource for the use of IEEE1394-connected DV-camcorders. The low-level driver ...
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
static int ToRGB(const Image< StorageType > &source, Image< StorageType > &dest)
Create a RGB converted copy of source image in this.
virtual int ShowImage(ImageBase &image, float min=0.0, float max=255.0)
shows/updates the image shown in window.
virtual char CheckForKeyEvent()
checks if any key is pressed and returns it returns -1 if no key is pressed
class TimeMeasure contains functions for timing real time and cpu time.