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

List of all members.

Classes

class  RefThread

Public Member Functions

 ImageWidget (unsigned int width, unsigned int height)
 Creates a new ImageWidget with predefined width and height.
 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.
virtual ~ImageWidget ()
 Destructor.
void set_camera (Camera *cam, unsigned int refresh_delay=0)
 Set the camera from which the ImageWidget obtains the images.
void enable_camera (bool enable)
 En-/disable the camera.
void set_size (unsigned int width, unsigned int height)
 Sets the size of the ImageWidget.
virtual bool show (colorspace_t colorspace, unsigned char *buffer, unsigned int width=0, unsigned int height=0)
 Show image from given colorspace.
void set_refresh_delay (unsigned int refresh_delay)
 Sets the refresh delay for automatic camera refreshes.
void refresh_cam ()
 Performs a refresh during the next loop of the refresh thread.
unsigned int get_width () const
 Returns the image buffer width.
unsigned int get_height () const
 Returns the image buffer height.
Glib::RefPtr< Gdk::Pixbuf > get_buffer () const
 Returns the widgets pixel buffer (RGB!)
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.
void set_rgb (unsigned int x, unsigned int y, RGB_t rgb)
 Sets a pixel to the given RGB colors.
bool save_image (std::string filename, Glib::ustring type) const throw ()
 Saves the current content of the Image.
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.
unsigned int get_image_num ()
 Returns the latest image number.
sigc::signal< void,
colorspace_t, unsigned char
*, unsigned int, unsigned int > & 
signal_show ()
 Signal emits after a new buffer gets successfully shown (see.

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

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 53 of file image_widget.cpp.

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 73 of file image_widget.cpp.

firevision::ImageWidget::~ImageWidget ( ) [virtual]

Destructor.

Definition at line 125 of file image_widget.cpp.


Member Function Documentation

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 175 of file image_widget.cpp.

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

Returns the widgets pixel buffer (RGB!)

Returns:
the RGB pixel buffer

Definition at line 249 of file image_widget.cpp.

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

Returns the image buffer height.

Returns:
height of the contained image

Definition at line 239 of file image_widget.cpp.

unsigned int firevision::ImageWidget::get_image_num ( )

Returns the latest image number.

Returns:
the latest image number

Definition at line 452 of file image_widget.cpp.

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

Returns the image buffer width.

Returns:
width of the contained image

Definition at line 229 of file image_widget.cpp.

void firevision::ImageWidget::refresh_cam ( )

Performs a refresh during the next loop of the refresh thread.

Definition at line 373 of file image_widget.cpp.

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 411 of file image_widget.cpp.

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 442 of file image_widget.cpp.

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

Parameters:
refresh_delayim [ms]

Definition at line 363 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.

Parameters:
xposition of the pixel
yposition of the pixel
rgbthe color

Definition at line 277 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.

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

Definition at line 264 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!

Parameters:
widthThe new width
heightThe new height

Definition at line 197 of file image_widget.cpp.

References firevision::Camera::pixel_height(), and firevision::Camera::pixel_width().

Referenced by set_camera().

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

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 351 of file image_widget.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends