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

Example for a videoserver waiting for 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 ExampleVideoServer.cpp
@relates VideoServer
@ingroup g_examples
@ingroup g_videosource
@brief Example for a videoserver waiting for images
@author MIP
*/
#include <iostream>
#include <Utils/Param.hh>
#include <VideoSource/VideoServer.hh>
#include <Base/Debug/TimeMeasure.hh>
using namespace std;
using namespace BIAS;
int main( int argc, char *argv[])
{
bool done = false;
Param Params;
TimeMeasure timer_;
float fps;
Params.SetShortCommand("readconfig",'r');
Params.SetShortCommand("writeconfig",'w');
int optind = Params.ParseCommandLine(argc,argv);
if (optind<0) {
cout<<"Usage: "<<argv[0]<<" options"<<endl<<
" by default all images in current dir are taken."<<endl;
exit(1);
}
cout <<"Init class VideoServer"<<endl;
if (vs.Init() <0) exit(1);
cout <<"done"<<endl;
int i=0,res=0;
while(!done){
timer_.Start();
res=vs.ProcessOneImage();
if (res==1) biasusleep(500); // not yet connected
timer_.Stop();
fps = 1000000.0f / float( timer_.GetRealTime() );
timer_.Reset();
if (res==0) {
unsigned int MessageSize = vs.GetMessageSize();
float bw = (float)MessageSize* fps / 1024;
cout <<"sent image "<<i<<" size: "<<MessageSize<<" fps: "<<fps
<<" bandwidth: "<<bw<< " [kB/s]"<<endl;
i++;
}
}
return 0;
}