29 #define PLUS '+' //flag states 35 return &global_params;
49 }
else if (*file ==
MINUS) {
55 fp = fopen(file + nameoffset,
"rb");
57 tprintf(
"read_params_file: Can't open %s\n", file + nameoffset);
73 while ((end_offset < 0 || ftell(fp) < end_offset) &&
75 if (line[0] !=
'\r' && line[0] !=
'\n' && line[0] !=
'#') {
77 for (valptr = line; *valptr && *valptr !=
' ' && *valptr !=
'\t';
83 while (*valptr ==
' ' || *valptr ==
'\t');
85 foundit =
SetParam(line, valptr, constraint, member_params);
89 tprintf(
"read_params_file: parameter not found: %s\n", line);
104 if (*value ==
'\0')
return (sp != NULL);
111 sscanf(value,
"%d", &intval) == 1) ip->
set_value(intval);
117 if (*value ==
'T' || *value ==
't' ||
118 *value ==
'Y' || *value ==
'y' || *value ==
'1') {
120 }
else if (*value ==
'F' || *value ==
'f' ||
121 *value ==
'N' || *value ==
'n' || *value ==
'0') {
134 if (sscanf(value,
"%lf", &doubleval) == 1)
138 return (sp || ip || bp || dp);
156 snprintf(buf,
sizeof(buf),
"%d",
inT32(*ip));
164 *value =
BOOL8(*bp) ?
"1":
"0";
172 snprintf(buf,
sizeof(buf),
"%g",
double(*dp));
181 int num_iterations = (member_params == NULL) ? 1 : 2;
182 for (v = 0; v < num_iterations; ++v) {
184 for (i = 0; i < vec->
int_params.size(); ++i) {
185 fprintf(fp,
"%s\t%d\t%s\n", vec->
int_params[i]->name_str(),
189 fprintf(fp,
"%s\t%d\t%s\n", vec->
bool_params[i]->name_str(),
193 fprintf(fp,
"%s\t%s\t%s\n", vec->
string_params[i]->name_str(),
197 fprintf(fp,
"%s\t%g\t%s\n", vec->
double_params[i]->name_str(),
206 int num_iterations = (member_params == NULL) ? 1 : 2;
207 for (v = 0; v < num_iterations; ++v) {
209 for (i = 0; i < vec->
int_params.size(); ++i) {
GenericVector< BoolParam * > bool_params
tesseract::ParamsVectors * GlobalParams()
double strtofloat(const char *s)
bool constraint_ok(SetParamConstraint constraint) const
static bool GetParamAsString(const char *name, const ParamsVectors *member_params, STRING *value)
void set_value(double value)
GenericVector< DoubleParam * > double_params
const char * string() const
GenericVector< StringParam * > string_params
GenericVector< IntParam * > int_params
static void ResetToDefaults(ParamsVectors *member_params)
void set_value(BOOL8 value)
static bool SetParam(const char *name, const char *value, SetParamConstraint constraint, ParamsVectors *member_params)
static bool ReadParamsFromFp(FILE *fp, inT64 end_offset, SetParamConstraint constraint, ParamsVectors *member_params)
static bool TESS_API ReadParamsFile(const char *file, SetParamConstraint constraint, ParamsVectors *member_params)
void set_value(const STRING &value)
void set_value(inT32 value)
static void PrintParams(FILE *fp, const ParamsVectors *member_params)
void chomp_string(char *str)