Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleVideofeedShm.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 ExampleVideofeedShm.cpp
27  @relates VideoSource_Disk, VideoSource_DCAM, VideoShMFeeder
28  @ingroup g_examples
29  @ingroup g_videosource
30  @brief Example for a feeding a videosource to shared memory
31  @author MIP
32 */
33 
34 #include <Base/Common/W32Compat.hh> // sprintf wrn
35 #include <VideoSource/VideoSource_Disk.hh>
36 #include <VideoSource/VideoSource_Shm.hh>
37 
38 #ifdef BIAS_HAVE_DCAM
39 # include <VideoSource/VideoSource_DCAM.hh>
40 #endif // BIAS_HAVE_DCAM
41 
42 #include <Image/Camera.hh>
43 #include <iostream>
44 
45 #include <VideoSource/VideoShMFeeder.hh>
46 
47 using namespace std;
48 using namespace BIAS;
49 
50 
51 int main( int /*argc*/, char** /*argv*/)
52 {
53  VideoSource *cam;
54  std::vector<std::string> filenames;
55  filenames.push_back("pic.mip");
56 
57  cam = new VideoSource_Disk();
58 //#ifdef BIAS_HAVE_DCAM
59 // cam = new VideoSource_DCAM();
60 //#endif // BIAS_HAVE_DCAM
61 
63  char title[100];
64 
65  sprintf(title,"Sending Picture");
66 
67  cam->OpenDevice(filenames);
68  //cam->OpenDevice();
69  cam->InitImage(pic);
70  cam->PreGrab();
71  cam->GrabSingle(pic);
72  cout << "Image grab OK\n";
73 
74  VideoShMFeeder ShMFeeder;
75 
76  int i =0;
77  while(i<10000){
78  cam->GrabSingle(pic);
79  ShMFeeder.ProcessImage(&pic);
80  i++;
81  cout <<i<<endl;
82  }
83  cam->PostGrab();
84 
85  cam->CloseDevice();
86  delete cam;
87  return 0;
88 }
89 
90 
virtual int InitImage(BIAS::ImageBase &Image)
Defines a common interface to different devices.
bool ProcessImage(BIAS::Camera< unsigned char > *Image)
virtual int OpenDevice()
selects the first available device to open (e.g.
virtual int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
virtual int GrabSingle(BIAS::Camera< unsigned char > &image)
virtual int PostGrab()
Stop anything started in PreGrab()
virtual int CloseDevice()
class to save Images to a Sharerd memory
This class simulates a video device by loading images from disk.