35 yCError(RGBDSENSORPARAMPARSER) <<
"Check"<<param.
name<<
"in config file";
40 yCError(RGBDSENSORPARAMPARSER) <<
"Parameter" << param.
name <<
"size should be" << param.
size;
44 for (
size_t i=0;i<b->
size();i++)
61 bool ret1, ret2, ret3;
69 yCError(RGBDSENSORPARAMPARSER) <<
"Setting " << param.
name <<
" can either be a 'SETTING' or 'HW_DESCRIPTION', not both. Fix the config file. \
70 Look for documentation online.";
73 return (ret1 && ret2 && ret3);
80 std::pair<std::string, double*> realparam;
81 std::vector<std::pair<std::string, double*> > realParams;
84 if (!config.
check(groupName))
97 realparam.first =
"physFocalLength"; realparam.second = ¶ms.
physFocalLength; realParams.push_back(realparam);
98 realparam.first =
"focalLengthX"; realparam.second = ¶ms.
focalLengthX; realParams.push_back(realparam);
99 realparam.first =
"focalLengthY"; realparam.second = ¶ms.
focalLengthY; realParams.push_back(realparam);
100 realparam.first =
"principalPointX"; realparam.second = ¶ms.
principalPointX; realParams.push_back(realparam);
101 realparam.first =
"principalPointY"; realparam.second = ¶ms.
principalPointY; realParams.push_back(realparam);
103 for(i = 0; i < realParams.size(); i++)
105 if (!intrinsic.
check(realParams[i].first))
107 yCError(RGBDSENSORPARAMPARSER) <<
"Missing" << realParams[i].first <<
"param in" << groupName <<
"group in the configuration file";
111 *(realParams[i].second) = intrinsic.
find(realParams[i].first).
asFloat64();
114 if (!intrinsic.
check(
"distortionModel"))
116 yCError(RGBDSENSORPARAMPARSER) <<
"Missing distortionModel param in configuration";
122 yCError(RGBDSENSORPARAMPARSER) <<
"Missing" << intrinsic.
find(
"distortionModel").
asString() <<
"group in configuration file";
128 if (!distortion.
check(
"name"))
130 yCError(RGBDSENSORPARAMPARSER) <<
"Missing name param in" << config.
find(
"distortionModel").
asString() <<
"group in configuration file";
135 yCError(RGBDSENSORPARAMPARSER) <<
"Only plumb_bob distortion model is supported at the moment";
140 realparam.first =
"k1"; realparam.second = ¶ms.
distortionModel.
k1; realParams.push_back(realparam);
141 realparam.first =
"k2"; realparam.second = ¶ms.
distortionModel.
k2; realParams.push_back(realparam);
142 realparam.first =
"t1"; realparam.second = ¶ms.
distortionModel.
t1; realParams.push_back(realparam);
143 realparam.first =
"t2"; realparam.second = ¶ms.
distortionModel.
t2; realParams.push_back(realparam);
144 realparam.first =
"k3"; realparam.second = ¶ms.
distortionModel.
k3; realParams.push_back(realparam);
146 for(i = 0; i < realParams.size(); i++)
148 if (!distortion.
check(realParams[i].first))
150 yCError(RGBDSENSORPARAMPARSER) <<
"Missing" << realParams[i].first <<
"param in" << intrinsic.
find(
"distortionModel").
asString() <<
"group in the configuration file";
153 *(realParams[i].second) = distortion.
find(realParams[i].first).
asFloat64();
159 bool RGBDSensorParamParser::parseParam(
const Searchable &config, std::vector<RGBDParam*>& params)
163 if (!config.
check(
"SETTINGS"))
165 yCError(RGBDSENSORPARAMPARSER) <<
"Missing SETTINGS section on the configuration file";
171 if (!config.
check(
"HW_DESCRIPTION"))
173 yCError(RGBDSENSORPARAMPARSER) <<
"Missing HW_DESCRIPTION section on the configuration file";
180 for (
auto& v: params)
187 yCError(RGBDSENSORPARAMPARSER) <<
"Driver input file not correct, please fix it!";
191 if (!
parseIntrinsic(config,
"RGB_INTRINSIC_PARAMETERS", rgbIntrinsic))
193 yCError(RGBDSENSORPARAMPARSER) <<
"Incomplete or missing RGB_INTRINSIC_PARAMETERS section on the configuration file";
198 if (!
parseIntrinsic(config,
"DEPTH_INTRINSIC_PARAMETERS", depthIntrinsic))
200 yCError(RGBDSENSORPARAMPARSER) <<
"Incomplete or missing DEPTH_INTRINSIC_PARAMETERS section on the configuration file";
204 if (!config.
check(
"EXTRINSIC_PARAMETERS"))
206 if (!isOptionalExtrinsic)
208 yCError(RGBDSENSORPARAMPARSER) <<
"Missing EXTRINSIC_PARAMETERS section on the configuration file";
221 if (!extrinsic.
check(
"transformation"))
223 yCError(RGBDSENSORPARAMPARSER) <<
"Missing transformation parameter under EXTRINSIC_PARAMETERS group in configuration file";
230 if (transformation.
size()==1)
238 if (!(
tf->size() == 4*4))
240 yCError(RGBDSENSORPARAMPARSER) <<
"The size of the transformation matrix is wrong";
244 for(
int i = 0; i < 4; i++)
246 for(
int j = 0; j < 4; j++)
252 yCError(RGBDSENSORPARAMPARSER) <<
"Wrong data format on transformation matrix (position" << k <<
")";
255 transformationMatrix[i][j] = v.
asFloat64();
static bool parseIntrinsic(const Searchable &config, const std::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.