Acquire images using Pylon library.
Acquire images using Pylon library.
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#include <iostream>
#include <string>
#if defined(VISP_HAVE_PYLON)
#include <visp3/core/vpIoTools.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/sensor/vpPylonFactory.h>
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
try {
std::cout << "Basler camera test with Pylon in progress..." << std::endl;
std::string username;
std::string outputpath = "/tmp/" + username;
std::string guid;
unsigned int ncameras;
for (unsigned int i = 0; i < ncameras; i++) {
std::cout << "Detected camera with serial: " << guid << std::endl;
}
if (ncameras > 1) {
std::cout << "Use camera with serial: " << guid << std::endl;
}
std::cout <<
"Frame rate: " << g->
getFrameRate() << std::endl;
std::cout <<
"Gain: " << g->
getGain() << std::endl;
std::cout <<
"Gamma: " << g->
getGamma() << std::endl;
std::cout <<
"Exposure time (ms): " << g->
getExposure() << std::endl;
std::cout << "Black level: " << blackLevel << std::endl;
for (int i = 0; i < 10; i++)
std::cout <<
"Current image size: " << g->
getWidth() <<
"x" << g->
getHeight() << std::endl;
std::string filename = outputpath + "/imagetest1.pgm";
std::cout << "Write image: " << filename << std::endl;
std::cout << "New connection..." << std::endl;
std::cout << "New connection..." << std::endl;
filename = outputpath + "/imagetest2.pgm";
std::cout << "Write image: " << filename << std::endl;
}
}
catch (const std::exception &e) {
}
catch (...) {
vpCERROR <<
"Failure: exit" << std::endl;
}
}
#else
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
vpTRACE(
"Basler Pylon grabber capabilities are not available...\n"
"You should install pylon SDK to use this binary.");
}
#endif
error that can be emitted by ViSP classes.
unsigned int getWidth() const
Return the number of columns in the image.
unsigned int getHeight() const
Return the number of rows in the image.
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition of the vpImage class member functions.
Factory singleton class to create vpPylonGrabber subclass instances.
static vpPylonFactory & instance()
Get the vpPylonFactory singleton.
@ BASLER_GIGE
Basler GigE camera.
vpPylonGrabber * createPylonGrabber(DeviceClass dev_class)
Create an object of vpPylonGrabber.
virtual void close()=0
Stop active camera capturing images and disconnect the active camera.
virtual float getFrameRate()=0
virtual unsigned int getNumCameras()=0
Get the number of cameras of specific subclasses. GigE, USB, etc.
virtual void setCameraSerial(const std::string &serial)=0
virtual float getBlackLevel()=0
virtual float getGain()=0
virtual void acquire(vpImage< unsigned char > &I)=0
virtual float getExposure()=0
virtual void open(vpImage< unsigned char > &I)=0
virtual std::string getCameraSerial(unsigned int index)=0
virtual void setCameraIndex(unsigned int index)=0
virtual std::ostream & getCameraInfo(std::ostream &os)=0
virtual float getGamma()=0