MCPcopy Create free account
hub / github.com/davisking/dlib / run_test1

Function run_test1

dlib/test/scan_image.cpp:214–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212// ----------------------------------------------------------------------------------------
213
214 void run_test1()
215 {
216 dlog << LINFO << "run_test1()";
217
218 print_spinner();
219 array2d<unsigned char> img, temp_img;
220 img.set_size(600,600);
221 assign_all_pixels(img,0);
222 rectangle rect = centered_rect(10,10,5,5);
223 dlog << LTRACE << "expected: 10,10";
224 fill_rect(img, rect, 255);
225
226
227 array<array2d<unsigned char> > images;
228 std::vector<std::pair<unsigned int, rectangle> > rects;
229 for (int i = 0; i < 10; ++i)
230 {
231 assign_image(temp_img, img);
232 images.push_back(temp_img);
233 rects.push_back(make_pair(i,centered_rect(0,0,5,5)));
234 }
235
236 std::vector<std::pair<double, point> > dets, dets2, dets3;
237
238
239 dlog << LTRACE << "best score: "<< sum_of_rects_in_images(images,rects,point(10,10));
240 scan_image(dets,images,rects,30000, 100);
241 scan_image_i(dets2,images,rects,30000, 100);
242 scan_image_old(dets3,images,rects,30000, 100);
243
244
245
246 dlog << LTRACE << "dets.size(): "<< dets.size();
247 dlog << LTRACE << "dets2.size(): "<< dets2.size();
248 dlog << LTRACE << "dets3.size(): "<< dets3.size();
249
250 DLIB_TEST(dets.size() == dets2.size());
251 DLIB_TEST(dets.size() == dets3.size());
252
253 for (unsigned long i = 0; i < dets.size(); ++i)
254 {
255 //dlog << LTRACE << "dets["<<i<<"]: " << dets[i].second << " -> " << dets[i].first;
256 //dlog << LTRACE << "dets2["<<i<<"]: " << dets2[i].second << " -> " << dets2[i].first;
257 //dlog << LTRACE << "dets3["<<i<<"]: " << dets3[i].second << " -> " << dets3[i].first;
258
259 DLIB_TEST(sum_of_rects_in_images(images, rects, dets[i].second) == dets[i].first);
260 DLIB_TEST(sum_of_rects_in_images(images, rects, dets2[i].second) == dets2[i].first);
261 DLIB_TEST(sum_of_rects_in_images(images, rects, dets3[i].second) == dets3[i].first);
262 }
263
264
265 }
266
267// ----------------------------------------------------------------------------------------
268

Callers 1

perform_testMethod · 0.85

Calls 13

print_spinnerFunction · 0.85
assign_all_pixelsFunction · 0.85
centered_rectFunction · 0.85
sum_of_rects_in_imagesFunction · 0.85
scan_imageFunction · 0.85
scan_image_iFunction · 0.85
scan_image_oldFunction · 0.85
fill_rectFunction · 0.50
assign_imageFunction · 0.50
pointClass · 0.50
set_sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected