12 for (
size_t i=0; i<
images.size(); i++) {
13 if (
images[i].release_at_exit) {
14 cvReleaseImage(&(
images[i].ipl));
38 static bool pause =
false;
45 cvShowImage(
wintitle.c_str(), frame);
51 if( (key = cvWaitKey(1)) >= 0 ) {
53 if( (key = cvWaitKey(20)) >= 0 ) {
66 else if ((key >=
'0') && (key <=
'9')) {
81 for (
size_t i=0; i<
images.size(); i++) {
106 if (vec.size() < 1)
return false;
107 cap = CaptureFactory::instance()->createCapture(vec[0]);
116 cvNamedWindow(_wintitle, 1);
130 Image i(ipl, title,
false, release_at_exit);
135 if (
images[index].release_at_exit) {
136 cvReleaseImage(&(
images[index].ipl));
139 images[index].release_at_exit = release_at_exit;
144 IplImage *ipl=cvCreateImage(size, depth, channels);
145 if (!ipl)
return NULL;
151 if (depth == 0) depth = proto->depth;
152 if (channels == 0) channels = proto->nChannels;
153 IplImage *ipl= cvCreateImage(cvSize(proto->width, proto->height), depth, channels);
154 if (!ipl)
return NULL;
155 ipl->origin = proto->origin;
161 if (index < 0)
return NULL;
162 if (index >=
images.size())
return NULL;
167 std::string
s(title);
168 for (
size_t i=0; i<
images.size(); i++) {
169 if (s.compare(
images[i].title) == 0) {
181 if (index >=
images.size())
return false;
182 if (
images[index].visible ==
false) {
183 images[index].visible=
true;
184 cvNamedWindow(
images[index].title.c_str(), flags);
188 images[index].visible=
false;
189 cvDestroyWindow(
images[index].title.c_str());
Image structure to store the images internally.
static CvTestbed & Instance()
The one and only instance of CvTestbed is accessed using CvTestbed::Instance()
std::vector< Image > images
Vector of images stored internally.
static void default_videocallback(IplImage *image)
Video callback called for every frame. This calls user-defined videocallback if one exists...
virtual void stop()=0
Stops the camera capture.
virtual bool start()=0
Starts the camera capture.
bool running
Boolean indicating are we still running. We exit from the WaitKeys when this is false.
void SetVideoCallback(void(*_videocallback)(IplImage *image))
Set the videocallback function that will be called for every frame.
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 CvTestbe...
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::SetI...
ROSCPP_DECL std::string clean(const std::string &name)
IplImage * GetImage(size_t index)
Get a pointer for the stored image based on index number.
std::vector< CaptureDevice > CaptureDeviceVector
Vector of CaptureDevices.
std::string wintitle
The window title for the video view.
bool StartVideo(Capture *_cap, const char *_wintitle=0)
Start video input from given capture device.
size_t GetImageIndex(const char *title)
Get an index number of the stored image based on title.
void SetKeyCallback(int(*_keycallback)(int key))
Sets the keyboard callback function that will be called when keyboard is pressed. ...
virtual bool showSettingsDialog()=0
Show the settings dialog of the camera.
void(* videocallback)(IplImage *image)
Pointer for the user-defined videocallback.
int(* keycallback)(int key)
Pointer for the user-defined KEYcallback.
bool ToggleImageVisible(size_t index, int flags=1)
Toggle the visibility of the stored image.
virtual IplImage * captureImage()=0
Capture one image from the camera.
Capture interface that plugins must implement.
size_t SetImage(const char *title, IplImage *ipl, bool release_at_exit=false)
Sets an existing IplImage to be stored with the given title.
void WaitKeys()
WaitKeys contains the main loop.
void ShowVisibleImages()
ShowVisibleImages is called from the videocallback. This shows the internally stored images which hav...
CvTestbed()
Hidden constructor for Singleton.
~CvTestbed()
Hidden destructor for Singleton.
CvTestbed is a class for making quick OpenCV test applications