CvTestbed is a class for making quick OpenCV test applications More...
#include <CvTestbed.h>
Classes | |
struct | Image |
Image structure to store the images internally. More... | |
Public Member Functions | |
IplImage * | CreateImage (const char *title, CvSize size, int depth, int channels) |
Creates an image with given size, depth and channels and stores it with a given 'title' (see CvTestbed::SetImage) More... | |
IplImage * | CreateImageWithProto (const char *title, IplImage *proto, int depth=0, int channels=0) |
Creates an image based on the given prototype and stores it with a given 'title' (see CvTestbed::SetImage) More... | |
IplImage * | GetImage (size_t index) |
Get a pointer for the stored image based on index number. More... | |
IplImage * | GetImage (const char *title) |
Get a pointer for the stored image based on title. More... | |
size_t | GetImageIndex (const char *title) |
Get an index number of the stored image based on title. More... | |
size_t | SetImage (const char *title, IplImage *ipl, bool release_at_exit=false) |
Sets an existing IplImage to be stored with the given title. More... | |
void | SetKeyCallback (int(*_keycallback)(int key)) |
Sets the keyboard callback function that will be called when keyboard is pressed. More... | |
void | SetVideoCallback (void(*_videocallback)(IplImage *image)) |
Set the videocallback function that will be called for every frame. More... | |
bool | StartVideo (Capture *_cap, const char *_wintitle=0) |
Start video input from given capture device. More... | |
void | StopVideo () |
Stop video. More... | |
bool | ToggleImageVisible (size_t index, int flags=1) |
Toggle the visibility of the stored image. More... | |
Static Public Member Functions | |
static CvTestbed & | Instance () |
The one and only instance of CvTestbed is accessed using CvTestbed::Instance() More... | |
Protected Member Functions | |
CvTestbed () | |
Hidden constructor for Singleton. More... | |
CvTestbed (const CvTestbed &) | |
Hidden copy constructor for Singleton. More... | |
CvTestbed & | operator= (const CvTestbed &) |
Hidden copy operator for Singleton. More... | |
void | ShowVisibleImages () |
ShowVisibleImages is called from the videocallback. This shows the internally stored images which have the visible-flag on More... | |
void | WaitKeys () |
WaitKeys contains the main loop. More... | |
~CvTestbed () | |
Hidden destructor for Singleton. More... | |
Static Protected Member Functions | |
static void | default_videocallback (IplImage *image) |
Video callback called for every frame. This calls user-defined videocallback if one exists. More... | |
Protected Attributes | |
Capture * | cap |
std::string | filename |
The filename if we are reading an AVI file. More... | |
std::vector< Image > | images |
Vector of images stored internally. More... | |
int(* | keycallback )(int key) |
Pointer for the user-defined KEYcallback. More... | |
bool | running |
Boolean indicating are we still running. We exit from the WaitKeys when this is false. More... | |
void(* | videocallback )(IplImage *image) |
Pointer for the user-defined videocallback. More... | |
std::string | wintitle |
The window title for the video view. More... | |
CvTestbed is a class for making quick OpenCV test applications
Usage:
In addition to handling video input from avi or from camera CvTestbed has also functions for creating and showing (and automatically releasing) IplImage's.
The CvTestbed is made into a simple Meyers singleton:
The only instance of the class is accessed using public Instance()-interface. All possible constructors and destructors are hidden. If more complex singleton approach is needed refer to Loki library or the book "Modern C++ Design".
Definition at line 66 of file CvTestbed.h.
|
protected |
Hidden constructor for Singleton.
Definition at line 3 of file CvTestbed.cpp.
|
protected |
Hidden copy constructor for Singleton.
|
protected |
Hidden destructor for Singleton.
Definition at line 11 of file CvTestbed.cpp.
IplImage * CvTestbed::CreateImage | ( | const char * | title, |
CvSize | size, | ||
int | depth, | ||
int | channels | ||
) |
Creates an image with given size, depth and channels and stores it with a given 'title' (see CvTestbed::SetImage)
Definition at line 143 of file CvTestbed.cpp.
IplImage * CvTestbed::CreateImageWithProto | ( | const char * | title, |
IplImage * | proto, | ||
int | depth = 0 , |
||
int | channels = 0 |
||
) |
Creates an image based on the given prototype and stores it with a given 'title' (see CvTestbed::SetImage)
Definition at line 150 of file CvTestbed.cpp.
|
staticprotected |
Video callback called for every frame. This calls user-defined videocallback if one exists.
Definition at line 20 of file CvTestbed.cpp.
IplImage * CvTestbed::GetImage | ( | size_t | index | ) |
Get a pointer for the stored image based on index number.
Definition at line 160 of file CvTestbed.cpp.
IplImage * CvTestbed::GetImage | ( | const char * | title | ) |
Get a pointer for the stored image based on title.
Definition at line 176 of file CvTestbed.cpp.
size_t CvTestbed::GetImageIndex | ( | const char * | title | ) |
Get an index number of the stored image based on title.
Definition at line 166 of file CvTestbed.cpp.
|
static |
The one and only instance of CvTestbed is accessed using CvTestbed::Instance()
Definition at line 88 of file CvTestbed.cpp.
size_t CvTestbed::SetImage | ( | const char * | title, |
IplImage * | ipl, | ||
bool | release_at_exit = false |
||
) |
Sets an existing IplImage to be stored with the given title.
title | Title for the image |
ipl | The IplImage to be stored |
release_at_exit | Boolean indicating should CvTestbed automatically release the image at exit |
Definition at line 126 of file CvTestbed.cpp.
void CvTestbed::SetKeyCallback | ( | int(*)(int key) | _keycallback | ) |
Sets the keyboard callback function that will be called when keyboard is pressed.
The callback should return 0 if it doesn't want the default keyboard actions to be made. By default keys '0'-'9' executes ToggleImageVisible for first 10 IplImage's, while any other key will Exit the program.
Definition at line 97 of file CvTestbed.cpp.
void CvTestbed::SetVideoCallback | ( | void(*)(IplImage *image) | _videocallback | ) |
Set the videocallback function that will be called for every frame.
Definition at line 93 of file CvTestbed.cpp.
|
protected |
ShowVisibleImages is called from the videocallback. This shows the internally stored images which have the visible-flag on
Definition at line 80 of file CvTestbed.cpp.
bool CvTestbed::StartVideo | ( | Capture * | _cap, |
const char * | _wintitle = 0 |
||
) |
Start video input from given capture device.
cap | The capture device. If NULL a default capture device is created. |
Definition at line 101 of file CvTestbed.cpp.
|
inline |
Stop video.
Definition at line 136 of file CvTestbed.h.
bool CvTestbed::ToggleImageVisible | ( | size_t | index, |
int | flags = 1 |
||
) |
Toggle the visibility of the stored image.
Definition at line 180 of file CvTestbed.cpp.
|
protected |
WaitKeys contains the main loop.
Definition at line 36 of file CvTestbed.cpp.
|
protected |
Definition at line 68 of file CvTestbed.h.
|
protected |
The filename if we are reading an AVI file.
Definition at line 87 of file CvTestbed.h.
|
protected |
Vector of images stored internally.
Definition at line 98 of file CvTestbed.h.
|
protected |
Pointer for the user-defined KEYcallback.
Definition at line 83 of file CvTestbed.h.
|
protected |
Boolean indicating are we still running. We exit from the WaitKeys when this is false.
Definition at line 78 of file CvTestbed.h.
|
protected |
Pointer for the user-defined videocallback.
Definition at line 81 of file CvTestbed.h.
|
protected |
The window title for the video view.
Definition at line 85 of file CvTestbed.h.