SharedMemoryCamera Class Reference
Shared memory camera. More...
#include <cams/shmem.h>

Public Member Functions | |
| SharedMemoryCamera (const char *image_id, bool deep_copy=false) | |
| Constructor. | |
| SharedMemoryCamera (const CameraArgumentParser *cap) | |
| Constructor. | |
| ~SharedMemoryCamera () | |
| Destructor. | |
| virtual void | open () |
| Open the camera. | |
| virtual void | start () |
| Start image transfer from the camera. | |
| virtual void | stop () |
| Stop image transfer from the camera. | |
| virtual void | close () |
| Close camera. | |
| virtual void | flush () |
| Flush image queue. | |
| virtual void | capture () |
| Capture an image. | |
| virtual void | print_info () |
| Print out camera information. | |
| virtual bool | ready () |
| Camera is ready for taking pictures. | |
| virtual unsigned char * | buffer () |
| Get access to current image buffer. | |
| virtual unsigned int | buffer_size () |
| Size of buffer. | |
| virtual void | dispose_buffer () |
| Dispose current buffer. | |
| virtual unsigned int | pixel_width () |
| Width of image in pixels. | |
| virtual unsigned int | pixel_height () |
| Height of image in pixels. | |
| virtual colorspace_t | colorspace () |
| Colorspace of returned image. | |
| virtual fawkes::Time * | capture_time () |
| Get the Time of the last successfully captured image. | |
| virtual void | set_image_number (unsigned int n) |
| Set image number to retrieve. | |
| SharedMemoryImageBuffer * | shared_memory_image_buffer () |
| Get the shared memory image buffer. | |
| virtual void | lock_for_read () |
| Lock image for reading. | |
| virtual bool | try_lock_for_read () |
| Try to lock for reading. | |
| virtual void | lock_for_write () |
| Lock image for writing. | |
| virtual bool | try_lock_for_write () |
| Try to lock for reading. | |
| virtual void | unlock () |
| Unlock buffer. | |
Detailed Description
Shared memory camera.Camera to retrieve images from a shared memory segment.
The camera can operate in a so-called deep-copy mode. In this mode a local internal buffer is created of the size of the image. On capture() the image is copied from the shared memory buffer to the local buffer with the shared memory segment locked for reading. This can be used if the image writing and the image reading processess run asynchronously. While locking would suffice the copying will account for only short locking times so that the interference between the two processes is minimal.
Definition at line 33 of file shmem.h.
Constructor & Destructor Documentation
| SharedMemoryCamera::SharedMemoryCamera | ( | const char * | image_id, | |
| bool | deep_copy = false | |||
| ) |
| SharedMemoryCamera::SharedMemoryCamera | ( | const CameraArgumentParser * | cap | ) |
Constructor.
Take configuration data from camera argument parser. The following options are supported.
- image_id=ID, where ID is the image ID
- Parameters:
-
cap camera argument parser
Definition at line 76 of file shmem.cpp.
References CameraArgumentParser::get(), and CameraArgumentParser::has().
Member Function Documentation
| unsigned char * SharedMemoryCamera::buffer | ( | ) | [virtual] |
Get access to current image buffer.
This will return a pointer to the current buffer. The buffer contains an image of the given colorspace, width and height.
- Returns:
- pointer to image buffer
Implements Camera.
Definition at line 167 of file shmem.cpp.
References SharedMemoryImageBuffer::buffer().
| unsigned int SharedMemoryCamera::buffer_size | ( | ) | [virtual] |
Size of buffer.
Gets the size in bytes of the buffer returned by buffer().
- Returns:
- size of buffer in bytes
Implements Camera.
Definition at line 177 of file shmem.cpp.
References SharedMemoryImageBuffer::colorspace(), SharedMemoryImageBuffer::height(), and SharedMemoryImageBuffer::width().
| void SharedMemoryCamera::capture | ( | ) | [virtual] |
Capture an image.
Although cameras shall operate with a continuous image flow where possible sometimes capturing an image means copying a buffer or advancing a buffer list pointer. This shall be done in this method. For a camera-using application it is mandatory to call capture() just before accessing the image buffer.
Implements Camera.
Definition at line 155 of file shmem.cpp.
References SharedMemoryImageBuffer::buffer(), SharedMemoryImageBuffer::capture_time(), fawkes::SharedMemory::data_size(), fawkes::SharedMemory::lock_for_read(), fawkes::Time::set_time(), and fawkes::SharedMemory::unlock().
| fawkes::Time * SharedMemoryCamera::capture_time | ( | ) | [virtual] |
Get the Time of the last successfully captured image.
Returns a Time representing the time when the last image was captured successfully. Note that calling this function is only valid after capture() and before dispose_buffer() has been called -- it is only valid when an image is currently available.
- Returns:
- Time of the currently processed image. The pointer shall be valid at least until the next call to dispose_buffer().
- Exceptions:
-
NotImplementedException thrown if Camera does not support time stamping
Reimplemented from Camera.
| void SharedMemoryCamera::close | ( | ) | [virtual] |
| colorspace_t SharedMemoryCamera::colorspace | ( | ) | [virtual] |
Colorspace of returned image.
- Returns:
- colorspace of image returned by buffer()
Implements Camera.
Definition at line 208 of file shmem.cpp.
References SharedMemoryImageBuffer::colorspace().
| void SharedMemoryCamera::dispose_buffer | ( | ) | [virtual] |
Dispose current buffer.
Some cameras need disposal of the current buffer (for example to free space in a queue to retrieve the next image). This is done with this method. It has to be called after all work has been done on the image as desired. After dispose_buffer() has been called no further access may happen to the image buffer or undesired behavior may happen.
Implements Camera.
| void SharedMemoryCamera::flush | ( | ) | [virtual] |
| void SharedMemoryCamera::lock_for_read | ( | ) | [virtual] |
Lock image for reading.
Aquire the lock to read images.
Definition at line 255 of file shmem.cpp.
References fawkes::SharedMemory::lock_for_read().
| void SharedMemoryCamera::lock_for_write | ( | ) | [virtual] |
Lock image for writing.
Aquire the lock to write images.
Definition at line 275 of file shmem.cpp.
References fawkes::SharedMemory::lock_for_write().
| void SharedMemoryCamera::open | ( | ) | [virtual] |
| unsigned int SharedMemoryCamera::pixel_height | ( | ) | [virtual] |
Height of image in pixels.
- Returns:
- height of image in pixels
Implements Camera.
Definition at line 201 of file shmem.cpp.
References SharedMemoryImageBuffer::height().
| unsigned int SharedMemoryCamera::pixel_width | ( | ) | [virtual] |
Width of image in pixels.
- Returns:
- width of image in pixels
Implements Camera.
Definition at line 195 of file shmem.cpp.
References SharedMemoryImageBuffer::width().
| void SharedMemoryCamera::print_info | ( | ) | [virtual] |
| bool SharedMemoryCamera::ready | ( | ) | [virtual] |
| void SharedMemoryCamera::set_image_number | ( | unsigned int | n | ) | [virtual] |
| SharedMemoryImageBuffer * SharedMemoryCamera::shared_memory_image_buffer | ( | ) |
| void SharedMemoryCamera::start | ( | ) | [virtual] |
Start image transfer from the camera.
For many cameras opening the camera and starting transmission of images are two tasks. This method will simply initiate the transfer after the camera as been opened. And exception shall be thrown if the camera has not been opened.
Implements Camera.
| void SharedMemoryCamera::stop | ( | ) | [virtual] |
| bool SharedMemoryCamera::try_lock_for_read | ( | ) | [virtual] |
Try to lock for reading.
- Returns:
- true if the lock has been aquired, false otherwise
Definition at line 265 of file shmem.cpp.
References fawkes::SharedMemory::try_lock_for_read().
| bool SharedMemoryCamera::try_lock_for_write | ( | ) | [virtual] |
Try to lock for reading.
- Returns:
- true if the lock has been aquired, false otherwise
Definition at line 285 of file shmem.cpp.
References fawkes::SharedMemory::try_lock_for_write().
| void SharedMemoryCamera::unlock | ( | ) | [virtual] |
The documentation for this class was generated from the following files:

