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}};
73 m_iAutoControlSettings->setAeLock(
true);
78 ret =
ret && m_iSourceSettings->setFrameDurationRange(Argus::Range<uint64_t>(
frameDuration)) == STATUS_OK;
79 ret =
ret && m_iSourceSettings->setExposureTimeRange(Argus::Range<uint64_t>(
frameDuration)) == STATUS_OK;
107bool argusCameraDriver::startCamera()
121bool argusCameraDriver::stopCamera()
152 m_cameraProvider.reset(CameraProvider::create());
162 if (m_cameraDevices.size() == 0)
175 if (
m_d >= m_cameraDevices.size())
211 return ok && startCamera();
259 double minDistance = std::numeric_limits<double>::max();
264 if (resolution.width() ==
width && resolution.height() ==
height)
266 yCDebug(
ARGUS_CAMERA) <<
"The resolution" << resolution.width() <<
"x" << resolution.height() <<
"is available";
273 yCWarning(
ARGUS_CAMERA) <<
"The set width and height are different from the available ones. Searching for the nearest resolution...";
274 double distance = std::abs(
int(resolution.width() -
width)) + std::abs(
int(resolution.height() -
height));
308 m_stream.reset(
iCaptureSession->createOutputStream(m_streamSettings.get()));
309 m_consumer.reset(FrameConsumer::create(m_stream.get()));
317 m_request.reset(
iCaptureSession->createRequest(Argus::CAPTURE_INTENT_PREVIEW));
318 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
319 if (
iRequest->enableOutputStream(m_stream.get()) != STATUS_OK)
392 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
416 b = setFramerate(value);
438 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
445 *value = m_iAutoControlSettings->getExposureCompensation();
449 m_iAutoControlSettings->setColorSaturationEnable(
true);
450 *value = m_iAutoControlSettings->getColorSaturation();
454 *value = m_iEdgeEnhanceSettings->getEdgeEnhanceStrength();
479 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
489 m_iAutoControlSettings->setAeLock(
true);
490 m_iAutoControlSettings->setAwbLock(
false);
493 m_iAutoControlSettings->setWbGains(
wbGains);
504 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
527 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
539 yCError(
ARGUS_CAMERA) <<
"Feature" <<
feature <<
"does not have OnOff.. call hasOnOff() to know if a specific feature support OnOff mode";
546 m_iAutoControlSettings->setAeLock(!onoff);
551 m_iAutoControlSettings->setAwbLock(!onoff);
567 Argus::IRequest *
iRequest = Argus::interface_cast<Argus::IRequest>(m_request);
577 yCError(
ARGUS_CAMERA) <<
"Feature" <<
feature <<
"does not have OnOff.. call hasOnOff() to know if a specific feature support OnOff mode";
585 val_to_get = !(m_iAutoControlSettings->getAeLock());
589 val_to_get = !(m_iAutoControlSettings->getAwbLock());
700 std::lock_guard<std::mutex>
guard(m_mutex);
710 auto img =
iFrame->getImage();
711 auto image2d(Argus::interface_cast<EGLStream::IImage2D>(img));
721 double rotation = 0.0;
759 cv::cuda::GpuMat
tmp;
771 cv::cvtColor(rgba_img, bgr_img, cv::COLOR_RGBA2BGR);
775 cv::Point2f
img_center((bgr_img.cols - 1) / 2.0, (bgr_img.rows - 1) / 2.0);
777 cv::warpAffine(bgr_img, bgr_img,
M, bgr_img.size());
783 cv::resize(bgr_img, bgr_img, size);
786 image.copy(yarp::cv::fromCvMat<yarp::sig::PixelRgb>(bgr_img));
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
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
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
bool getMode(int feature, FeatureMode *mode) override
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
int height() const override
Return the height of each frame.
bool setFeature(int feature, double value) override
int getRgbWidth() override
Return the width of each frame.
bool getCameraDescription(CameraDescriptor *camera) override
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
bool hasOnePush(int feature, bool *hasOnePush) override
bool hasFeature(int feature, bool *hasFeature) override
int width() const override
Return the width of each frame.
bool setMode(int feature, FeatureMode mode) override
bool setActive(int feature, bool onoff) override
bool hasOnOff(int feature, bool *HasOnOff) override
bool getFeature(int feature, double *value) override
bool setOnePush(int feature) override
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.
#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.
@ YARP_FEATURE_SATURATION
@ YARP_FEATURE_FRAME_RATE
@ YARP_FEATURE_WHITE_BALANCE
An interface to the operating system, including Port based communication.
std::string deviceDescription