Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleDirectToDisk.cpp

Example for using the videosource dcam and writing direct to disk ,ImageConvert

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @example ExampleDirectToDisk.cpp
@relates VideoSource_DCAM,ImageConvert
@ingroup g_examples
@ingroup g_videosource
@brief Example for using the videosource dcam and writing direct to disk
@author MIP
*/
#include <Image/Camera.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Image/ImageIO.hh>
#include <VideoSource/VideoSource_DCAM.hh>
#include <Base/Debug/TimeMeasure.hh>
#ifdef WIN32
# include <windows.h>
#else
# include <unistd.h>
# include <getopt.h>
#endif
using namespace BIAS;
using namespace std;
#define StorageType unsigned char
int main(int /*argc*/, char** /*argv*/)
{
int res = -1;
unsigned int loopcount = 100;
cout <<"Warning: Improper use can freeze your system and especially your filesystem "<<endl;
// cam.SetSize(1600,1200);
// cam.SetLeftTop(174,32);
// cam.SetFormat7(0,2400,1);
cam.SetDebugLevel(D_DTD | D_DCAM | D_DCAM_F7);
// cam.SetBinning(true);
// res = cam.OpenDevice() ;
// cam.ForceFormat7(true);
// cam.SetSize(1200,1200);
// cam.SetSize(1024, 768);
// cam.SetLeftTop(0,0);
cam.SetFPS(7.5);
res = cam.OpenDevice() ;
//cout <<"Openresult: "<<res<<endl;
// cam.ExternalTrigger(true);
if (res <0) {
cerr<<" Can not open camera. res="<<res<<endl;
exit(1);
}
// if (cam.SetWhiteBalance(rgain, bgain)!=0){
// BIASERR("error setting white balance");}
// cam.AutoMode(FEATURE_WHITE_BALANCE, true);
// cam.ShowCapabilities();
cam.SetShutter(float(1.0/50.0));
cam.InitImage(img);
cam.SetDirectToDisk("VideoStream.miv");
cam.PreGrab();
cam.SetDebugLevel(0);
// cam.SetFeature(FEATURE_SHARPNESS,0);
t1.Start();
for (unsigned int i=0;i<loopcount; i++) {
cout <<"Grabing image "<<i;
cam.GrabSingle(img);
cout <<" UID: "<<img.GetUID()<<endl;
}
t1.Stop();
float fps = float(loopcount / (t1.GetRealTime()/1000000.0));
cout <<"FPS: "<<fps<<endl;
cam.PostGrab();
cam.CloseDevice();
return 0;
}