44 #include "vpPylonGrabberUsb.h" 46 #ifdef VISP_HAVE_PYLON 48 #include <visp3/core/vpException.h> 49 #include <visp3/core/vpTime.h> 70 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
71 Pylon::DeviceInfoList_t lstDevices;
72 Pylon::DeviceInfoList_t filter;
73 Pylon::CBaslerUsbDeviceInfo usb_devinfo;
74 filter.push_back(usb_devinfo);
75 TlFactory.EnumerateDevices(lstDevices, filter);
77 m_numCameras = lstDevices.size();
90 Pylon::CDeviceInfo deviceInfo = m_camera.GetDeviceInfo();
92 GenApi::INodeMap &control = m_camera.GetNodeMap();
94 GenApi::CIntegerPtr widthMax = control.GetNode(
"WidthMax");
95 GenApi::CIntegerPtr heightMax = control.GetNode(
"HeightMax");
97 os <<
"Camera information: " << std::endl;
98 os <<
" Serial number : " << deviceInfo.GetSerialNumber() << std::endl;
99 os <<
" Camera model : " << deviceInfo.GetModelName() << std::endl;
100 os <<
" Camera vendor : " << deviceInfo.GetVendorName() << std::endl;
101 os <<
" Resolution : " << widthMax->GetValue() <<
"x" << heightMax->GetValue() << std::endl;
102 os <<
" Firmware version : " << deviceInfo.GetDeviceVersion() << std::endl;
117 if (m_connected ==
true) {
134 float frame_rate = m_camera.AcquisitionFrameRate.GetValue();
148 if (GenApi::IsReadable(m_camera.Gain))
149 return m_camera.Gain.GetValue();
169 if (GenApi::IsReadable(m_camera.BlackLevel))
170 return m_camera.BlackLevel.GetValue();
190 if (GenApi::IsReadable(m_camera.ExposureTime))
191 return m_camera.ExposureTime.GetValue() * 0.001;
206 float gamma = m_camera.Gamma.GetValue();
220 if (index >= m_numCameras) {
222 index, m_numCameras));
225 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
226 Pylon::DeviceInfoList_t lstDevices;
227 Pylon::DeviceInfoList_t filter;
228 Pylon::CBaslerUsbDeviceInfo usb_devinfo;
229 filter.push_back(usb_devinfo);
230 TlFactory.EnumerateDevices(lstDevices, filter);
232 std::ostringstream os;
233 os << lstDevices[index].GetSerialNumber();
253 m_camera.UserSetLoad.Execute();
255 success = m_camera.UserSetLoad.IsDone();
271 Basler_UsbCameraParams::UserSetDefaultEnums user_set = m_camera.UserSetDefault.GetValue();
274 case Basler_UsbCameraParams::UserSetDefault_Default:
277 case Basler_UsbCameraParams::UserSetDefault_UserSet1:
280 case Basler_UsbCameraParams::UserSetDefault_UserSet2:
283 case Basler_UsbCameraParams::UserSetDefault_UserSet3:
309 if (index >= m_numCameras) {
311 index, m_numCameras));
326 for (
unsigned int i = 0; i < m_numCameras; i++) {
346 m_camera.AcquisitionFrameRate.SetValue(frame_rate);
348 return m_camera.AcquisitionFrameRate.GetValue();
369 m_camera.GainAuto.SetValue(Basler_UsbCameraParams::GainAuto_Continuous);
371 m_camera.GainAuto.SetValue(Basler_UsbCameraParams::GainAuto_Off);
373 if (GenApi::IsWritable(m_camera.Gain)) {
374 m_camera.Gain.SetValue(gain_value);
375 return m_camera.Gain.GetValue();
398 if (GenApi::IsWritable(m_camera.BlackLevel)) {
399 m_camera.BlackLevel.SetValue(blacklevel_value);
400 return m_camera.BlackLevel.GetValue();
427 m_camera.ExposureMode.SetValue(Basler_UsbCameraParams::ExposureMode_Timed);
429 m_camera.ExposureMode.SetValue(Basler_UsbCameraParams::ExposureMode_TriggerWidth);
432 m_camera.ExposureAuto.SetValue(Basler_UsbCameraParams::ExposureAuto_Continuous);
434 m_camera.ExposureAuto.SetValue(Basler_UsbCameraParams::ExposureAuto_Off);
436 if (GenApi::IsWritable(m_camera.ExposureTime)) {
437 m_camera.ExposureTime.SetValue(exposure_value * 1000);
438 return m_camera.ExposureTime.GetValue() * 0.001;
459 if (GenApi::IsWritable(m_camera.Gamma)) {
461 m_camera.Gamma.SetValue(gamma_value);
463 m_camera.Gamma.SetValue(1);
464 return m_camera.Gamma.GetValue();
487 m_camera.UserSetSave.Execute();
489 success = m_camera.UserSetSave.IsDone();
492 if (success && set_default)
513 m_camera.UserSetDefault.SetValue(Basler_UsbCameraParams::UserSetDefault_Default);
517 m_camera.UserSetDefault.SetValue(Basler_UsbCameraParams::UserSetDefault_UserSet1);
521 m_camera.UserSetDefault.SetValue(Basler_UsbCameraParams::UserSetDefault_UserSet2);
525 m_camera.UserSetDefault.SetValue(Basler_UsbCameraParams::UserSetDefault_UserSet3);
542 if (!m_camera.IsGrabbing()) {
543 m_camera.StartGrabbing(1);
545 if (m_connected && m_camera.IsGrabbing())
558 if (m_camera.IsGrabbing()) {
559 m_camera.StopGrabbing();
561 if (m_connected && m_camera.IsGrabbing())
574 if (m_connected ==
false) {
576 if (m_numCameras == 0) {
580 if (!m_camera.IsPylonDeviceAttached()) {
581 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
582 Pylon::DeviceInfoList_t lstDevices;
583 Pylon::DeviceInfoList_t filter;
584 Pylon::CBaslerUsbDeviceInfo usb_devinfo;
585 filter.push_back(usb_devinfo);
586 TlFactory.EnumerateDevices(lstDevices, filter);
588 m_camera.Attach(TlFactory.CreateDevice(lstDevices[m_index]));
594 if (m_connected && m_camera.IsGrabbing())
607 if (m_connected ==
true) {
611 if (m_connected && m_camera.IsGrabbing())
640 Pylon::CGrabResultPtr grabResult;
642 if (!m_camera.RetrieveResult(2000, grabResult)) {
647 if (grabResult->GrabSucceeded()) {
648 height = grabResult->GetHeight();
649 width = grabResult->GetWidth();
652 Pylon::CImageFormatConverter imageConvert;
653 imageConvert.OutputPixelFormat = Pylon::PixelType_Mono8;
654 imageConvert.OutputPaddingX = 0;
656 imageConvert.Convert(I.
bitmap,
sizeof(
unsigned char) *
width *
height, (Pylon::IImage &)grabResult);
669 Pylon::CGrabResultPtr grabResult;
671 if (!m_camera.RetrieveResult(2000, grabResult)) {
676 if (grabResult->GrabSucceeded()) {
677 height = grabResult->GetHeight();
678 width = grabResult->GetWidth();
681 Pylon::CImageFormatConverter imageConvert;
682 imageConvert.OutputPixelFormat = Pylon::PixelType_BGRA8packed;
683 imageConvert.OutputPaddingX = 0;
685 Pylon::CPylonImage destImage;
686 imageConvert.Convert(destImage, (Pylon::IImage &)grabResult);
687 Pylon::SBGRA8Pixel *pixel = (Pylon::SBGRA8Pixel *)destImage.GetBuffer();
688 for (
unsigned int i = 0; i <
height; i++) {
689 for (
unsigned int j = 0; j <
width; j++) {
690 unsigned int p_index = i * width + j;
691 I[i][j].R = pixel[p_index].R;
692 I[i][j].G = pixel[p_index].G;
693 I[i][j].B = pixel[p_index].B;
694 I[i][j].A = pixel[p_index].A;
751 m_camera.UserSetSelector.SetValue(Basler_UsbCameraParams::UserSetSelector_Default);
755 m_camera.UserSetSelector.SetValue(Basler_UsbCameraParams::UserSetSelector_UserSet1);
759 m_camera.UserSetSelector.SetValue(Basler_UsbCameraParams::UserSetSelector_UserSet2);
763 m_camera.UserSetSelector.SetValue(Basler_UsbCameraParams::UserSetSelector_UserSet3);
794 void dummy_vpPylonGrabberUsb(){};
795 #endif // #ifdef VISP_HAVE_PYLON bool loadUserSet(UserSetName user_set)
Loads the selected configuration into the camera's volatile memory and makes it the active configurat...
Used to indicate that a value is not in the allowed range.
bool saveUserSet(UserSetName user_set, bool set_default=false)
Saves the current active configuration set into the selected user set.
VISP_EXPORT int wait(double t0, double t)
Pylon::CInstantCamera * getCameraHandler()
bool selectUserSet(UserSetName user_set)
Selects the configuration set to load, save, or configure.
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
void setCameraSerial(const std::string &serial)
Type * bitmap
points toward the bitmap
UserSetName getUserSetDefault()
Gets the configuration set being used as the default startup set.
error that can be emited by ViSP classes.
void close()
Stop active camera capturing images and disconnect the active camera.
float setBlackLevel(float blacklevel_value=0)
std::ostream & getCameraInfo(std::ostream &os)
unsigned int height
Number of rows in the image.
unsigned int getNumCameras()
bool setUserSetDefault(UserSetName user_set)
Sets the configuration set to be used as the default startup set.
float setGamma(bool gamma_on, float gamma_value=1)
std::string getCameraSerial(unsigned int index)
float setExposure(bool exposure_on, bool exposure_auto, float exposure_value=0)
virtual ~vpPylonGrabberUsb()
bool init
Set to true if the frame grabber has been initialized.
float setGain(bool gain_auto, float gain_value=0)
void acquire(vpImage< unsigned char > &I)
float setFrameRate(float frame_rate)
unsigned int width
Number of columns in the image.
vpPylonGrabber & operator>>(vpImage< unsigned char > &I)
void setCameraIndex(unsigned int index)