18#include <opencv2/cudawarping.hpp>
19#include <opencv2/cudaimgproc.hpp>
30using namespace EGLStream;
47static const std::map<double, NV::Rotation>
rotationToNVRot{{0.0, NV::ROTATION_0}, {90.0, NV::ROTATION_90}, {-90.0, NV::ROTATION_270}, {180.0, NV::ROTATION_180}};
48static const std::map<double, double>
rotationToCVRot{{0.0, 0.0}, {90.0, cv::ROTATE_90_COUNTERCLOCKWISE}, {-90.0, cv::ROTATE_90_CLOCKWISE}, {180.0, cv::ROTATE_180}};
72 m_iAutoControlSettings->setAeLock(
true);
77 ret =
ret && m_iSourceSettings->setFrameDurationRange(Argus::Range<uint64_t>(
frameDuration)) == STATUS_OK;
78 ret =
ret && m_iSourceSettings->setExposureTimeRange(Argus::Range<uint64_t>(
frameDuration)) == STATUS_OK;
106bool argusCameraDriver::startCamera()
120bool argusCameraDriver::stopCamera()
151 m_cameraProvider.reset(CameraProvider::create());
161 if (m_cameraDevices.size() == 0)
174 if (
m_d >= m_cameraDevices.size())
210 return ok && startCamera();
258 double minDistance = std::numeric_limits<double>::max();
263 if (resolution.width() ==
width && resolution.height() ==
height)
265 yCDebug(
ARGUS_CAMERA) <<
"The resolution" << resolution.width() <<
"x" << resolution.height() <<
"is available";
272 yCWarning(
ARGUS_CAMERA) <<
"The set width and height are different from the available ones. Searching for the nearest resolution...";
273 double distance = std::abs(
int(resolution.width() -
width)) + std::abs(
int(resolution.height() -
height));
307 m_stream.reset(
iCaptureSession->createOutputStream(m_streamSettings.get()));
308 m_consumer.reset(FrameConsumer::create(m_stream.get()));
316 m_request.reset(
iCaptureSession->createRequest(Argus::CAPTURE_INTENT_PREVIEW));
317 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
318 if (
iRequest->enableOutputStream(m_stream.get()) != STATUS_OK)
391 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
415 b = setFramerate(value);
437 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
444 *value = m_iAutoControlSettings->getExposureCompensation();
448 m_iAutoControlSettings->setColorSaturationEnable(
true);
449 *value = m_iAutoControlSettings->getColorSaturation();
453 *value = m_iEdgeEnhanceSettings->getEdgeEnhanceStrength();
478 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
488 m_iAutoControlSettings->setAeLock(
true);
489 m_iAutoControlSettings->setAwbLock(
false);
492 m_iAutoControlSettings->setWbGains(
wbGains);
503 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
526 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
538 yCError(
ARGUS_CAMERA) <<
"Feature" <<
feature <<
"does not have OnOff.. call hasOnOff() to know if a specific feature support OnOff mode";
545 m_iAutoControlSettings->setAeLock(!
onoff);
550 m_iAutoControlSettings->setAwbLock(!
onoff);
566 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
576 yCError(
ARGUS_CAMERA) <<
"Feature" <<
feature <<
"does not have OnOff.. call hasOnOff() to know if a specific feature support OnOff mode";
584 val_to_get = !(m_iAutoControlSettings->getAeLock());
588 val_to_get = !(m_iAutoControlSettings->getAwbLock());
699 std::lock_guard<std::mutex>
guard(m_mutex);
709 auto img =
iFrame->getImage();
710 auto image2d(Argus::interface_cast<EGLStream::IImage2D>(img));
720 double rotation = 0.0;
758 cv::cuda::GpuMat
tmp;
770 cv::cvtColor(rgba_img, bgr_img, cv::COLOR_RGBA2BGR);
774 cv::Point2f
img_center((bgr_img.cols - 1) / 2.0, (bgr_img.rows - 1) / 2.0);
776 cv::warpAffine(bgr_img, bgr_img,
M, bgr_img.size());
782 cv::resize(bgr_img, bgr_img, size);
785 image.
copy(yarp::cv::fromCvMat<yarp::sig::PixelRgb>(bgr_img));
@ YARP_FEATURE_FRAME_RATE
@ YARP_FEATURE_WHITE_BALANCE
@ YARP_FEATURE_SATURATION
static const std::map< double, NV::Rotation > rotationToNVRot
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< cameraFeature_id_t, std::pair< double, double > > featureMinMax
static const std::map< std::string, std::vector< Argus::Size2D< uint32_t > > > cameraResolutions
static const std::map< double, double > rotationToCVRot
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool m_rotation_with_crop
int getRgbHeight() override
Return the height of each frame.
bool hasAuto(int feature, bool *hasAuto) override
Check if the requested feature has the 'auto' mode.
bool close() override
Close the DeviceDriver.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
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 getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
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 setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ... )
int getRgbWidth() override
Return the width of each frame.
bool getCameraDescription(CameraDescriptor *camera) override
Get a basic description of the camera hw.
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an image from the frame grabber.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool hasManual(int feature, bool *hasManual) override
Check if the requested feature has the 'manual' mode.
bool hasOnePush(int feature, bool *hasOnePush) override
Check if the requested feature has the 'onePush' mode.
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ... )
int width() const override
Return the width of each frame.
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
bool hasOnOff(int feature, bool *HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ... )
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters 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.
bool copy(const Image &alt)
Copy operator.
#define yCInfo(component,...)
#define yCError(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.