44 #include "vpPylonGrabberGigE.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::CBaslerGigEDeviceInfo gige_devinfo;
74 filter.push_back(gige_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.AcquisitionFrameRateAbs.GetValue();
148 if (GenApi::IsReadable(m_camera.GainAbs))
149 return m_camera.GainAbs.GetValue();
150 else if (GenApi::IsReadable(m_camera.GainRaw))
151 return m_camera.GainRaw.GetValue();
171 if (GenApi::IsReadable(m_camera.BlackLevelAbs))
172 return m_camera.BlackLevelAbs.GetValue();
173 else if (GenApi::IsReadable(m_camera.BlackLevelRaw))
174 return m_camera.BlackLevelRaw.GetValue();
194 if (GenApi::IsReadable(m_camera.ExposureTimeAbs))
195 return m_camera.ExposureTimeAbs.GetValue() * 0.001;
196 else if (GenApi::IsReadable(m_camera.ExposureTimeRaw))
197 return m_camera.ExposureTimeRaw.GetValue();
212 float gamma = m_camera.Gamma.GetValue();
226 if (index >= m_numCameras) {
228 index, m_numCameras));
231 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
232 Pylon::DeviceInfoList_t lstDevices;
233 Pylon::DeviceInfoList_t filter;
234 Pylon::CBaslerGigEDeviceInfo gige_devinfo;
235 filter.push_back(gige_devinfo);
236 TlFactory.EnumerateDevices(lstDevices, filter);
238 std::ostringstream os;
239 os << lstDevices[index].GetSerialNumber();
259 m_camera.UserSetLoad.Execute();
261 success = m_camera.UserSetLoad.IsDone();
277 Basler_GigECamera::UserSetDefaultSelectorEnums user_set = m_camera.UserSetDefaultSelector.GetValue();
280 case Basler_GigECamera::UserSetDefaultSelector_Default:
283 case Basler_GigECamera::UserSetDefaultSelector_UserSet1:
286 case Basler_GigECamera::UserSetDefaultSelector_UserSet2:
289 case Basler_GigECamera::UserSetDefaultSelector_UserSet3:
315 if (index >= m_numCameras) {
317 index, m_numCameras));
332 for (
unsigned int i = 0; i < m_numCameras; i++) {
352 m_camera.AcquisitionFrameRateAbs.SetValue(frame_rate);
354 return m_camera.AcquisitionFrameRateAbs.GetValue();
375 m_camera.GainAuto.SetValue(Basler_GigECamera::GainAuto_Continuous);
377 m_camera.GainAuto.SetValue(Basler_GigECamera::GainAuto_Off);
379 if (GenApi::IsWritable(m_camera.GainAbs)) {
380 m_camera.GainAbs.SetValue(gain_value);
381 return m_camera.GainAbs.GetValue();
382 }
else if (GenApi::IsWritable(m_camera.GainRaw)) {
383 m_camera.GainRaw.SetValue(gain_value);
384 return m_camera.GainRaw.GetValue();
407 if (GenApi::IsWritable(m_camera.BlackLevelAbs)) {
408 m_camera.BlackLevelAbs.SetValue(blacklevel_value);
409 return m_camera.BlackLevelAbs.GetValue();
410 }
else if (GenApi::IsWritable(m_camera.BlackLevelRaw)) {
411 m_camera.BlackLevelRaw.SetValue(blacklevel_value);
412 return m_camera.BlackLevelRaw.GetValue();
439 m_camera.ExposureMode.SetValue(Basler_GigECamera::ExposureMode_Timed);
441 m_camera.ExposureMode.SetValue(Basler_GigECamera::ExposureMode_Off);
444 m_camera.ExposureAuto.SetValue(Basler_GigECamera::ExposureAuto_Continuous);
446 m_camera.ExposureAuto.SetValue(Basler_GigECamera::ExposureAuto_Off);
448 if (GenApi::IsWritable(m_camera.ExposureTimeAbs)) {
449 m_camera.ExposureTimeAbs.SetValue(exposure_value * 1000);
450 return m_camera.ExposureTimeAbs.GetValue() * 0.001;
451 }
else if (GenApi::IsWritable(m_camera.ExposureTimeRaw)) {
452 m_camera.ExposureTimeRaw.SetValue(exposure_value);
453 return m_camera.ExposureTimeRaw.GetValue();
474 if (GenApi::IsWritable(m_camera.GammaEnable))
475 m_camera.GammaEnable.SetValue(gamma_on);
477 if (GenApi::IsWritable(m_camera.Gamma)) {
478 m_camera.Gamma.SetValue(gamma_value);
479 return m_camera.Gamma.GetValue();
502 m_camera.UserSetSave.Execute();
504 success = m_camera.UserSetSave.IsDone();
507 if (success && set_default)
528 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_Default);
532 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_UserSet1);
536 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_UserSet2);
540 m_camera.UserSetDefaultSelector.SetValue(Basler_GigECamera::UserSetDefaultSelector_UserSet3);
557 if (!m_camera.IsGrabbing()) {
558 m_camera.StartGrabbing(1);
560 if (m_connected && m_camera.IsGrabbing())
573 if (m_camera.IsGrabbing()) {
574 m_camera.StopGrabbing();
576 if (m_connected && m_camera.IsGrabbing())
589 if (m_connected ==
false) {
591 if (m_numCameras == 0) {
595 if (!m_camera.IsPylonDeviceAttached()) {
596 Pylon::CTlFactory &TlFactory = Pylon::CTlFactory::GetInstance();
597 Pylon::DeviceInfoList_t lstDevices;
598 Pylon::DeviceInfoList_t filter;
599 Pylon::CBaslerGigEDeviceInfo gige_devinfo;
600 filter.push_back(gige_devinfo);
601 TlFactory.EnumerateDevices(lstDevices, filter);
603 m_camera.Attach(TlFactory.CreateDevice(lstDevices[m_index]));
609 if (m_connected && m_camera.IsGrabbing())
622 if (m_connected ==
true) {
626 if (m_connected && m_camera.IsGrabbing())
655 Pylon::CGrabResultPtr grabResult;
657 if (!m_camera.RetrieveResult(2000, grabResult)) {
662 if (grabResult->GrabSucceeded()) {
663 height = grabResult->GetHeight();
664 width = grabResult->GetWidth();
667 Pylon::CImageFormatConverter imageConvert;
668 imageConvert.OutputPixelFormat = Pylon::PixelType_Mono8;
669 imageConvert.OutputPaddingX = 0;
671 imageConvert.Convert(I.
bitmap,
sizeof(
unsigned char) *
width *
height, (Pylon::IImage &)grabResult);
684 Pylon::CGrabResultPtr grabResult;
686 if (!m_camera.RetrieveResult(2000, grabResult)) {
691 if (grabResult->GrabSucceeded()) {
692 height = grabResult->GetHeight();
693 width = grabResult->GetWidth();
696 Pylon::CImageFormatConverter imageConvert;
697 imageConvert.OutputPixelFormat = Pylon::PixelType_BGRA8packed;
698 imageConvert.OutputPaddingX = 0;
700 Pylon::CPylonImage destImage;
701 imageConvert.Convert(destImage, (Pylon::IImage &)grabResult);
702 Pylon::SBGRA8Pixel *pixel = (Pylon::SBGRA8Pixel *)destImage.GetBuffer();
703 for (
unsigned int i = 0; i <
height; i++) {
704 for (
unsigned int j = 0; j <
width; j++) {
705 unsigned int p_index = i * width + j;
706 I[i][j].R = pixel[p_index].R;
707 I[i][j].G = pixel[p_index].G;
708 I[i][j].B = pixel[p_index].B;
709 I[i][j].A = pixel[p_index].A;
766 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_Default);
770 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_UserSet1);
774 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_UserSet2);
778 m_camera.UserSetSelector.SetValue(Basler_GigECamera::UserSetSelector_UserSet3);
809 void dummy_vpPylonGrabberGigE(){};
810 #endif // #ifdef VISP_HAVE_PYLON float setGain(bool gain_auto, float gain_value=0)
Used to indicate that a value is not in the allowed range.
VISP_EXPORT int wait(double t0, double t)
bool loadUserSet(UserSetName user_set)
Loads the selected configuration into the camera's volatile memory and makes it the active configurat...
virtual ~vpPylonGrabberGigE()
Type * bitmap
points toward the bitmap
std::ostream & getCameraInfo(std::ostream &os)
error that can be emited by ViSP classes.
void acquire(vpImage< unsigned char > &I)
unsigned int getNumCameras()
void setCameraSerial(const std::string &serial)
std::string getCameraSerial(unsigned int index)
Pylon::CInstantCamera * getCameraHandler()
unsigned int height
Number of rows in the image.
float setFrameRate(float frame_rate)
vpPylonGrabber & operator>>(vpImage< unsigned char > &I)
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
float setGamma(bool gamma_on, float gamma_value=1)
bool init
Set to true if the frame grabber has been initialized.
UserSetName getUserSetDefault()
Gets the configuration set being used as the default startup set.
bool selectUserSet(UserSetName user_set)
Selects the configuration set to load, save, or configure.
void close()
Stop active camera capturing images and disconnect the active camera.
float setExposure(bool exposure_on, bool exposure_auto, float exposure_value=0)
float setBlackLevel(float blacklevel_value=0)
void setCameraIndex(unsigned int index)
unsigned int width
Number of columns in the image.
bool saveUserSet(UserSetName user_set, bool set_default=false)
Saves the current active configuration set into the selected user set.
bool setUserSetDefault(UserSetName user_set)
Sets the configuration set to be used as the default startup set.