39 yCError(RGBDSENSORPARAMPARSER) <<
"Check"<<param.
name<<
"in config file";
44 yCError(RGBDSENSORPARAMPARSER) <<
"Parameter" << param.
name <<
"size should be" << param.
size;
48 for (
size_t i=0;i<b->
size();i++)
65 bool ret1, ret2, ret3;
73 yCError(RGBDSENSORPARAMPARSER) <<
"Setting " << param.
name <<
" can either be a 'SETTING' or 'HW_DESCRIPTION', not both. Fix the config file. \
74 Look for documentation online.";
77 return (ret1 && ret2 && ret3);
84 pair<string, double*> realparam;
85 vector<pair<string, double*> > realParams;
88 if (!config.
check(groupName))
101 realparam.first =
"physFocalLength"; realparam.second = ¶ms.
physFocalLength; realParams.push_back(realparam);
102 realparam.first =
"focalLengthX"; realparam.second = ¶ms.
focalLengthX; realParams.push_back(realparam);
103 realparam.first =
"focalLengthY"; realparam.second = ¶ms.
focalLengthY; realParams.push_back(realparam);
104 realparam.first =
"principalPointX"; realparam.second = ¶ms.
principalPointX; realParams.push_back(realparam);
105 realparam.first =
"principalPointY"; realparam.second = ¶ms.
principalPointY; realParams.push_back(realparam);
107 for(i = 0; i < realParams.size(); i++)
109 if (!intrinsic.
check(realParams[i].first))
111 yCError(RGBDSENSORPARAMPARSER) <<
"Missing" << realParams[i].first <<
"param in" << groupName <<
"group in the configuration file";
115 *(realParams[i].second) = intrinsic.
find(realParams[i].first).
asFloat64();
118 if (!intrinsic.
check(
"distortionModel"))
120 yCError(RGBDSENSORPARAMPARSER) <<
"Missing distortionModel param in configuration";
126 yCError(RGBDSENSORPARAMPARSER) <<
"Missing" << intrinsic.
find(
"distortionModel").
asString() <<
"group in configuration file";
132 if (!distortion.
check(
"name"))
134 yCError(RGBDSENSORPARAMPARSER) <<
"Missing name param in" << config.
find(
"distortionModel").
asString() <<
"group in configuration file";
139 yCError(RGBDSENSORPARAMPARSER) <<
"Only plumb_bob distortion model is supported at the moment";
144 realparam.first =
"k1"; realparam.second = ¶ms.
distortionModel.
k1; realParams.push_back(realparam);
145 realparam.first =
"k2"; realparam.second = ¶ms.
distortionModel.
k2; realParams.push_back(realparam);
146 realparam.first =
"t1"; realparam.second = ¶ms.
distortionModel.
t1; realParams.push_back(realparam);
147 realparam.first =
"t2"; realparam.second = ¶ms.
distortionModel.
t2; realParams.push_back(realparam);
148 realparam.first =
"k3"; realparam.second = ¶ms.
distortionModel.
k3; realParams.push_back(realparam);
150 for(i = 0; i < realParams.size(); i++)
152 if (!distortion.
check(realParams[i].first))
154 yCError(RGBDSENSORPARAMPARSER) <<
"Missing" << realParams[i].first <<
"param in" << intrinsic.
find(
"distortionModel").
asString() <<
"group in the configuration file";
157 *(realParams[i].second) = distortion.
find(realParams[i].first).
asFloat64();
163 bool RGBDSensorParamParser::parseParam(
const Searchable &config, std::vector<RGBDParam*>& params)
167 if (!config.
check(
"SETTINGS"))
169 yCError(RGBDSENSORPARAMPARSER) <<
"Missing SETTINGS section on the configuration file";
175 if (!config.
check(
"HW_DESCRIPTION"))
177 yCError(RGBDSENSORPARAMPARSER) <<
"Missing HW_DESCRIPTION section on the configuration file";
184 for (
auto& v: params)
191 yCError(RGBDSENSORPARAMPARSER) <<
"Driver input file not correct, please fix it!";
195 if (!
parseIntrinsic(config,
"RGB_INTRINSIC_PARAMETERS", rgbIntrinsic))
197 yCError(RGBDSENSORPARAMPARSER) <<
"Incomplete or missing RGB_INTRINSIC_PARAMETERS section on the configuration file";
202 if (!
parseIntrinsic(config,
"DEPTH_INTRINSIC_PARAMETERS", depthIntrinsic))
204 yCError(RGBDSENSORPARAMPARSER) <<
"Incomplete or missing DEPTH_INTRINSIC_PARAMETERS section on the configuration file";
208 if (!config.
check(
"EXTRINSIC_PARAMETERS"))
210 if (!isOptionalExtrinsic)
212 yCError(RGBDSENSORPARAMPARSER) <<
"Missing EXTRINSIC_PARAMETERS section on the configuration file";
225 if (!extrinsic.
check(
"transformation"))
227 yCError(RGBDSENSORPARAMPARSER) <<
"Missing transformation parameter under EXTRINSIC_PARAMETERS group in configuration file";
234 if (transformation.
size()==1)
242 if (!(
tf->size() == 4*4))
244 yCError(RGBDSENSORPARAMPARSER) <<
"The size of the transformation matrix is wrong";
248 for(
int i = 0; i < 4; i++)
250 for(
int j = 0; j < 4; j++)
256 yCError(RGBDSENSORPARAMPARSER) <<
"Wrong data format on transformation matrix (position" << k <<
")";
259 transformationMatrix[i][j] = v.
asFloat64();
static bool parseIntrinsic(const Searchable &config, const string &groupName, yarp::sig::IntrinsicParams ¶ms)
static bool checkParam(const Bottle &input, RGBDSensorParamParser::RGBDParam ¶m, bool &found)
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle tail() const
Get all but the first element of a bottle.
bool isNull() const override
Checks if the object is invalid.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual Bottle * asList() const
Get list value.
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.
std::vector< yarp::os::Value > val
The IntrinsicParams struct to handle the intrinsic parameter of cameras(RGB and RGBD either).
double focalLengthY
Result of the product of the physical focal length(mm) and the size sy of the individual imager eleme...
DistortionModel distortionModel
Distortion model of the image.
double focalLengthX
Result of the product of the physical focal length(mm) and the size sx of the individual imager eleme...
double physFocalLength
Physical focal length of the lens (m)
double principalPointX
Horizontal coordinate of the principal point of the image, as a pixel offset from the left edge.
double principalPointY
Vertical coordinate of the principal point of the image, as a pixel offset from the top edge.