Fawkes API  Fawkes Development Version
firevision::ImageWidget Class Reference

This class is an image container to display fawkes cameras (or image buffers) inside a Gtk::Container. More...

#include <>>

Inheritance diagram for firevision::ImageWidget:

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...
 

Detailed Description

This class is an image container to display fawkes cameras (or image buffers) inside a Gtk::Container.

Author
Christof Rath

Definition at line 45 of file image_widget.h.

Constructor & Destructor Documentation

◆ ImageWidget() [1/3]

firevision::ImageWidget::ImageWidget ( unsigned int  width,
unsigned int  height 
)

Creates a new ImageWidget with predefined width and height.

Parameters
widthof the widget
heightof the widget

Definition at line 52 of file image_widget.cpp.

References set_size().

Referenced by ImageWidget().

◆ ImageWidget() [2/3]

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.

Parameters
camthe image source
refresh_delayif greater 0 a thread gets created that refreshes the Image every refresh_delay milliseconds
widthof the widget (if not equal to the camera width the image gets scaled)
heightof 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().

◆ ImageWidget() [3/3]

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

See also
ImageWidget::set_size() to resize the ImageWidget afterwards.
Parameters
cobjectpointer to the base object
builderBuilder

Definition at line 108 of file image_widget.cpp.

References ImageWidget().

◆ ~ImageWidget()

firevision::ImageWidget::~ImageWidget ( )
virtual

Destructor.

Definition at line 145 of file image_widget.cpp.

Member Function Documentation

◆ enable_camera()

void firevision::ImageWidget::enable_camera ( bool  enable)

En-/disable the camera.

Parameters
enableif 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.

◆ get_buffer()

Glib::RefPtr< Gdk::Pixbuf > firevision::ImageWidget::get_buffer ( ) const

Returns the widgets pixel buffer (RGB!)

Returns
the RGB pixel buffer

Definition at line 269 of file image_widget.cpp.

◆ get_height()

unsigned int firevision::ImageWidget::get_height ( ) const

Returns the image buffer height.

Returns
height of the contained image

Definition at line 259 of file image_widget.cpp.

◆ get_image_num()

unsigned int firevision::ImageWidget::get_image_num ( )

Returns the latest image number.

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().

◆ get_width()

unsigned int firevision::ImageWidget::get_width ( ) const

Returns the image buffer width.

Returns
width of the contained image

Definition at line 249 of file image_widget.cpp.

◆ refresh_cam()

void firevision::ImageWidget::refresh_cam ( )

◆ save_image()

bool firevision::ImageWidget::save_image ( std::string  filename,
Glib::ustring  type 
) const
throw (
)

Saves the current content of the Image.

Parameters
filenameof the output
typeof 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().)
Returns
true on success, false otherwise

Definition at line 431 of file image_widget.cpp.

References fawkes::Mutex::lock(), and fawkes::Mutex::unlock().

Referenced by FuseViewerGtkWindow::~FuseViewerGtkWindow().

◆ save_on_refresh_cam()

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.

Parameters
enableenables or disables the feature
pathto save the images at
typefile type (
See also
ImageWidget::save_image)
Parameters
img_numof 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().

◆ set_camera()

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.

Parameters
camthe camera
refresh_delaythe 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().

◆ set_refresh_delay()

void firevision::ImageWidget::set_refresh_delay ( unsigned int  refresh_delay)

Sets the refresh delay for automatic camera refreshes.

Parameters
refresh_delayim [ms]

Definition at line 383 of file image_widget.cpp.

◆ set_rgb() [1/2]

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.

Parameters
xposition of the pixel
yposition of the pixel
rcomponent of the color
gcomponent of the color
bcomponent of the color

Definition at line 284 of file image_widget.cpp.

◆ set_rgb() [2/2]

void firevision::ImageWidget::set_rgb ( unsigned int  x,
unsigned int  y,
RGB_t  rgb 
)

Sets a pixel to the given RGB colors.

Parameters
xposition of the pixel
yposition of the pixel
rgbthe color

Definition at line 297 of file image_widget.cpp.

◆ set_size()

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!

Parameters
widthThe new width
heightThe 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().

◆ show()

bool firevision::ImageWidget::show ( colorspace_t  colorspace,
unsigned char *  buffer,
unsigned int  width = 0,
unsigned int  height = 0 
)
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.

Parameters
colorspacecolorspace of the supplied buffer
bufferimage buffer
widthWidth of the provided buffer (may be scaled to ImageWidget dimensions)
heightHeight of the provided buffer (may be scaled to ImageWidget dimensions)
Returns
TRUE if the buffer chould have been shown

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().

◆ signal_show()

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.

See also
ImageWidget::show()).

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.

Returns
The signal_show signal

Definition at line 371 of file image_widget.cpp.


The documentation for this class was generated from the following files: