44 #include "vpPylonGrabberGigE.h"
46 #ifdef VISP_HAVE_PYLON
48 #include <visp3/core/vpException.h>
49 #include <visp3/core/vpTime.h>
71 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
72 Pylon::DeviceInfoList_t lstDevices;
73 Pylon::DeviceInfoList_t filter;
74 Pylon::CBaslerGigEDeviceInfo gige_devinfo;
75 filter.push_back(gige_devinfo);
76 TlFactory.EnumerateDevices(lstDevices, filter);
78 m_numCameras = lstDevices.size();
91 Pylon::CDeviceInfo deviceInfo = m_camera.GetDeviceInfo();
93 GenApi::INodeMap &control = m_camera.GetNodeMap();
95 GenApi::CIntegerPtr widthMax = control.GetNode(
"WidthMax");
96 GenApi::CIntegerPtr heightMax = control.GetNode(
"HeightMax");
98 os <<
"Camera information: " << std::endl;
99 os <<
" Serial number : " << deviceInfo.GetSerialNumber() << std::endl;
100 os <<
" Camera model : " << deviceInfo.GetModelName() << std::endl;
101 os <<
" Camera vendor : " << deviceInfo.GetVendorName() << std::endl;
102 os <<
" Resolution : " << widthMax->GetValue() <<
"x" << heightMax->GetValue() << std::endl;
103 os <<
" Firmware version : " << deviceInfo.GetDeviceVersion() << std::endl;
118 if (m_connected ==
true) {
136 float frame_rate = m_camera.AcquisitionFrameRateAbs.GetValue();
150 if (GenApi::IsReadable(m_camera.GainAbs))
151 return m_camera.GainAbs.GetValue();
152 else if (GenApi::IsReadable(m_camera.GainRaw))
153 return m_camera.GainRaw.GetValue();
173 if (GenApi::IsReadable(m_camera.BlackLevelAbs))
174 return m_camera.BlackLevelAbs.GetValue();
175 else if (GenApi::IsReadable(m_camera.BlackLevelRaw))
176 return m_camera.BlackLevelRaw.GetValue();
196 if (GenApi::IsReadable(m_camera.ExposureTimeAbs))
197 return m_camera.ExposureTimeAbs.GetValue() * 0.001;
198 else if (GenApi::IsReadable(m_camera.ExposureTimeRaw))
199 return m_camera.ExposureTimeRaw.GetValue();
214 float gamma = m_camera.Gamma.GetValue();
228 if (index >= m_numCameras) {
230 index, m_numCameras));
233 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
234 Pylon::DeviceInfoList_t lstDevices;
235 Pylon::DeviceInfoList_t filter;
236 Pylon::CBaslerGigEDeviceInfo gige_devinfo;
237 filter.push_back(gige_devinfo);
238 TlFactory.EnumerateDevices(lstDevices, filter);
240 std::ostringstream os;
241 os << lstDevices[index].GetSerialNumber();
261 m_camera.UserSetLoad.Execute();
263 success = m_camera.UserSetLoad.IsDone();
279 Basler_GigECamera::UserSetDefaultSelectorEnums user_set = m_camera.UserSetDefaultSelector.GetValue();
282 case Basler_GigECamera::UserSetDefaultSelector_Default:
285 case Basler_GigECamera::UserSetDefaultSelector_UserSet1:
288 case Basler_GigECamera::UserSetDefaultSelector_UserSet2:
291 case Basler_GigECamera::UserSetDefaultSelector_UserSet3:
317 if (index >= m_numCameras) {
319 index, m_numCameras));
334 for (
unsigned int i = 0; i < m_numCameras; i++) {
354 m_camera.AcquisitionFrameRateAbs.SetValue(frame_rate);
356 return m_camera.AcquisitionFrameRateAbs.GetValue();
377 m_camera.GainAuto.SetValue(Basler_GigECamera::GainAuto_Continuous);
379 m_camera.GainAuto.SetValue(Basler_GigECamera::GainAuto_Off);
381 if (GenApi::IsWritable(m_camera.GainAbs)) {
382 m_camera.GainAbs.SetValue(gain_value);
383 return m_camera.GainAbs.GetValue();
385 else if (GenApi::IsWritable(m_camera.GainRaw)) {
386 m_camera.GainRaw.SetValue(gain_value);
387 return m_camera.GainRaw.GetValue();
411 if (GenApi::IsWritable(m_camera.BlackLevelAbs)) {
412 m_camera.BlackLevelAbs.SetValue(blacklevel_value);
413 return m_camera.BlackLevelAbs.GetValue();
415 else if (GenApi::IsWritable(m_camera.BlackLevelRaw)) {
416 m_camera.BlackLevelRaw.SetValue(blacklevel_value);
417 return m_camera.BlackLevelRaw.GetValue();
445 m_camera.ExposureMode.SetValue(Basler_GigECamera::ExposureMode_Timed);
447 m_camera.ExposureMode.SetValue(Basler_GigECamera::ExposureMode_Off);
450 m_camera.ExposureAuto.SetValue(Basler_GigECamera::ExposureAuto_Continuous);
452 m_camera.ExposureAuto.SetValue(Basler_GigECamera::ExposureAuto_Off);
454 if (GenApi::IsWritable(m_camera.ExposureTimeAbs)) {
455 m_camera.ExposureTimeAbs.SetValue(exposure_value * 1000);
456 return m_camera.ExposureTimeAbs.GetValue() * 0.001;
458 else if (GenApi::IsWritable(m_camera.ExposureTimeRaw)) {
459 m_camera.ExposureTimeRaw.SetValue(exposure_value);
460 return m_camera.ExposureTimeRaw.GetValue();
482 if (GenApi::IsWritable(m_camera.GammaEnable))
483 m_camera.GammaEnable.SetValue(gamma_on);
485 if (GenApi::IsWritable(m_camera.Gamma)) {
486 m_camera.Gamma.SetValue(gamma_value);
487 return m_camera.Gamma.GetValue();
511 m_camera.UserSetSave.Execute();
513 success = m_camera.UserSetSave.IsDone();
516 if (success && set_default)
537 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_Default);
541 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_UserSet1);
545 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_UserSet2);
549 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_UserSet3);
566 if (!m_camera.IsGrabbing()) {
567 m_camera.StartGrabbing(1);
569 if (m_connected && m_camera.IsGrabbing())
582 if (m_camera.IsGrabbing()) {
583 m_camera.StopGrabbing();
585 if (m_connected && m_camera.IsGrabbing())
598 if (m_connected ==
false) {
600 if (m_numCameras == 0) {
604 if (!m_camera.IsPylonDeviceAttached()) {
605 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
606 Pylon::DeviceInfoList_t lstDevices;
607 Pylon::DeviceInfoList_t filter;
608 Pylon::CBaslerGigEDeviceInfo gige_devinfo;
609 filter.push_back(gige_devinfo);
610 TlFactory.EnumerateDevices(lstDevices, filter);
612 m_camera.Attach(TlFactory.CreateDevice(lstDevices[m_index]));
618 if (m_connected && m_camera.IsGrabbing())
631 if (m_connected ==
true) {
635 if (m_connected && m_camera.IsGrabbing())
664 Pylon::CGrabResultPtr grabResult;
666 if (!m_camera.RetrieveResult(2000, grabResult)) {
671 if (grabResult->GrabSucceeded()) {
672 height = grabResult->GetHeight();
673 width = grabResult->GetWidth();
676 Pylon::CImageFormatConverter imageConvert;
677 imageConvert.OutputPixelFormat = Pylon::PixelType_Mono8;
678 imageConvert.OutputPaddingX = 0;
680 imageConvert.Convert(I.
bitmap,
sizeof(
unsigned char) *
width *
height, (Pylon::IImage &)grabResult);
693 Pylon::CGrabResultPtr grabResult;
695 if (!m_camera.RetrieveResult(2000, grabResult)) {
700 if (grabResult->GrabSucceeded()) {
701 height = grabResult->GetHeight();
702 width = grabResult->GetWidth();
705 Pylon::CImageFormatConverter imageConvert;
706 imageConvert.OutputPixelFormat = Pylon::PixelType_BGRA8packed;
707 imageConvert.OutputPaddingX = 0;
709 Pylon::CPylonImage destImage;
710 imageConvert.Convert(destImage, (Pylon::IImage &)grabResult);
711 Pylon::SBGRA8Pixel *pixel = (Pylon::SBGRA8Pixel *)destImage.GetBuffer();
712 for (
unsigned int i = 0; i <
height; i++) {
713 for (
unsigned int j = 0; j <
width; j++) {
714 unsigned int p_index = i *
width + j;
715 I[i][j].R = pixel[p_index].R;
716 I[i][j].G = pixel[p_index].G;
717 I[i][j].B = pixel[p_index].B;
718 I[i][j].A = pixel[p_index].A;
775 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_Default);
779 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_UserSet1);
783 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_UserSet2);
787 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_UserSet3);
818 void dummy_vpPylonGrabberGigE() { };
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
@ notImplementedError
Not implemented.
unsigned int height
Number of rows in the image.
bool init
Set to true if the frame grabber has been initialized.
unsigned int width
Number of columns in the image.
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Type * bitmap
points toward the bitmap
void close()
Stop active camera capturing images and disconnect the active camera.
void setCameraIndex(unsigned int index)
bool loadUserSet(UserSetName user_set)
Loads the selected configuration into the camera's volatile memory and makes it the active configurat...
float setBlackLevel(float blacklevel_value=0)
std::string getCameraSerial(unsigned int index)
bool setUserSetDefault(UserSetName user_set)
Sets the configuration set to be used as the default startup set.
virtual ~vpPylonGrabberGigE()
Pylon::CInstantCamera * getCameraHandler()
void acquire(vpImage< unsigned char > &I)
unsigned int getNumCameras()
float setExposure(bool exposure_on, bool exposure_auto, float exposure_value=0)
void setCameraSerial(const std::string &serial)
UserSetName getUserSetDefault()
Gets the configuration set being used as the default startup set.
float setGamma(bool gamma_on, float gamma_value=1)
float setFrameRate(float frame_rate)
bool selectUserSet(UserSetName user_set)
Selects the configuration set to load, save, or configure.
vpPylonGrabber & operator>>(vpImage< unsigned char > &I)
std::ostream & getCameraInfo(std::ostream &os)
float setGain(bool gain_auto, float gain_value=0)
bool saveUserSet(UserSetName user_set, bool set_default=false)
Saves the current active configuration set into the selected user set.
@ USERSET_DEFAULT
The default user set.
@ USERSET_UNKNOWN
User set not supported.
@ USERSET_USERSET1
User set 1.
@ USERSET_USERSET3
User set 3.
@ USERSET_USERSET2
User set 2.
VISP_EXPORT int wait(double t0, double t)