Fawkes API
Fawkes Development Version
|
Shared memory camera. More...
#include <>>
Public Member Functions | |
SharedMemoryCamera (const char *image_id, bool deep_copy=false) | |
Constructor. More... | |
SharedMemoryCamera (const CameraArgumentParser *cap) | |
Constructor. More... | |
~SharedMemoryCamera () | |
Destructor. More... | |
virtual void | open () |
Open the camera. More... | |
virtual void | start () |
Start image transfer from the camera. More... | |
virtual void | stop () |
Stop image transfer from the camera. More... | |
virtual void | close () |
Close camera. More... | |
virtual void | flush () |
Flush image queue. More... | |
virtual void | capture () |
Capture an image. More... | |
virtual void | print_info () |
Print out camera information. More... | |
virtual bool | ready () |
Camera is ready for taking pictures. More... | |
virtual unsigned char * | buffer () |
Get access to current image buffer. More... | |
virtual unsigned int | buffer_size () |
Size of buffer. More... | |
virtual void | dispose_buffer () |
Dispose current buffer. More... | |
virtual unsigned int | pixel_width () |
Width of image in pixels. More... | |
virtual unsigned int | pixel_height () |
Height of image in pixels. More... | |
virtual colorspace_t | colorspace () |
Colorspace of returned image. More... | |
virtual fawkes::Time * | capture_time () |
Get the Time of the last successfully captured image. More... | |
virtual void | set_image_number (unsigned int n) |
Set image number to retrieve. More... | |
SharedMemoryImageBuffer * | shared_memory_image_buffer () |
Get the shared memory image buffer. More... | |
virtual void | lock_for_read () |
Lock image for reading. More... | |
virtual bool | try_lock_for_read () |
Try to lock for reading. More... | |
virtual void | lock_for_write () |
Lock image for writing. More... | |
virtual bool | try_lock_for_write () |
Try to lock for reading. More... | |
virtual void | unlock () |
Unlock buffer. More... | |
![]() | |
virtual | ~Camera () |
Virtual empty destructor. More... | |
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.
firevision::SharedMemoryCamera::SharedMemoryCamera | ( | const char * | image_id, |
bool | deep_copy = false |
||
) |
firevision::SharedMemoryCamera::SharedMemoryCamera | ( | const CameraArgumentParser * | cap | ) |
Constructor.
Take configuration data from camera argument parser. The following options are supported.
cap | camera argument parser |
Definition at line 81 of file shmem.cpp.
References firevision::CameraArgumentParser::get(), and firevision::CameraArgumentParser::has().
firevision::SharedMemoryCamera::~SharedMemoryCamera | ( | ) |
|
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.
Implements firevision::Camera.
Definition at line 172 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::loop().
|
virtual |
Size of buffer.
Gets the size in bytes of the buffer returned by buffer().
Implements firevision::Camera.
|
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 firevision::Camera.
Definition at line 160 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::loop().
|
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.
NotImplementedException | thrown if Camera does not support time stamping |
Reimplemented from firevision::Camera.
|
virtual |
Close camera.
This closes the camera device. The camera must have been stopped before calling close().
Implements firevision::Camera.
|
virtual |
Colorspace of returned image.
Implements firevision::Camera.
Definition at line 213 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::loop().
|
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 firevision::Camera.
Definition at line 195 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::loop().
|
virtual |
Flush image queue.
Some cameras may have an image buffer queue. With this it can happen that if the processing of an image took longer than desired it is needed to flush this buffer queue.
Implements firevision::Camera.
|
virtual |
Lock image for reading.
Aquire the lock to read images.
Definition at line 260 of file shmem.cpp.
References fawkes::SharedMemory::lock_for_read().
Referenced by fawkes::WebviewJpegStreamProducer::loop().
|
virtual |
|
virtual |
Open the camera.
The camera is opened, but image transfer not yet started. This can be used to detect general problems with the camera while delaying the real transfer startup until it is needed.
Implements firevision::Camera.
|
virtual |
Height of image in pixels.
Implements firevision::Camera.
Definition at line 206 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::init(), and fawkes::WebviewJpegStreamProducer::loop().
|
virtual |
Width of image in pixels.
Implements firevision::Camera.
Definition at line 200 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::init(), and fawkes::WebviewJpegStreamProducer::loop().
|
virtual |
Print out camera information.
Shall print out camera information and current setup information on stdout.
Implements firevision::Camera.
|
virtual |
Camera is ready for taking pictures.
The camera has been opened and started correctly and may now provide images.
Implements firevision::Camera.
|
virtual |
Set image number to retrieve.
If a camera is able to retrieve several images this method can be used to select the image to be retrieved with the next call to capture().
n | image number to set |
Implements firevision::Camera.
SharedMemoryImageBuffer * firevision::SharedMemoryCamera::shared_memory_image_buffer | ( | ) |
Get the shared memory image buffer.
Definition at line 236 of file shmem.cpp.
Referenced by Firestation::get_window().
|
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 firevision::Camera.
|
virtual |
Stop image transfer from the camera.
This will stop the image transfer initiated with start(). This can be used to start and stop the image transfer at will without opening and closing operations inbetween.
Implements firevision::Camera.
|
virtual |
|
virtual |
|
virtual |
Unlock buffer.
Definition at line 298 of file shmem.cpp.
Referenced by fawkes::WebviewJpegStreamProducer::loop().