Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleVideoServer.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 ExampleVideoServer.cpp
27  @relates VideoServer
28  @ingroup g_examples
29  @ingroup g_videosource
30  @brief Example for a videoserver waiting for images
31  @author MIP
32 */
33 
34 #include <iostream>
35 #include <Utils/Param.hh>
36 #include <VideoSource/VideoServer.hh>
37 #include <Base/Debug/TimeMeasure.hh>
38 
39 using namespace std;
40 using namespace BIAS;
41 
42 
43 int main( int argc, char *argv[])
44 {
45  bool done = false;
46  Param Params;
47  TimeMeasure timer_;
48  float fps;
49  VideoServer vs;
50  Params.SetShortCommand("readconfig",'r');
51  Params.SetShortCommand("writeconfig",'w');
52  int optind = Params.ParseCommandLine(argc,argv);
53  if (optind<0) {
54  cout<<"Usage: "<<argv[0]<<" options"<<endl<<
55  " by default all images in current dir are taken."<<endl;
56  exit(1);
57  }
58  cout <<"Init class VideoServer"<<endl;
59  if (vs.Init() <0) exit(1);
60  cout <<"done"<<endl;
61  int i=0,res=0;
62  while(!done){
63  timer_.Start();
64  res=vs.ProcessOneImage();
65 
66  if (res==1) biasusleep(500); // not yet connected
67  timer_.Stop();
68  fps = 1000000.0f / float( timer_.GetRealTime() );
69  timer_.Reset();
70  if (res==0) {
71  unsigned int MessageSize = vs.GetMessageSize();
72  float bw = (float)MessageSize* fps / 1024;
73  cout <<"sent image "<<i<<" size: "<<MessageSize<<" fps: "<<fps
74  <<" bandwidth: "<<bw<< " [kB/s]"<<endl;
75  i++;
76  }
77  }
78 
79  return 0;
80 }
81 
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
Definition: Param.cpp:1028
int Init(int port=D_CS_DEFAULT_PORT)
Definition: VideoServer.cpp:56
int SetShortCommand(const std::string &name, const char cmd)
Add a short commandline switch to an existing parameter.
Definition: Param.cpp:1841
double GetRealTime() const
return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user...
This class Param provides generic support for parameters.
Definition: Param.hh:231
class to send images from a camera or disk to a client
Definition: VideoServer.hh:37
class TimeMeasure contains functions for timing real time and cpu time.
Definition: TimeMeasure.hh:111
unsigned int GetMessageSize()
Definition: VideoServer.hh:58