Fawkes API
Fawkes Development Version
|
This class is an image container to display fawkes cameras (or image buffers) inside a Gtk::Container. More...
#include <>>
Public Member Functions | |
ImageWidget (unsigned int width, unsigned int height) | |
Creates a new ImageWidget with predefined width and height. More... | |
ImageWidget (Camera *cam, unsigned int refresh_delay=0, unsigned int width=0, unsigned int height=0) | |
Creates a new ImageWidget with a Camera as image source. More... | |
ImageWidget (BaseObjectType *cobject, Glib::RefPtr< Gtk::Builder > builder) | |
Constructor for Gtk::Builder. More... | |
virtual | ~ImageWidget () |
Destructor. More... | |
void | set_camera (Camera *cam, unsigned int refresh_delay=0) |
Set the camera from which the ImageWidget obtains the images. More... | |
void | enable_camera (bool enable) |
En-/disable the camera. More... | |
void | set_size (unsigned int width, unsigned int height) |
Sets the size of the ImageWidget. More... | |
virtual bool | show (colorspace_t colorspace, unsigned char *buffer, unsigned int width=0, unsigned int height=0) |
Show image from given colorspace. More... | |
void | set_refresh_delay (unsigned int refresh_delay) |
Sets the refresh delay for automatic camera refreshes. More... | |
void | refresh_cam () |
Performs a refresh during the next loop of the refresh thread. More... | |
unsigned int | get_width () const |
Returns the image buffer width. More... | |
unsigned int | get_height () const |
Returns the image buffer height. More... | |
Glib::RefPtr< Gdk::Pixbuf > | get_buffer () const |
Returns the widgets pixel buffer (RGB!) More... | |
void | set_rgb (unsigned int x, unsigned int y, unsigned char r, unsigned char g, unsigned char b) |
Sets a pixel to the given RGB colors. More... | |
void | set_rgb (unsigned int x, unsigned int y, RGB_t rgb) |
Sets a pixel to the given RGB colors. More... | |
bool | save_image (std::string filename, Glib::ustring type) const throw () |
Saves the current content of the Image. More... | |
void | save_on_refresh_cam (bool enabled, std::string path="", Glib::ustring type="", unsigned int img_num=0) |
Saves the content of the image on every refresh. More... | |
unsigned int | get_image_num () |
Returns the latest image number. More... | |
sigc::signal< void, colorspace_t, unsigned char *, unsigned int, unsigned int > & | signal_show () |
Signal emits after a new buffer gets successfully shown (see. More... | |
This class is an image container to display fawkes cameras (or image buffers) inside a Gtk::Container.
Definition at line 45 of file image_widget.h.
firevision::ImageWidget::ImageWidget | ( | unsigned int | width, |
unsigned int | height | ||
) |
Creates a new ImageWidget with predefined width and height.
width | of the widget |
height | of the widget |
Definition at line 52 of file image_widget.cpp.
References set_size().
Referenced by ImageWidget().
firevision::ImageWidget::ImageWidget | ( | Camera * | cam, |
unsigned int | refresh_delay = 0 , |
||
unsigned int | width = 0 , |
||
unsigned int | height = 0 |
||
) |
Creates a new ImageWidget with a Camera as image source.
cam | the image source |
refresh_delay | if greater 0 a thread gets created that refreshes the Image every refresh_delay milliseconds |
width | of the widget (if not equal to the camera width the image gets scaled) |
height | of the widget (if not equal to the camera height the image gets scaled) |
Definition at line 72 of file image_widget.cpp.
References firevision::Camera::capture_time(), and set_size().
firevision::ImageWidget::ImageWidget | ( | BaseObjectType * | cobject, |
Glib::RefPtr< Gtk::Builder > | builder | ||
) |
Constructor for Gtk::Builder.
Constructor that can be used to instantiate an ImageWidget as a derived widget from a Gtk builder file.
Note: The ImageWidget (and its internal buffer) is set to the size as in the UI file, in case no camera is set afterwards. Use
cobject | pointer to the base object |
builder | Builder |
Definition at line 108 of file image_widget.cpp.
References ImageWidget().
|
virtual |
Destructor.
Definition at line 145 of file image_widget.cpp.
void firevision::ImageWidget::enable_camera | ( | bool | enable | ) |
En-/disable the camera.
enable | if true the camera is enabled and the refresh thread is start, if false the refresh thread is stopped and the camera is disabled |
Definition at line 195 of file image_widget.cpp.
Glib::RefPtr< Gdk::Pixbuf > firevision::ImageWidget::get_buffer | ( | ) | const |
Returns the widgets pixel buffer (RGB!)
Definition at line 269 of file image_widget.cpp.
unsigned int firevision::ImageWidget::get_height | ( | ) | const |
Returns the image buffer height.
Definition at line 259 of file image_widget.cpp.
unsigned int firevision::ImageWidget::get_image_num | ( | ) |
Returns the latest image number.
Definition at line 467 of file image_widget.cpp.
References fawkes::Time::in_msec(), and fawkes::Exception::what().
Referenced by FuseViewerGtkWindow::~FuseViewerGtkWindow().
unsigned int firevision::ImageWidget::get_width | ( | ) | const |
Returns the image buffer width.
Definition at line 249 of file image_widget.cpp.
void firevision::ImageWidget::refresh_cam | ( | ) |
Performs a refresh during the next loop of the refresh thread.
Definition at line 393 of file image_widget.cpp.
References firevision::Camera::buffer(), firevision::Camera::colorspace(), firevision::Camera::flush(), fawkes::Mutex::lock(), firevision::Camera::pixel_height(), firevision::Camera::pixel_width(), show(), and fawkes::Mutex::unlock().
bool firevision::ImageWidget::save_image | ( | std::string | filename, |
Glib::ustring | type | ||
) | const | ||
throw | ( | ||
) |
Saves the current content of the Image.
filename | of the output |
type | of the output (By default, "jpeg", "png", "ico" and "bmp" are possible file formats to save in, but more formats may be installed. The list of all writable formats can be determined by using Gdk::Pixbuf::get_formats() with Gdk::PixbufFormat::is_writable().) |
Definition at line 431 of file image_widget.cpp.
References fawkes::Mutex::lock(), and fawkes::Mutex::unlock().
Referenced by FuseViewerGtkWindow::~FuseViewerGtkWindow().
void firevision::ImageWidget::save_on_refresh_cam | ( | bool | enable, |
std::string | path = "" , |
||
Glib::ustring | type = "" , |
||
unsigned int | img_num = 0 |
||
) |
Saves the content of the image on every refresh.
enable | enables or disables the feature |
path | to save the images at |
type | file type ( |
img_num | of which to start the numbering (actually the first image is numbered img_num + 1) |
Definition at line 457 of file image_widget.cpp.
Referenced by FuseViewerGtkWindow::~FuseViewerGtkWindow().
void firevision::ImageWidget::set_camera | ( | Camera * | cam, |
unsigned int | refresh_delay = 0 |
||
) |
Set the camera from which the ImageWidget obtains the images.
Note: The size of the ImageWidget remains untouched and the cameras image gets scaled appropriately. Use ImageWidget::set_size(0, 0) to set the widget to the size of the camera.
cam | the camera |
refresh_delay | the delay between two refreshs in milliseconds |
Definition at line 161 of file image_widget.cpp.
References firevision::Camera::capture_time(), firevision::Camera::pixel_height(), firevision::Camera::pixel_width(), and set_size().
void firevision::ImageWidget::set_refresh_delay | ( | unsigned int | refresh_delay | ) |
Sets the refresh delay for automatic camera refreshes.
refresh_delay | im [ms] |
Definition at line 383 of file image_widget.cpp.
void firevision::ImageWidget::set_rgb | ( | unsigned int | x, |
unsigned int | y, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b | ||
) |
Sets a pixel to the given RGB colors.
x | position of the pixel |
y | position of the pixel |
r | component of the color |
g | component of the color |
b | component of the color |
Definition at line 284 of file image_widget.cpp.
void firevision::ImageWidget::set_rgb | ( | unsigned int | x, |
unsigned int | y, | ||
RGB_t | rgb | ||
) |
Sets a pixel to the given RGB colors.
x | position of the pixel |
y | position of the pixel |
rgb | the color |
Definition at line 297 of file image_widget.cpp.
void firevision::ImageWidget::set_size | ( | unsigned int | width, |
unsigned int | height | ||
) |
Sets the size of the ImageWidget.
Updates the internal buffer and the size request for the ImageWidget. If width and/or height are set to 0 (and a Camera is set) the ImageWidget will be set to the camera dimensions.
Note: The ImageWidget must be refreshed after changing its size!
width | The new width |
height | The new height |
Definition at line 217 of file image_widget.cpp.
References firevision::Camera::pixel_height(), and firevision::Camera::pixel_width().
Referenced by ImageWidget(), and set_camera().
|
virtual |
Show image from given colorspace.
Warning: If width and/or height not set, it is assumed, that the given buffer has the same dimension as the widget.
colorspace | colorspace of the supplied buffer |
buffer | image buffer |
width | Width of the provided buffer (may be scaled to ImageWidget dimensions) |
height | Height of the provided buffer (may be scaled to ImageWidget dimensions) |
Definition at line 320 of file image_widget.cpp.
References firevision::LossyScaler::scale(), firevision::LossyScaler::set_original_buffer(), firevision::LossyScaler::set_original_dimensions(), firevision::LossyScaler::set_scaled_buffer(), firevision::LossyScaler::set_scaled_dimensions(), and fawkes::Exception::what().
Referenced by refresh_cam(), and YuvViewerGtkWindow::~YuvViewerGtkWindow().
sigc::signal< void, colorspace_t, unsigned char *, unsigned int, unsigned int > & firevision::ImageWidget::signal_show | ( | ) |
Signal emits after a new buffer gets successfully shown (see.
The buffer's validity can not be guaranteed beyond the called functions scope! In case the source of the widget is a Camera, the buffer gets disposed after calling ImageWidget::show.
Definition at line 371 of file image_widget.cpp.