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

Example for using the videosource dcam and converting images

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 ExampleDcamImageConvert.cpp
@relates VideoSource_DCAM
@ingroup g_examples
@ingroup g_videosource
@brief Example for using the videosource dcam and converting images
@author MIP
*/
#include <Image/Camera.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Image/ImageIO.hh>
#include <VideoSource/VideoSource_DCAM.hh>
//#include <unistd.h>
//#include <getopt.h>
using namespace BIAS;
using namespace std;
#include <Base/Debug/TimeMeasure.hh>
int main(int argc, char *argv[])
{
int res = -1;
// grabimg.SetColorModel(BIAS::ImageBase::CM_Bayer_GRBG);
// prepare camera
cam = new VideoSource_DCAM;
cam->SetDebugLevel(D_DCAM |D_DCAM_F7);
// cam[0].UsePort(0);
// cam[1].UsePort(1);
res = cam->OpenDevice() ;
if (res <0) {
cerr<<" Can not open camera on bus "<<res<<endl;
exit(1);
}
cam->PreGrab();
cam->SetDebugLevel(0);
cam->InitImage(grabimg);
//cam->InitImage(saveimg);
saveimg.Init(grabimg.GetWidth(),grabimg.GetHeight(),3);
//cout << "================== Channels: " << saveimg.GetChannelCount() << endl;
// grab 20 images
for(int i=0; i<10;i++){
cam->GrabSingle(grabimg);
//ImageIO::Write("cam0",grabimg[0]);
stringstream ss;
ss << "cam_" << i;
ImageIO::Save(ss.str(),saveimg);
stringstream ss2;
ss2 << "cam2_" << i;
ImageIO::Save(ss2.str(),saveimg);
}
//Image
cout <<"Write finished, closing cameras"<<endl;
cam->SetDebugLevel(D_DCAM );
cam->PostGrab();
cam->CloseDevice();
// delete cam;
return 0;
}