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

Function run_test3

dlib/test/scan_image.cpp:324–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322
323 template <typename pixel_type>
324 void run_test3(const double thresh)
325 {
326 dlog << LINFO << "running run_test3("<<thresh<<")";
327 dlib::rand rnd;
328
329 rnd.set_seed("235");
330
331 array<array2d<pixel_type> > images;
332 images.resize(1);
333 images[0].set_size(200,180);
334
335 for (int iter = 0; iter < 50; ++iter)
336 {
337 print_spinner();
338 assign_all_pixels(images[0], thresh - 0.0001);
339
340 for (int i = 0; i < 20; ++i)
341 {
342 point p1(rnd.get_random_32bit_number()%images[0].nc(),
343 rnd.get_random_32bit_number()%images[0].nr());
344 point p2(rnd.get_random_32bit_number()%images[0].nc(),
345 rnd.get_random_32bit_number()%images[0].nr());
346
347 rectangle rect(p1,p2);
348 fill_rect(images[0], rect, static_cast<pixel_type>(rnd.get_random_double()*10 - 5));
349 }
350
351 std::vector<std::pair<unsigned int, rectangle> > rects;
352 rects.push_back(make_pair(0,centered_rect(0,0,1+rnd.get_random_32bit_number()%40,1+rnd.get_random_32bit_number()%40)));
353 rects.push_back(make_pair(0,centered_rect(0,0,1+rnd.get_random_32bit_number()%40,1+rnd.get_random_32bit_number()%40)));
354
355
356
357
358 std::vector<std::pair<double, point> > dets, dets2, dets3;
359 scan_image(dets,images,rects,thresh, 100);
360 scan_image_i(dets2,images,rects,thresh, 100);
361 scan_image_old(dets3,images,rects,thresh, 100);
362
363 dlog << LTRACE << "dets.size(): "<< dets.size();
364 dlog << LTRACE << "dets2.size(): "<< dets2.size();
365 dlog << LTRACE << "dets3.size(): "<< dets3.size();
366
367 DLIB_TEST(dets.size() == dets2.size());
368 DLIB_TEST(dets.size() == dets3.size());
369
370 for (unsigned long i = 0; i < dets.size(); ++i)
371 {
372 //dlog << LTRACE << "dets["<<i<<"]: " << dets[i].second << " -> " << dets[i].first;
373 //dlog << LTRACE << "dets2["<<i<<"]: " << dets2[i].second << " -> " << dets2[i].first;
374 //dlog << LTRACE << "dets3["<<i<<"]: " << dets3[i].second << " -> " << dets3[i].first;
375
376 DLIB_TEST_MSG(std::abs(sum_of_rects_in_images(images, rects, dets[i].second) - dets[i].first) < 1e-6,
377 "error: "<< sum_of_rects_in_images(images, rects, dets[i].second) - dets[i].first
378 << " dets["<<i<<"].second: " << dets[i].second
379 );
380 DLIB_TEST_MSG(std::abs(sum_of_rects_in_images(images, rects, dets2[i].second) - dets2[i].first) < 1e-6,
381 sum_of_rects_in_images(images, rects, dets2[i].second) - dets2[i].first

Callers

nothing calls this directly

Calls 15

print_spinnerFunction · 0.85
assign_all_pixelsFunction · 0.85
centered_rectFunction · 0.85
scan_imageFunction · 0.85
scan_image_iFunction · 0.85
scan_image_oldFunction · 0.85
absFunction · 0.85
sum_of_rects_in_imagesFunction · 0.85
get_random_doubleMethod · 0.80
fill_rectFunction · 0.50
set_seedMethod · 0.45

Tested by

no test coverage detected