Fawkes API  Fawkes Development Version
shmem.h
1 
2 /***************************************************************************
3  * shmem.h - This header defines a reader for shared memory images
4  *
5  * Created: Thu Jan 12 19:41:17 2006
6  * Copyright 2005-2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_CAMS_SHMEM_H_
25 #define __FIREVISION_CAMS_SHMEM_H_
26 
27 #include <fvcams/camera.h>
28 #include <fvutils/color/colorspaces.h>
29 #include <fvutils/ipc/shm_image.h>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 class CameraArgumentParser;
37 
38 class SharedMemoryCamera : public Camera
39 {
40 
41  public:
42 
43  SharedMemoryCamera(const char *image_id, bool deep_copy = false);
46 
47  virtual void open();
48  virtual void start();
49  virtual void stop();
50  virtual void close();
51  virtual void flush();
52  virtual void capture();
53  virtual void print_info();
54 
55  virtual bool ready();
56 
57  virtual unsigned char* buffer();
58  virtual unsigned int buffer_size();
59  virtual void dispose_buffer();
60 
61  virtual unsigned int pixel_width();
62  virtual unsigned int pixel_height();
63  virtual colorspace_t colorspace();
64  virtual fawkes::Time * capture_time();
65 
66  virtual void set_image_number(unsigned int n);
67 
69 
70  virtual void lock_for_read();
71  virtual bool try_lock_for_read();
72  virtual void lock_for_write();
73  virtual bool try_lock_for_write();
74  virtual void unlock();
75 
76  private:
77  void init();
78 
79  bool __deep_copy;
80  bool __opened;
81  char * __image_id;
82 
83  SharedMemoryImageBuffer *__shm_buffer;
84 
85  unsigned char *__deep_buffer;
86 
87  fawkes::Time *__capture_time;
88 };
89 
90 } // end namespace firevision
91 
92 #endif
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: shmem.cpp:200
~SharedMemoryCamera()
Destructor.
Definition: shmem.cpp:106
virtual void stop()
Stop image transfer from the camera.
Definition: shmem.cpp:150
virtual void print_info()
Print out camera information.
Definition: shmem.cpp:155
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
A class for handling time.
Definition: time.h:91
virtual void flush()
Flush image queue.
Definition: shmem.cpp:227
Camera argument parser.
Definition: camargp.h:38
virtual bool ready()
Camera is ready for taking pictures.
Definition: shmem.cpp:243
virtual void unlock()
Unlock buffer.
Definition: shmem.cpp:298
virtual void capture()
Capture an image.
Definition: shmem.cpp:160
virtual void dispose_buffer()
Dispose current buffer.
Definition: shmem.cpp:195
virtual bool try_lock_for_write()
Try to lock for reading.
Definition: shmem.cpp:290
virtual void close()
Close camera.
Definition: shmem.cpp:190
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: shmem.cpp:213
Shared memory image buffer.
Definition: shm_image.h:181
Shared memory camera.
Definition: shmem.h:38
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: shmem.cpp:250
virtual bool try_lock_for_read()
Try to lock for reading.
Definition: shmem.cpp:270
virtual void lock_for_write()
Lock image for writing.
Definition: shmem.cpp:280
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: shmem.cpp:172
SharedMemoryImageBuffer * shared_memory_image_buffer()
Get the shared memory image buffer.
Definition: shmem.cpp:236
virtual unsigned int buffer_size()
Size of buffer.
Definition: shmem.cpp:182
virtual void start()
Start image transfer from the camera.
Definition: shmem.cpp:145
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: shmem.cpp:206
virtual fawkes::Time * capture_time()
Get the Time of the last successfully captured image.
Definition: shmem.cpp:220
virtual void open()
Open the camera.
Definition: shmem.cpp:139
virtual void lock_for_read()
Lock image for reading.
Definition: shmem.cpp:260
SharedMemoryCamera(const char *image_id, bool deep_copy=false)
Constructor.
Definition: shmem.cpp:60