9#include <opencv2/core/core_c.h>
19#include <opencv2/opencv.hpp>
20#include <opencv2/videoio.hpp>
22#include <opencv2/cudawarping.hpp>
69bool pylonCameraDriver::setFramerate(
const float _fps)
71 auto res = setOption(
"AcquisitionFrameRate",
_fps);
133bool pylonCameraDriver::startCamera()
137 if (!m_camera_ptr->IsGrabbing())
145bool pylonCameraDriver::stopCamera()
149 if (m_camera_ptr->IsGrabbing())
151 m_camera_ptr->StopGrabbing();
161 if (!config.
check(
"serial_number"))
167 m_serial_number = config.
find(
"serial_number").toString().c_str();
176 if (m_rotationWithCrop)
178 if (m_rotation == -90.0 || m_rotation == 90.0)
180 std::swap(m_width, m_height);
187 m_fps = 1.0 / period;
193 CTlFactory& factory = CTlFactory::GetInstance();
201 m_camera_ptr->Open();
202 if (!m_camera_ptr->IsOpen())
217 yCError(
PYLON_CAMERA) <<
"Camera" << m_serial_number <<
"cannot be opened, error:" <<
e.GetDescription();
222 auto&
nodemap = m_camera_ptr->GetNodeMap();
224 ok = ok && setOption(
"AcquisitionFrameRateEnable",
true);
225 ok = ok && setOption(
"BslScalingEnable",
true);
229 ok = ok && setOption(
"ExposureAuto",
"Off",
true);
231 ok = ok && setFramerate(m_fps);
241 return ok && startCamera();
246 if (m_camera_ptr->IsPylonDeviceAttached())
248 m_camera_ptr->DetachDevice();
375 b = setFramerate(value);
398 b = getOption(
"BslBrightness", value);
401 b = getOption(
"ExposureTime", value);
404 b = getOption(
"BslSharpnessEnhancement", value);
411 b = getOption(
"Gain", value);
436 auto res = setOption(
"BalanceRatioSelector",
"Blue",
true);
438 res =
res && setOption(
"BalanceRatioSelector",
"Red",
true);
452 auto res = setOption(
"BalanceRatioSelector",
"Blue",
true);
454 res =
res && setOption(
"BalanceRatioSelector",
"Red",
true);
479 yCError(
PYLON_CAMERA) <<
"Feature" <<
feature <<
"does not have OnOff.. call hasOnOff() to know if a specific feature support OnOff mode";
488 b = setOption(
"ExposureAuto",
val_to_set.c_str(),
true);
491 b = setOption(
"BalanceWhiteAuto",
val_to_set.c_str(),
true);
494 b = setOption(
"GainAuto",
val_to_set.c_str(),
true);
515 yCError(
PYLON_CAMERA) <<
"Feature" <<
feature <<
"does not have OnOff.. call hasOnOff() to know if a specific feature support OnOff mode";
524 b = getOption(
"ExposureAuto",
val_to_get,
true);
527 b = getOption(
"BalanceWhiteAuto",
val_to_get,
true);
639 std::lock_guard<std::mutex>
guard(m_mutex);
640 if (m_camera_ptr->IsGrabbing())
653 catch (
const Pylon::GenericException&
e)
656 yCError(
PYLON_CAMERA) <<
"Camera" << m_serial_number <<
"cannot get images error:" <<
e.GetDescription();
666 if (m_rotation == -90.0 || m_rotation == 90.0)
668 std::swap(m_width, m_height);
672 image.
resize(m_width, m_height);
689 if (m_rotation != 0.0)
700 cv::Size size =
rotated.size();
703 cv::cuda::rotate(
gpu_im,
gpu_im_rot, cv::Size(size.height, size.width), m_rotation, size.height - 1, 0, cv::INTER_LINEAR);
710 image.
copy(yarp::cv::fromCvMat<yarp::sig::PixelRgb>(
rotated));
@ YARP_FEATURE_FRAME_RATE
@ YARP_FEATURE_BRIGHTNESS
@ YARP_FEATURE_WHITE_BALANCE
bool parseUint32Param(std::string param_name, std::uint32_t ¶m, yarp::os::Searchable &config)
static const std::vector< cameraFeature_id_t > supported_features
static const std::vector< cameraFeature_id_t > features_with_auto
double fromZeroOneToRange(cameraFeature_id_t feature, double value)
double fromRangeToZeroOne(cameraFeature_id_t feature, double value)
static const std::map< double, double > rotationToCVRot
int getRgbWidth() override
Return the width of each frame.
bool getActive(int feature, bool *isActive) override
Get the current status of the feature, on or off.
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
bool hasAuto(int feature, bool *hasAuto) override
Check if the requested feature has the 'auto' mode.
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ... )
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ... )
bool getRgbIntrinsicParam(Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
bool hasOnePush(int feature, bool *hasOnePush) override
Check if the requested feature has the 'onePush' mode.
bool close() override
Close the DeviceDriver.
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
int height() const override
Return the height of each frame.
bool hasOnOff(int feature, bool *HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
bool getCameraDescription(CameraDescriptor *camera) override
Get a basic description of the camera hw.
bool getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
bool hasManual(int feature, bool *hasManual) override
Check if the requested feature has the 'manual' mode.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
int width() const override
Return the width of each frame.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
bool setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ... )
int getRgbHeight() override
Return the height of each frame.
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an image from the frame grabber.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
A mini-server for performing network communication in the background.
A class for storing options and configuration information.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
size_t getPixelSize() const override
Gets pixel size in memory in bytes.
unsigned char * getRawImage() const
Access to the internal image buffer.
bool copy(const Image &alt)
Copy operator.
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
bool parseUint32Param(std::string param_name, std::uint32_t ¶m, yarp::os::Searchable &config)
bool parseFloat64Param(std::string param_name, double ¶m, yarp::os::Searchable &config)
static const std::vector< cameraFeature_id_t > supported_features
static const std::vector< cameraFeature_id_t > features_with_auto
double fromZeroOneToRange(cameraFeature_id_t feature, double value)
static const std::map< double, int > rotationToCVRot
bool parseBooleanParam(std::string param_name, bool ¶m, yarp::os::Searchable &config)
double fromRangeToZeroOne(cameraFeature_id_t feature, double value)
static const std::map< cameraFeature_id_t, std::pair< double, double > > featureMinMax
bool parseStringParam(std::string param_name, std::string ¶m, yarp::os::Searchable &config)