32 #include <sys/resource.h>
44 sprintf(fn,
"/proc/%d/statm", getpid());
46 fscanf(f,
"%d", &mem);
60 int _class_number,
int _max_depth,
62 :
image_classifier(_image_width, _image_height, _class_number,_LearnProgress)
74 ifstream ifs(filename.data());
84 int nodes_plus_leaves_number;
85 ifs >> nodes_plus_leaves_number;
91 for(
int i = 0; i < nodes_plus_leaves_number; i++)
95 nodes[tmp_node->index] = tmp_node;
106 for(
int i = 0; i < nodes_plus_leaves_number; i++)
131 cout <<
". Ok." << endl;
144 cout <<
"Saving tree (" << filename <<
")..." << flush;
146 ofstream ofs(filename.data());
150 ofs <<
"max_depth: " <<
max_depth << endl;
158 cout <<
"...ok." << endl;
165 for(
int i = 0; i < call_number; i++)
167 cout <<
"REFINEMENT: " << call_number - i <<
"... \r" << flush;
171 for(vector<image_class_example *>::iterator it = examples->begin(); it < examples->end(); it++)
178 node->
P[(*it)->class_index]++;
188 cout <<
"Refinement done (" << call_number <<
" calls to generate_random_examples). " << endl;
197 inlier_total[i] = total[i] = 0;
199 for(
int i = 0; i < call_number; i++)
201 cout <<
"GENERATING TESTING SET: " << call_number - i <<
"... " << (char)13 << flush;
205 for(vector<image_class_example *>::iterator it = examples->begin(); it < examples->end(); it++)
207 int found_class_index =
recognize(*it, 0);
209 total[(*it)->class_index]++;
210 if ((*it)->class_index == found_class_index)
211 inlier_total[found_class_index]++;
219 cout <<
"Test: " << flush;
222 cout <<
"[class " << i <<
": ";
224 cout <<
"not represented !!!]." << flush;
226 cout << std::setprecision(1) << 100. * float(inlier_total[i]) / total[i] <<
"% inliers]." << flush;
233 IT += inlier_total[i];
236 cout <<
"ok) -> " << setprecision(1) << 100. * float(IT) / T <<
"% inliers." << endl;
256 unsigned char * I = (
unsigned char *)(pv->
preprocessed->imageData);
260 int dot_product = (int)I[node->
d1] - (
int)I[node->
d2];
262 if (dot_product <= 0)