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
31namespace firevision {
32
33class CameraArgumentParser;
34
36{
37public:
38 SharedMemoryCamera(const char *image_id, bool deep_copy = false);
41
42 virtual void open();
43 virtual void start();
44 virtual void stop();
45 virtual void close();
46 virtual void flush();
47 virtual void capture();
48 virtual void print_info();
49
50 virtual bool ready();
51
52 virtual unsigned char *buffer();
53 virtual unsigned int buffer_size();
54 virtual void dispose_buffer();
55
56 virtual unsigned int pixel_width();
57 virtual unsigned int pixel_height();
58 virtual colorspace_t colorspace();
59 virtual fawkes::Time *capture_time();
60
61 virtual void set_image_number(unsigned int n);
62
64
65 virtual void lock_for_read();
66 virtual bool try_lock_for_read();
67 virtual void lock_for_write();
68 virtual bool try_lock_for_write();
69 virtual void unlock();
70
71private:
72 void init();
73
74 bool deep_copy_;
75 bool opened_;
76 char *image_id_;
77
78 SharedMemoryImageBuffer *shm_buffer_;
79
80 unsigned char *deep_buffer_;
81
82 fawkes::Time *capture_time_;
83};
84
85} // end namespace firevision
86
87#endif
A class for handling time.
Definition: time.h:93
Camera argument parser.
Definition: camargp.h:36
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:33
Shared memory camera.
Definition: shmem.h:36
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: shmem.cpp:193
~SharedMemoryCamera()
Destructor.
Definition: shmem.cpp:101
virtual void lock_for_read()
Lock image for reading.
Definition: shmem.cpp:246
virtual unsigned int buffer_size()
Size of buffer.
Definition: shmem.cpp:175
virtual void stop()
Stop image transfer from the camera.
Definition: shmem.cpp:143
virtual void flush()
Flush image queue.
Definition: shmem.cpp:217
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: shmem.cpp:205
virtual bool try_lock_for_read()
Try to lock for reading.
Definition: shmem.cpp:255
virtual void dispose_buffer()
Dispose current buffer.
Definition: shmem.cpp:188
virtual void close()
Close camera.
Definition: shmem.cpp:183
virtual void print_info()
Print out camera information.
Definition: shmem.cpp:148
virtual void unlock()
Unlock buffer.
Definition: shmem.cpp:280
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: shmem.cpp:237
virtual void start()
Start image transfer from the camera.
Definition: shmem.cpp:138
virtual void capture()
Capture an image.
Definition: shmem.cpp:153
virtual void open()
Open the camera.
Definition: shmem.cpp:133
virtual bool ready()
Camera is ready for taking pictures.
Definition: shmem.cpp:231
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: shmem.cpp:165
SharedMemoryImageBuffer * shared_memory_image_buffer()
Get the shared memory image buffer.
Definition: shmem.cpp:225
virtual void lock_for_write()
Lock image for writing.
Definition: shmem.cpp:264
virtual fawkes::Time * capture_time()
Get the Time of the last successfully captured image.
Definition: shmem.cpp:211
virtual bool try_lock_for_write()
Try to lock for reading.
Definition: shmem.cpp:273
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: shmem.cpp:199
SharedMemoryCamera(const char *image_id, bool deep_copy=false)
Constructor.
Definition: shmem.cpp:57
Shared memory image buffer.
Definition: shm_image.h:184