Fawkes API
Fawkes Development Version
|
Shared memory image buffer. More...
#include <>>
Public Member Functions | |
SharedMemoryImageBuffer (const char *image_id, colorspace_t cspace, unsigned int width, unsigned int height) | |
Write Constructor. More... | |
SharedMemoryImageBuffer (const char *image_id, bool is_read_only=true) | |
Read Constructor. More... | |
~SharedMemoryImageBuffer () | |
Destructor. More... | |
const char * | image_id () const |
Get Image ID. More... | |
const char * | frame_id () const |
Get frame ID. More... | |
unsigned char * | buffer () const |
Get image buffer. More... | |
colorspace_t | colorspace () const |
Get color space. More... | |
unsigned int | width () const |
Get image width. More... | |
unsigned int | height () const |
Get image height. More... | |
unsigned int | roi_x () const |
Get ROI X. More... | |
unsigned int | roi_y () const |
Get ROI Y. More... | |
unsigned int | roi_width () const |
Get ROI width. More... | |
unsigned int | roi_height () const |
Get ROI height. More... | |
int | circle_x () const |
Get circle X. More... | |
int | circle_y () const |
Get circle Y. More... | |
unsigned int | circle_radius () const |
Get circle radius. More... | |
bool | circle_found () const |
Check if circle was found . More... | |
void | set_roi_x (unsigned int roi_x) |
Set ROI X. More... | |
void | set_roi_y (unsigned int roi_y) |
Set ROI Y. More... | |
void | set_roi_width (unsigned int roi_w) |
Set ROI width. More... | |
void | set_roi_height (unsigned int roi_h) |
Set ROI height. More... | |
void | set_roi (unsigned int roi_x, unsigned int roi_y, unsigned int roi_w, unsigned int roi_h) |
Set ROI data. More... | |
void | set_circle_x (int circle_x) |
Set circle X. More... | |
void | set_circle_y (int circle_y) |
Set circle Y. More... | |
void | set_circle_radius (unsigned int circle_radius) |
Set circle radius. More... | |
void | set_circle (int x, int y, unsigned int r) |
Set circle data. More... | |
void | set_circle_found (bool found) |
Set circle found. More... | |
bool | set_image_id (const char *image_id) |
Set image number. More... | |
void | set_frame_id (const char *frame_id) |
Set frame ID. More... | |
fawkes::Time | capture_time () const |
Get the time when the image was captured. More... | |
void | capture_time (long int *sec, long int *usec) const |
Get the time when the image was captured. More... | |
void | set_capture_time (fawkes::Time *time) |
Set the capture time. More... | |
void | set_capture_time (long int sec, long int usec) |
Set the capture time. More... | |
![]() | |
SharedMemory (const char *magic_token, SharedMemoryHeader *header, bool is_read_only, bool create, bool destroy_on_delete, const char *registry_name=0) | |
Create a new shared memory segment. More... | |
SharedMemory (const SharedMemory &s) | |
Copy constructor. More... | |
virtual | ~SharedMemory () |
Destructor. More... | |
bool | is_read_only () const |
Check for read-only mode. More... | |
bool | is_destroyed () const |
Check if segment has been destroyed This can be used if the segment has been destroyed. More... | |
bool | is_swapable () const |
Check if memory can be swapped out. More... | |
bool | is_valid () const |
Check validity of shared memory segment. More... | |
bool | is_creator () const |
Determine if the shared memory segment has been created by this instance. More... | |
bool | is_protected () const |
Check if memory segment is protected. More... | |
void * | memptr () const |
Get a pointer to the shared memory This method returns a pointer to the data-segment of the shared memory segment. More... | |
size_t | data_size () const |
Get the size of the data-segment. More... | |
int | shmem_id () const |
Get shared memory ID. More... | |
unsigned int | num_attached () const |
Get number of attached processes. More... | |
void | set (void *memptr) |
Copies data from the memptr to shared memory. More... | |
void | set_destroy_on_delete (bool destroy) |
Set deletion behaviour. More... | |
void | add_semaphore () |
Add semaphore to shared memory segment. More... | |
void | set_swapable (bool swapable) |
Set shared memory swapable. More... | |
void | lock_for_read () |
Lock shared memory segment for reading. More... | |
bool | try_lock_for_read () |
Try to aquire lock on shared memory segment for reading. More... | |
void | lock_for_write () |
Lock shared memory segment for writing. More... | |
bool | try_lock_for_write () |
Try to aquire lock on shared memory segment for writing. More... | |
void | unlock () |
Unlock memory. More... | |
void * | ptr (void *addr) const |
Get the real pointer to the data based on an address. More... | |
void * | addr (void *ptr) const |
Get an address from a real pointer. More... | |
Static Public Member Functions | |
static void | list () |
List all shared memory segments that contain a FireVision image. More... | |
static void | cleanup (bool use_lister=true) |
Erase all shared memory segments that contain FireVision images. More... | |
static bool | exists (const char *image_id) |
Check image availability. More... | |
static void | wipe (const char *image_id) |
Erase a specific shared memory segment that contains an image. More... | |
static std::list< SharedMemoryImageBufferMetaData > | list_meta_data () |
Get meta data about image buffers. More... | |
![]() | |
static void | list (const char *magic_token, SharedMemoryHeader *header, SharedMemoryLister *lister, const char *registry_name=0) |
List shared memory segments of a given type. More... | |
static void | erase (const char *magic_token, SharedMemoryHeader *header, SharedMemoryLister *lister=0, const char *registry_name=0) |
Erase shared memory segments of a given type. More... | |
static void | erase_orphaned (const char *magic_token, SharedMemoryHeader *header, SharedMemoryLister *lister=0, const char *registry_name=0) |
Erase orphaned (attach count = 0) shared memory segments of a given type. More... | |
static bool | exists (const char *magic_token, SharedMemoryHeader *header, const char *registry_name=0) |
Check if a specific shared memory segment exists. More... | |
static bool | is_destroyed (int shm_id) |
Check if a segment has been destroyed. More... | |
static bool | is_swapable (int shm_id) |
Check if memory can be swapped out. More... | |
static unsigned int | num_attached (int shm_id) |
Get number of attached processes. More... | |
static SharedMemoryIterator | find (const char *magic_token, SharedMemoryHeader *header, const char *registry_name=0) |
Find SharedMemory segments. More... | |
static SharedMemoryIterator | end () |
Get invalid iterator. More... | |
Additional Inherited Members | |
![]() | |
static const unsigned int | MagicTokenSize = MAGIC_TOKEN_SIZE |
The magic token size. More... | |
static const short | MaxNumConcurrentReaders = 8 |
Maximum number of concurrent readers. More... | |
![]() | |
SharedMemory (const char *magic_token, bool is_read_only, bool create, bool destroy_on_delete, const char *registry_name=0) | |
Constructor for derivates. More... | |
void | attach () |
Attach to the shared memory segment. More... | |
void | free () |
Detach from and maybe destroy the shared memory segment. More... | |
![]() | |
void * | _memptr |
Pointer to the data segment. More... | |
size_t | _mem_size |
Total size of the segment, including headers. More... | |
size_t | _data_size |
Size of the data segment only. More... | |
SharedMemoryHeader * | _header |
Data-specific header. More... | |
bool | _is_read_only |
Read-only. More... | |
bool | _destroy_on_delete |
destroy on delete. More... | |
bool | _should_create |
Create shared memory segment. More... | |
char * | _magic_token |
Magic token. More... | |
char * | _shm_magic_token |
Magic token as stored in the shared memory segment. More... | |
SharedMemory_header_t * | _shm_header |
general header as stored in the shared memory segment More... | |
void * | _shm_upper_bound |
Upper bound of memory. More... | |
long unsigned int | _shm_offset |
Offset to the master's base addr. More... | |
Shared memory image buffer.
Write images to or retrieve images from a shared memory segment.
Definition at line 181 of file shm_image.h.
firevision::SharedMemoryImageBuffer::SharedMemoryImageBuffer | ( | const char * | image_id, |
colorspace_t | cspace, | ||
unsigned int | width, | ||
unsigned int | height | ||
) |
Write Constructor.
Create a new shared memory segment. Will open a shared memory segment that exactly fits the given information. Will throw an error if image with id image_id exists. I will create a new segment if no matching segment was found. The segment is accessed in read-write mode.
Use this constructor to open a shared memory image buffer for writing.
image_id | image ID to open |
cspace | colorspace |
width | image width |
height | image height |
Definition at line 64 of file shm_image.cpp.
References fawkes::SharedMemory::add_semaphore().
firevision::SharedMemoryImageBuffer::SharedMemoryImageBuffer | ( | const char * | image_id, |
bool | is_read_only = true |
||
) |
Read Constructor.
This constructor is used to search for an existing shared memory segment. It will throw an error if it cannot find a segment with the specified data. The segment is opened read-only by default, but this can be overridden with the is_read_only argument if needed.
Use this constructor to open an image for reading.
image_id | Image ID to open |
is_read_only | true to open image read-only |
Definition at line 88 of file shm_image.cpp.
References fawkes::SharedMemory::_header, fawkes::SharedMemory::_is_read_only, fawkes::Exception::append(), fawkes::SharedMemory::attach(), fawkes::SharedMemory::free(), height(), image_id(), fawkes::SharedMemory::is_read_only(), firevision::SharedMemoryImageBufferHeader::raw_header(), and width().
firevision::SharedMemoryImageBuffer::~SharedMemoryImageBuffer | ( | ) |
unsigned char * firevision::SharedMemoryImageBuffer::buffer | ( | ) | const |
Get image buffer.
Definition at line 235 of file shm_image.cpp.
References fawkes::SharedMemory::_memptr.
Referenced by OpenNiPointCloudThread::finalize(), firevision::FuseImageContent::FuseImageContent(), FvRetrieverThread::loop(), OpenNiImageThread::loop(), OpenNiPclOnlyThread::loop(), OpenNiDepthThread::loop(), OpenNiUserTrackerThread::loop(), and Bumblebee2Thread::loop().
Time firevision::SharedMemoryImageBuffer::capture_time | ( | ) | const |
Get the time when the image was captured.
Definition at line 195 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::capture_time_sec, and firevision::SharedMemoryImageBuffer_header_t::capture_time_usec.
Referenced by firevision::FuseImageContent::FuseImageContent(), and OpenNiPclOnlyThread::loop().
void firevision::SharedMemoryImageBuffer::capture_time | ( | long int * | sec, |
long int * | usec | ||
) | const |
Get the time when the image was captured.
sec | upon return contains the seconds part of the time |
usec | upon return contains the micro seconds part of the time |
Definition at line 185 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::capture_time_sec, and firevision::SharedMemoryImageBuffer_header_t::capture_time_usec.
bool firevision::SharedMemoryImageBuffer::circle_found | ( | ) | const |
Check if circle was found .
Definition at line 483 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::flag_circle_found.
Referenced by Firestation::get_window().
unsigned int firevision::SharedMemoryImageBuffer::circle_radius | ( | ) | const |
Get circle radius.
Definition at line 335 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::circle_radius.
Referenced by set_circle_radius().
int firevision::SharedMemoryImageBuffer::circle_x | ( | ) | const |
Get circle X.
Definition at line 315 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::circle_x.
Referenced by set_circle_x().
int firevision::SharedMemoryImageBuffer::circle_y | ( | ) | const |
Get circle Y.
Definition at line 325 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::circle_y.
Referenced by set_circle_y().
|
static |
Erase all shared memory segments that contain FireVision images.
use_lister | if true a lister is used to print the shared memory segments to stdout while cleaning up. |
Definition at line 531 of file shm_image.cpp.
colorspace_t firevision::SharedMemoryImageBuffer::colorspace | ( | ) | const |
Get color space.
Definition at line 245 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::colorspace.
Referenced by firevision::FuseImageContent::FuseImageContent(), firevision::SharedMemoryImageBufferLister::print_info(), firevision::SharedMemoryImageBufferHeader::SharedMemoryImageBufferHeader(), and firevision::SharedMemoryImageBufferMetaData::SharedMemoryImageBufferMetaData().
|
static |
Check image availability.
image_id | image ID to check |
Definition at line 552 of file shm_image.cpp.
const char * firevision::SharedMemoryImageBuffer::frame_id | ( | ) | const |
Get frame ID.
Definition at line 174 of file shm_image.cpp.
References firevision::SharedMemoryImageBufferHeader::frame_id().
Referenced by RosImagesThread::loop(), and firevision::SharedMemoryImageBufferMetaData::SharedMemoryImageBufferMetaData().
unsigned int firevision::SharedMemoryImageBuffer::height | ( | ) | const |
Get image height.
Definition at line 265 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::height.
Referenced by firevision::FuseImageContent::FuseImageContent(), OpenNiPclOnlyThread::init(), SharedMemoryImageBuffer(), firevision::SharedMemoryImageBufferHeader::SharedMemoryImageBufferHeader(), and firevision::SharedMemoryImageBufferMetaData::SharedMemoryImageBufferMetaData().
const char * firevision::SharedMemoryImageBuffer::image_id | ( | ) | const |
Get Image ID.
Definition at line 164 of file shm_image.cpp.
Referenced by firevision::FuseImageContent::FuseImageContent(), SharedMemoryImageBuffer(), and firevision::SharedMemoryImageBufferMetaData::SharedMemoryImageBufferMetaData().
|
static |
List all shared memory segments that contain a FireVision image.
Definition at line 491 of file shm_image.cpp.
|
static |
Get meta data about image buffers.
Definition at line 507 of file shm_image.cpp.
unsigned int firevision::SharedMemoryImageBuffer::roi_height | ( | ) | const |
Get ROI height.
Definition at line 305 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::roi_height.
Referenced by Firestation::get_window().
unsigned int firevision::SharedMemoryImageBuffer::roi_width | ( | ) | const |
Get ROI width.
Definition at line 295 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::roi_width.
Referenced by Firestation::get_window().
unsigned int firevision::SharedMemoryImageBuffer::roi_x | ( | ) | const |
Get ROI X.
Definition at line 275 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::roi_x.
Referenced by Firestation::get_window(), set_roi(), and set_roi_x().
unsigned int firevision::SharedMemoryImageBuffer::roi_y | ( | ) | const |
Get ROI Y.
Definition at line 285 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::roi_y.
Referenced by Firestation::get_window(), set_roi(), and set_roi_y().
void firevision::SharedMemoryImageBuffer::set_capture_time | ( | fawkes::Time * | time | ) |
Set the capture time.
time | capture time |
Definition at line 205 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::capture_time_sec, firevision::SharedMemoryImageBuffer_header_t::capture_time_usec, and fawkes::Time::get_timeval().
Referenced by OpenNiPointCloudThread::finalize(), FvRetrieverThread::loop(), OpenNiDepthThread::loop(), OpenNiImageThread::loop(), and Bumblebee2Thread::loop().
void firevision::SharedMemoryImageBuffer::set_capture_time | ( | long int | sec, |
long int | usec | ||
) |
Set the capture time.
sec | seconds part of capture time |
usec | microseconds part of capture time |
Definition at line 221 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::capture_time_sec, and firevision::SharedMemoryImageBuffer_header_t::capture_time_usec.
void firevision::SharedMemoryImageBuffer::set_circle | ( | int | x, |
int | y, | ||
unsigned int | r | ||
) |
Set circle data.
x | circle X |
y | circle Y |
r | circle radius |
Definition at line 458 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::circle_radius, firevision::SharedMemoryImageBuffer_header_t::circle_x, and firevision::SharedMemoryImageBuffer_header_t::circle_y.
void firevision::SharedMemoryImageBuffer::set_circle_found | ( | bool | found | ) |
Set circle found.
found | true if circle found |
Definition at line 473 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::flag_circle_found.
void firevision::SharedMemoryImageBuffer::set_circle_radius | ( | unsigned int | circle_radius | ) |
Set circle radius.
circle_radius | new circle radius |
Definition at line 443 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::circle_radius, and circle_radius().
void firevision::SharedMemoryImageBuffer::set_circle_x | ( | int | circle_x | ) |
Set circle X.
circle_x | new circle X |
Definition at line 417 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::circle_x, and circle_x().
void firevision::SharedMemoryImageBuffer::set_circle_y | ( | int | circle_y | ) |
Set circle Y.
circle_y | new circle Y |
Definition at line 430 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::circle_y, and circle_y().
void firevision::SharedMemoryImageBuffer::set_frame_id | ( | const char * | frame_id | ) |
Set frame ID.
frame_id | new frame ID |
Definition at line 153 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::frame_id, and firevision::SharedMemoryImageBufferHeader::set_frame_id().
Referenced by FvRetrieverThread::init(), and OpenNiPointCloudThread::init().
bool firevision::SharedMemoryImageBuffer::set_image_id | ( | const char * | image_id | ) |
Set image number.
This will close the currently opened image and will try to open the new image. This operation should be avoided.
image_id | new image ID |
Definition at line 137 of file shm_image.cpp.
References fawkes::SharedMemory::_memptr, fawkes::SharedMemory::attach(), fawkes::SharedMemory::free(), firevision::SharedMemoryImageBufferHeader::raw_header(), and firevision::SharedMemoryImageBufferHeader::set_image_id().
void firevision::SharedMemoryImageBuffer::set_roi | ( | unsigned int | roi_x, |
unsigned int | roi_y, | ||
unsigned int | roi_w, | ||
unsigned int | roi_h | ||
) |
Set ROI data.
Definition at line 400 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::roi_height, firevision::SharedMemoryImageBuffer_header_t::roi_width, firevision::SharedMemoryImageBuffer_header_t::roi_x, roi_x(), firevision::SharedMemoryImageBuffer_header_t::roi_y, and roi_y().
void firevision::SharedMemoryImageBuffer::set_roi_height | ( | unsigned int | roi_h | ) |
Set ROI height.
roi_h | new ROI height |
Definition at line 384 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, and firevision::SharedMemoryImageBuffer_header_t::roi_height.
void firevision::SharedMemoryImageBuffer::set_roi_width | ( | unsigned int | roi_w | ) |
Set ROI width.
roi_w | new ROI width |
Definition at line 371 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, and firevision::SharedMemoryImageBuffer_header_t::roi_width.
void firevision::SharedMemoryImageBuffer::set_roi_x | ( | unsigned int | roi_x | ) |
Set ROI X.
roi_x | new ROI X |
Definition at line 345 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::roi_x, and roi_x().
void firevision::SharedMemoryImageBuffer::set_roi_y | ( | unsigned int | roi_y | ) |
Set ROI Y.
roi_y | new ROI Y |
Definition at line 358 of file shm_image.cpp.
References fawkes::SharedMemory::_is_read_only, firevision::SharedMemoryImageBuffer_header_t::roi_y, and roi_y().
unsigned int firevision::SharedMemoryImageBuffer::width | ( | ) | const |
Get image width.
Definition at line 255 of file shm_image.cpp.
References firevision::SharedMemoryImageBuffer_header_t::width.
Referenced by firevision::FuseImageContent::FuseImageContent(), OpenNiPclOnlyThread::init(), SharedMemoryImageBuffer(), firevision::SharedMemoryImageBufferHeader::SharedMemoryImageBufferHeader(), and firevision::SharedMemoryImageBufferMetaData::SharedMemoryImageBufferMetaData().
|
static |
Erase a specific shared memory segment that contains an image.
image_id | ID of image to wipe |
Definition at line 567 of file shm_image.cpp.