Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
tutorial-grabber-1394-writer.cpp
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpImage.h>
#include <visp3/gui/vpDisplayFactory.h>
#include <visp3/io/vpVideoWriter.h>
#include <visp3/sensor/vp1394TwoGrabber.h>
int main(int argc, char **)
{
#ifdef VISP_HAVE_DC1394
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
#ifdef VISP_HAVE_DISPLAY
#else
std::cout << "No image viewer is available..." << std::endl;
#endif
try {
bool save = false;
if (argc == 2) {
save = true;
}
vpImage<vpRGBa> I; // Create a color image container
bool reset = true; // Enable bus reset during construction (default)
vp1394TwoGrabber g(reset); // Create a grabber based on libdc1394-2.x third party lib
g.open(I);
std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl;
vpVideoWriter writer;
writer.setFileName("./I%04d.pgm");
if (save)
writer.open(I);
#ifdef VISP_HAVE_DISPLAY
d->init(I);
while (1)
#else
// for loop when no display is available to avoid infinite while loop
for (unsigned int i = 0; i < 1000; ++i)
#endif
{
g.acquire(I);
if (save)
writer.saveFrame(I);
#ifdef VISP_HAVE_DISPLAY
if (vpDisplay::getClick(I, false)) {
break;
}
#endif
}
if (save) {
writer.close();
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#ifdef VISP_HAVE_DISPLAY
if (d != nullptr) {
delete d;
}
#endif
#else
(void)argc;
#endif
return EXIT_SUCCESS;
}
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void acquire(vpImage< unsigned char > &I)
void setVideoMode(vp1394TwoVideoModeType videomode)
void setFramerate(vp1394TwoFramerateType fps)
void open(vpImage< unsigned char > &I)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") VP_OVERRIDE
Class that defines generic functionalities for display.
Definition: vpDisplay.h:178
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
Definition: vpException.h:60
unsigned int getWidth() const
Definition: vpImage.h:242
unsigned int getHeight() const
Definition: vpImage.h:181
Class that enables to write easily a video file or a sequence of images.
void saveFrame(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
void open(vpImage< vpRGBa > &I)
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.