OpenCVWidget
Signals | Public Member Functions | Protected Member Functions | Protected Attributes
OpenCVViewer Class Reference

Widget to display frames or single images from OpenCV using OpenGL. More...

#include <opencvviewer.h>

List of all members.

Signals

void mouseClicked (QMouseEvent *event)
 Emitted each time the mouse is clicked.
void mouseMoved (QMouseEvent *event)
 Emitted when the mouse is moved and mouse tracking is on.

Public Member Functions

 OpenCVViewer (QWidget *parent=0, QGLWidget *shareWidget=0)
 Constructor.
 ~OpenCVViewer ()
QSize sizeHint () const
 Sets a default widget size of 400x300 px.
cv::Mat getImage ()
 Return the current image.
void setImage (cv::Mat newImage)
 Set image.
cv::Point mapPoint (cv::Point widgetCoords)
 Map a point in the widget to the image coordinates.

Protected Member Functions

void initializeGL ()
 Used for initializing the OpenGL session.
void paintGL ()
 Used everytime the display is refreshed.
void resizeGL (int width, int height)
 Used when the widget is resized.
void mousePressEvent (QMouseEvent *event)
 Called whenever a mousebutton is pressed.
void mouseMoveEvent (QMouseEvent *event)
 Called when the mouse is moved and mouse tracking is on.

Protected Attributes

GLuint texture
 The current OpenGL texture. Used for holding images.
QVector< QVector2D > vertices
 The vertices of the texture surface.
QVector< QVector2D > texCoords
 Texture mapping coordinates.
cv::Mat displayImage
 Holds the image to be displayed in the OpenGL-widget.

Detailed Description

Widget to display frames or single images from OpenCV using OpenGL.

This class integrates OpenCV and Qt. It is a widget that can be added to your GUI and handle display of video and single images.

To show an image, simply set it with setImage() and the display will automatically be updated.

Definition at line 27 of file opencvviewer.h.


Constructor & Destructor Documentation

OpenCVViewer::OpenCVViewer ( QWidget *  parent = 0,
QGLWidget *  shareWidget = 0 
)

Constructor.

Creates a new OpenCVViewer. Be aware that the capture source must be set before any capture can commence. See setSource().

Definition at line 5 of file opencvviewer.cpp.

Definition at line 11 of file opencvviewer.cpp.


Member Function Documentation

Return the current image.

This function returns the current image. Note that this is a shallow copy (as per OpenCV's memory management), so any alterations of the returned Mat will reflect in the original Mat being displayed in the OpenGL object.

Returns:
a shallow copy of the moest recently capture image.

Definition at line 20 of file opencvviewer.cpp.

void OpenCVViewer::initializeGL ( ) [protected]

Used for initializing the OpenGL session.

Definition at line 33 of file opencvviewer.cpp.

cv::Point OpenCVViewer::mapPoint ( cv::Point  widgetCoords)

Map a point in the widget to the image coordinates.

Parameters:
thepoint in the widget coordinate system.
Returns:
the point in the image coordinate system.

Definition at line 151 of file opencvviewer.cpp.

void OpenCVViewer::mouseClicked ( QMouseEvent *  event) [signal]

Emitted each time the mouse is clicked.

void OpenCVViewer::mouseMoved ( QMouseEvent *  event) [signal]

Emitted when the mouse is moved and mouse tracking is on.

void OpenCVViewer::mouseMoveEvent ( QMouseEvent *  event) [protected]

Called when the mouse is moved and mouse tracking is on.

Definition at line 146 of file opencvviewer.cpp.

void OpenCVViewer::mousePressEvent ( QMouseEvent *  event) [protected]

Called whenever a mousebutton is pressed.

Definition at line 141 of file opencvviewer.cpp.

void OpenCVViewer::paintGL ( ) [protected]

Used everytime the display is refreshed.

Definition at line 56 of file opencvviewer.cpp.

void OpenCVViewer::resizeGL ( int  width,
int  height 
) [protected]

Used when the widget is resized.

Definition at line 122 of file opencvviewer.cpp.

void OpenCVViewer::setImage ( cv::Mat  newImage)

Set image.

Overwrites the previous display image and updates the display.

Parameters:
theimage to display.

Definition at line 25 of file opencvviewer.cpp.

QSize OpenCVViewer::sizeHint ( ) const

Sets a default widget size of 400x300 px.

Returns:
the preferred size of the widget.

Definition at line 15 of file opencvviewer.cpp.


Member Data Documentation

cv::Mat OpenCVViewer::displayImage [protected]

Holds the image to be displayed in the OpenGL-widget.

Definition at line 90 of file opencvviewer.h.

QVector<QVector2D> OpenCVViewer::texCoords [protected]

Texture mapping coordinates.

Definition at line 89 of file opencvviewer.h.

GLuint OpenCVViewer::texture [protected]

The current OpenGL texture. Used for holding images.

Definition at line 87 of file opencvviewer.h.

QVector<QVector2D> OpenCVViewer::vertices [protected]

The vertices of the texture surface.

Definition at line 88 of file opencvviewer.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables