|
|
|
@@ -427,6 +427,14 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
|
|
|
|
Ptr<Algorithm> nestedAlgo = algo->get<Algorithm>(pname);
|
|
|
|
|
nestedAlgo->write(fs);
|
|
|
|
|
}
|
|
|
|
|
else if( p.type == Param::FLOAT)
|
|
|
|
|
cv::write(fs, pname, algo->getDouble(pname));
|
|
|
|
|
else if( p.type == Param::UNSIGNED_INT)
|
|
|
|
|
cv::write(fs, pname, algo->getInt(pname));//TODO: implement cv::write(, , unsigned int)
|
|
|
|
|
else if( p.type == Param::UINT64)
|
|
|
|
|
cv::write(fs, pname, algo->getInt(pname));//TODO: implement cv::write(, , uint64)
|
|
|
|
|
else if( p.type == Param::UCHAR)
|
|
|
|
|
cv::write(fs, pname, algo->getInt(pname));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
|
|
|
@@ -486,6 +494,26 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
|
|
|
|
nestedAlgo->read(n);
|
|
|
|
|
info->set(algo, pname.c_str(), p.type, &nestedAlgo, true);
|
|
|
|
|
}
|
|
|
|
|
else if( p.type == Param::FLOAT )
|
|
|
|
|
{
|
|
|
|
|
float val = (float)n;
|
|
|
|
|
info->set(algo, pname.c_str(), p.type, &val, true);
|
|
|
|
|
}
|
|
|
|
|
else if( p.type == Param::UNSIGNED_INT )
|
|
|
|
|
{
|
|
|
|
|
unsigned int val = (unsigned int)((int)n);//TODO: implement conversion (unsigned int)FileNode
|
|
|
|
|
info->set(algo, pname.c_str(), p.type, &val, true);
|
|
|
|
|
}
|
|
|
|
|
else if( p.type == Param::UINT64)
|
|
|
|
|
{
|
|
|
|
|
uint64 val = (uint64)((int)n);//TODO: implement conversion (uint64)FileNode
|
|
|
|
|
info->set(algo, pname.c_str(), p.type, &val, true);
|
|
|
|
|
}
|
|
|
|
|
else if( p.type == Param::UCHAR)
|
|
|
|
|
{
|
|
|
|
|
uchar val = (uchar)((int)n);
|
|
|
|
|
info->set(algo, pname.c_str(), p.type, &val, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
|
|
|
@@ -508,6 +536,10 @@ union GetSetParam
|
|
|
|
|
Mat (Algorithm::*get_mat)() const;
|
|
|
|
|
std::vector<Mat> (Algorithm::*get_mat_vector)() const;
|
|
|
|
|
Ptr<Algorithm> (Algorithm::*get_algo)() const;
|
|
|
|
|
float (Algorithm::*get_float)() const;
|
|
|
|
|
unsigned int (Algorithm::*get_uint)() const;
|
|
|
|
|
uint64 (Algorithm::*get_uint64)() const;
|
|
|
|
|
uchar (Algorithm::*get_uchar)() const;
|
|
|
|
|
|
|
|
|
|
void (Algorithm::*set_int)(int);
|
|
|
|
|
void (Algorithm::*set_bool)(bool);
|
|
|
|
@@ -516,6 +548,10 @@ union GetSetParam
|
|
|
|
|
void (Algorithm::*set_mat)(const Mat&);
|
|
|
|
|
void (Algorithm::*set_mat_vector)(const std::vector<Mat>&);
|
|
|
|
|
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
|
|
|
|
|
void (Algorithm::*set_float)(float);
|
|
|
|
|
void (Algorithm::*set_uint)(unsigned int);
|
|
|
|
|
void (Algorithm::*set_uint64)(uint64);
|
|
|
|
|
void (Algorithm::*set_uchar)(uchar);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static std::string getNameOfType(int argType);
|
|
|
|
@@ -531,6 +567,10 @@ static std::string getNameOfType(int argType)
|
|
|
|
|
case Param::MAT: return "cv::Mat";
|
|
|
|
|
case Param::MAT_VECTOR: return "std::vector<cv::Mat>";
|
|
|
|
|
case Param::ALGORITHM: return "algorithm";
|
|
|
|
|
case Param::FLOAT: return "float";
|
|
|
|
|
case Param::UNSIGNED_INT: return "unsigned int";
|
|
|
|
|
case Param::UINT64: return "unsigned int64";
|
|
|
|
|
case Param::UCHAR: return "unsigned char";
|
|
|
|
|
default: CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
@@ -542,9 +582,10 @@ static std::string getErrorMessageForWrongArgumentInSetter(std::string algoName,
|
|
|
|
|
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
|
|
|
|
|
+"', the parameter has " + getNameOfType(paramType) + " type, ";
|
|
|
|
|
|
|
|
|
|
if (paramType == Param::INT || paramType == Param::BOOLEAN || paramType == Param::REAL)
|
|
|
|
|
if (paramType == Param::INT || paramType == Param::BOOLEAN || paramType == Param::REAL
|
|
|
|
|
|| paramType == Param::FLOAT || paramType == Param::UNSIGNED_INT || paramType == Param::UINT64 || paramType == Param::UCHAR)
|
|
|
|
|
{
|
|
|
|
|
message += "so it should be set by integer, boolean, or double value, ";
|
|
|
|
|
message += "so it should be set by integer, unsigned integer, uint64, unsigned char, boolean, float or double value, ";
|
|
|
|
|
}
|
|
|
|
|
message += "but the setter was called with " + getNameOfType(argType) + " value";
|
|
|
|
|
|
|
|
|
@@ -559,11 +600,11 @@ static std::string getErrorMessageForWrongArgumentInGetter(std::string algoName,
|
|
|
|
|
|
|
|
|
|
if (paramType == Param::BOOLEAN)
|
|
|
|
|
{
|
|
|
|
|
message += "so it should be get as integer, boolean, or double value, ";
|
|
|
|
|
message += "so it should be get as integer, unsigned integer, uint64, boolean, unsigned char, float or double value, ";
|
|
|
|
|
}
|
|
|
|
|
else if (paramType == Param::INT)
|
|
|
|
|
else if (paramType == Param::INT || paramType == Param::UNSIGNED_INT || paramType == Param::UINT64 || paramType == Param::UCHAR)
|
|
|
|
|
{
|
|
|
|
|
message += "so it should be get as integer or double value, ";
|
|
|
|
|
message += "so it should be get as integer, unsigned integer, uint64, unsigned char, float or double value, ";
|
|
|
|
|
}
|
|
|
|
|
message += "but the getter was called to get a " + getNameOfType(argType) + " value";
|
|
|
|
|
|
|
|
|
@@ -583,9 +624,11 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
|
|
|
|
GetSetParam f;
|
|
|
|
|
f.set_int = p->setter;
|
|
|
|
|
|
|
|
|
|
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )
|
|
|
|
|
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL
|
|
|
|
|
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
|
|
|
|
|
{
|
|
|
|
|
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN) )
|
|
|
|
|
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN
|
|
|
|
|
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || argType == Param::UCHAR) )
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
@@ -593,9 +636,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
|
|
|
|
|
|
|
|
|
if( p->type == Param::INT )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
int val = argType == Param::INT ? *(const int*)value :
|
|
|
|
|
argType == Param::BOOLEAN ? (int)*(const bool*)value :
|
|
|
|
|
saturate_cast<int>(*(const double*)value);
|
|
|
|
|
argType == Param::BOOLEAN ? (int)*(const bool*)value :
|
|
|
|
|
argType == Param::REAL ? saturate_cast<int>(*(const double*)value) :
|
|
|
|
|
argType == Param::FLOAT ? saturate_cast<int>(*(const float*)value) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (int)*(const unsigned int*)value :
|
|
|
|
|
argType == Param::UINT64 ? (int)*(const uint64*)value :
|
|
|
|
|
argType == Param::UCHAR ? (int)*(const uchar*)value :
|
|
|
|
|
(int)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_int)(val);
|
|
|
|
|
else
|
|
|
|
@@ -603,24 +658,133 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::BOOLEAN )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
bool val = argType == Param::INT ? *(const int*)value != 0 :
|
|
|
|
|
argType == Param::BOOLEAN ? *(const bool*)value :
|
|
|
|
|
*(const double*)value != 0;
|
|
|
|
|
argType == Param::REAL ? (*(const double*)value != 0) :
|
|
|
|
|
argType == Param::FLOAT ? (*(const float*)value != 0) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (*(const unsigned int*)value != 0):
|
|
|
|
|
argType == Param::UINT64 ? (*(const uint64*)value != 0):
|
|
|
|
|
argType == Param::UCHAR ? (*(const uchar*)value != 0):
|
|
|
|
|
(int)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_bool)(val);
|
|
|
|
|
else
|
|
|
|
|
*(bool*)((uchar*)algo + p->offset) = val;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else if( p->type == Param::REAL )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
double val = argType == Param::INT ? (double)*(const int*)value :
|
|
|
|
|
argType == Param::BOOLEAN ? (double)*(const bool*)value :
|
|
|
|
|
*(const double*)value;
|
|
|
|
|
argType == Param::REAL ? (double)(*(const double*)value ) :
|
|
|
|
|
argType == Param::FLOAT ? (double)(*(const float*)value ) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (double)(*(const unsigned int*)value ) :
|
|
|
|
|
argType == Param::UINT64 ? (double)(*(const uint64*)value ) :
|
|
|
|
|
argType == Param::UCHAR ? (double)(*(const uchar*)value ) :
|
|
|
|
|
(double)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_double)(val);
|
|
|
|
|
else
|
|
|
|
|
*(double*)((uchar*)algo + p->offset) = val;
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::FLOAT )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
double val = argType == Param::INT ? (double)*(const int*)value :
|
|
|
|
|
argType == Param::BOOLEAN ? (double)*(const bool*)value :
|
|
|
|
|
argType == Param::REAL ? (double)(*(const double*)value ) :
|
|
|
|
|
argType == Param::FLOAT ? (double)(*(const float*)value ) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (double)(*(const unsigned int*)value ) :
|
|
|
|
|
argType == Param::UINT64 ? (double)(*(const uint64*)value ) :
|
|
|
|
|
argType == Param::UCHAR ? (double)(*(const uchar*)value ) :
|
|
|
|
|
(double)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_float)((float)val);
|
|
|
|
|
else
|
|
|
|
|
*(float*)((uchar*)algo + p->offset) = (float)val;
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::UNSIGNED_INT )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
unsigned int val = argType == Param::INT ? (unsigned int)*(const int*)value :
|
|
|
|
|
argType == Param::BOOLEAN ? (unsigned int)*(const bool*)value :
|
|
|
|
|
argType == Param::REAL ? saturate_cast<unsigned int>(*(const double*)value ) :
|
|
|
|
|
argType == Param::FLOAT ? saturate_cast<unsigned int>(*(const float*)value ) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (unsigned int)(*(const unsigned int*)value ) :
|
|
|
|
|
argType == Param::UINT64 ? (unsigned int)(*(const uint64*)value ) :
|
|
|
|
|
argType == Param::UCHAR ? (unsigned int)(*(const uchar*)value ) :
|
|
|
|
|
(int)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_uint)(val);
|
|
|
|
|
else
|
|
|
|
|
*(unsigned int*)((uchar*)algo + p->offset) = val;
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::UINT64 )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
uint64 val = argType == Param::INT ? (uint64)*(const int*)value :
|
|
|
|
|
argType == Param::BOOLEAN ? (uint64)*(const bool*)value :
|
|
|
|
|
argType == Param::REAL ? saturate_cast<uint64>(*(const double*)value ) :
|
|
|
|
|
argType == Param::FLOAT ? saturate_cast<uint64>(*(const float*)value ) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (uint64)(*(const unsigned int*)value ) :
|
|
|
|
|
argType == Param::UINT64 ? (uint64)(*(const uint64*)value ) :
|
|
|
|
|
argType == Param::UCHAR ? (uint64)(*(const uchar*)value ) :
|
|
|
|
|
(int)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_uint64)(val);
|
|
|
|
|
else
|
|
|
|
|
*(uint64*)((uchar*)algo + p->offset) = val;
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::UCHAR )
|
|
|
|
|
{
|
|
|
|
|
bool is_ok = true;
|
|
|
|
|
uchar val = argType == Param::INT ? (uchar)*(const int*)value :
|
|
|
|
|
argType == Param::BOOLEAN ? (uchar)*(const bool*)value :
|
|
|
|
|
argType == Param::REAL ? saturate_cast<uchar>(*(const double*)value ) :
|
|
|
|
|
argType == Param::FLOAT ? saturate_cast<uchar>(*(const float*)value ) :
|
|
|
|
|
argType == Param::UNSIGNED_INT ? (uchar)(*(const unsigned int*)value ) :
|
|
|
|
|
argType == Param::UINT64 ? (uchar)(*(const uint64*)value ) :
|
|
|
|
|
argType == Param::UCHAR ? (uchar)(*(const uchar*)value ) :
|
|
|
|
|
(int)(is_ok = false);
|
|
|
|
|
|
|
|
|
|
if (!is_ok)
|
|
|
|
|
{
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
|
|
|
|
}
|
|
|
|
|
if( p->setter )
|
|
|
|
|
(algo->*f.set_uchar)(val);
|
|
|
|
|
else
|
|
|
|
|
*(uchar*)((uchar*)algo + p->offset) = val;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong parameter type in the setter");
|
|
|
|
|
}
|
|
|
|
|
else if( argType == Param::STRING )
|
|
|
|
|
{
|
|
|
|
@@ -691,11 +855,12 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|
|
|
|
GetSetParam f;
|
|
|
|
|
f.get_int = p->getter;
|
|
|
|
|
|
|
|
|
|
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )
|
|
|
|
|
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL
|
|
|
|
|
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
|
|
|
|
|
{
|
|
|
|
|
if( p->type == Param::INT )
|
|
|
|
|
{
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::REAL ))
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
@@ -703,13 +868,24 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|
|
|
|
int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
|
|
|
|
|
|
|
|
|
|
if( argType == Param::INT )
|
|
|
|
|
*(int*)value = val;
|
|
|
|
|
*(int*)value = (int)val;
|
|
|
|
|
else if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = (double)val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = (float)val;
|
|
|
|
|
else if ( argType == Param::UNSIGNED_INT )
|
|
|
|
|
*(unsigned int*)value = (unsigned int)val;
|
|
|
|
|
else if ( argType == Param::UINT64 )
|
|
|
|
|
*(uint64*)value = (uint64)val;
|
|
|
|
|
else if ( argType == Param::UCHAR)
|
|
|
|
|
*(uchar*)value = (uchar)val;
|
|
|
|
|
else
|
|
|
|
|
*(double*)value = val;
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::BOOLEAN )
|
|
|
|
|
{
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL ))
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
@@ -720,20 +896,126 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
|
|
|
|
*(int*)value = (int)val;
|
|
|
|
|
else if( argType == Param::BOOLEAN )
|
|
|
|
|
*(bool*)value = val;
|
|
|
|
|
else
|
|
|
|
|
else if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = (int)val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = (float)((int)val);
|
|
|
|
|
else if ( argType == Param::UNSIGNED_INT )
|
|
|
|
|
*(unsigned int*)value = (unsigned int)val;
|
|
|
|
|
else if ( argType == Param::UINT64 )
|
|
|
|
|
*(uint64*)value = (int)val;
|
|
|
|
|
else if ( argType == Param::UCHAR)
|
|
|
|
|
*(uchar*)value = (uchar)val;
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else if( p->type == Param::REAL )
|
|
|
|
|
{
|
|
|
|
|
if( argType != Param::REAL )
|
|
|
|
|
if(!( argType == Param::REAL || argType == Param::FLOAT))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
|
}
|
|
|
|
|
double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
|
|
|
|
|
|
|
|
|
|
*(double*)value = val;
|
|
|
|
|
if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = (float)val;
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::FLOAT )
|
|
|
|
|
{
|
|
|
|
|
if(!( argType == Param::REAL || argType == Param::FLOAT))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
|
}
|
|
|
|
|
float val = p->getter ? (algo->*f.get_float)() : *(float*)((uchar*)algo + p->offset);
|
|
|
|
|
|
|
|
|
|
if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = (double)val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = (float)val;
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::UNSIGNED_INT )
|
|
|
|
|
{
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
|
}
|
|
|
|
|
unsigned int val = p->getter ? (algo->*f.get_uint)() : *(unsigned int*)((uchar*)algo + p->offset);
|
|
|
|
|
|
|
|
|
|
if( argType == Param::INT )
|
|
|
|
|
*(int*)value = (int)val;
|
|
|
|
|
else if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = (double)val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = (float)val;
|
|
|
|
|
else if ( argType == Param::UNSIGNED_INT )
|
|
|
|
|
*(unsigned int*)value = (unsigned int)val;
|
|
|
|
|
else if ( argType == Param::UINT64 )
|
|
|
|
|
*(uint64*)value = (uint64)val;
|
|
|
|
|
else if ( argType == Param::UCHAR)
|
|
|
|
|
*(uchar*)value = (uchar)val;
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::UINT64 )
|
|
|
|
|
{
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
|
}
|
|
|
|
|
uint64 val = p->getter ? (algo->*f.get_uint64)() : *(uint64*)((uchar*)algo + p->offset);
|
|
|
|
|
|
|
|
|
|
if( argType == Param::INT )
|
|
|
|
|
*(int*)value = (int)val;
|
|
|
|
|
else if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = (double)val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = (float)val;
|
|
|
|
|
else if ( argType == Param::UNSIGNED_INT )
|
|
|
|
|
*(unsigned int*)value = (unsigned int)val;
|
|
|
|
|
else if ( argType == Param::UINT64 )
|
|
|
|
|
*(uint64*)value = (uint64)val;
|
|
|
|
|
else if ( argType == Param::UCHAR)
|
|
|
|
|
*(uchar*)value = (uchar)val;
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
}
|
|
|
|
|
else if( p->type == Param::UCHAR )
|
|
|
|
|
{
|
|
|
|
|
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
|
|
|
|
{
|
|
|
|
|
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
|
|
|
|
CV_Error(CV_StsBadArg, message);
|
|
|
|
|
}
|
|
|
|
|
uchar val = p->getter ? (algo->*f.get_uchar)() : *(uchar*)((uchar*)algo + p->offset);
|
|
|
|
|
|
|
|
|
|
if( argType == Param::INT )
|
|
|
|
|
*(int*)value = val;
|
|
|
|
|
else if ( argType == Param::REAL )
|
|
|
|
|
*(double*)value = val;
|
|
|
|
|
else if ( argType == Param::FLOAT)
|
|
|
|
|
*(float*)value = val;
|
|
|
|
|
else if ( argType == Param::UNSIGNED_INT )
|
|
|
|
|
*(unsigned int*)value = val;
|
|
|
|
|
else if ( argType == Param::UINT64 )
|
|
|
|
|
*(uint64*)value = val;
|
|
|
|
|
else if ( argType == Param::UCHAR)
|
|
|
|
|
*(uchar*)value = val;
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Wrong argument type");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
CV_Error(CV_StsBadArg, "Unknown/unsupported parameter type");
|
|
|
|
|
}
|
|
|
|
|
else if( argType == Param::STRING )
|
|
|
|
|
{
|
|
|
|
@@ -819,7 +1101,9 @@ void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argTyp
|
|
|
|
|
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
|
|
|
|
|
argType == Param::REAL || argType == Param::STRING ||
|
|
|
|
|
argType == Param::MAT || argType == Param::MAT_VECTOR ||
|
|
|
|
|
argType == Param::ALGORITHM );
|
|
|
|
|
argType == Param::ALGORITHM
|
|
|
|
|
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64
|
|
|
|
|
|| argType == Param::UCHAR);
|
|
|
|
|
data->params.add(std::string(parameter), Param(argType, readOnly,
|
|
|
|
|
(int)((size_t)value - (size_t)(void*)&algo),
|
|
|
|
|
getter, setter, help));
|
|
|
|
@@ -896,6 +1180,46 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|
|
|
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|
|
|
|
float& value, bool readOnly,
|
|
|
|
|
float (Algorithm::*getter)(),
|
|
|
|
|
void (Algorithm::*setter)(float),
|
|
|
|
|
const std::string& help)
|
|
|
|
|
{
|
|
|
|
|
addParam_(algo, parameter, ParamType<float>::type, &value, readOnly,
|
|
|
|
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|
|
|
|
unsigned int& value, bool readOnly,
|
|
|
|
|
unsigned int (Algorithm::*getter)(),
|
|
|
|
|
void (Algorithm::*setter)(unsigned int),
|
|
|
|
|
const std::string& help)
|
|
|
|
|
{
|
|
|
|
|
addParam_(algo, parameter, ParamType<unsigned int>::type, &value, readOnly,
|
|
|
|
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|
|
|
|
uint64& value, bool readOnly,
|
|
|
|
|
uint64 (Algorithm::*getter)(),
|
|
|
|
|
void (Algorithm::*setter)(uint64),
|
|
|
|
|
const std::string& help)
|
|
|
|
|
{
|
|
|
|
|
addParam_(algo, parameter, ParamType<uint64>::type, &value, readOnly,
|
|
|
|
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
|
|
|
|
uchar& value, bool readOnly,
|
|
|
|
|
uchar (Algorithm::*getter)(),
|
|
|
|
|
void (Algorithm::*setter)(uchar),
|
|
|
|
|
const std::string& help)
|
|
|
|
|
{
|
|
|
|
|
addParam_(algo, parameter, ParamType<uchar>::type, &value, readOnly,
|
|
|
|
|
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End of file. */
|
|
|
|
|