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

Method perform_test

dlib/test/hog_image.cpp:34–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 {}
33
34 void perform_test (
35 )
36 {
37 print_spinner();
38 array2d<unsigned char> img;
39 img.set_size(200,200);
40
41 assign_all_pixels(img, 0);
42
43 hog_image<3,3,1,4,hog_signed_gradient,hog_full_interpolation> hog1, hog1_deserialized;
44 hog_image<4,4,2,4,hog_signed_gradient,hog_full_interpolation> hog2;
45
46 hog1.load(img);
47 hog2.load(img);
48
49
50 // Just test all the coordinate mapping functions.
51
52 DLIB_TEST(hog1.get_block_rect(0,0).width() == 3*3);
53 DLIB_TEST(hog1.get_block_rect(0,0).height() == 3*3);
54 DLIB_TEST(hog2.get_block_rect(0,0).width() == 4*4);
55 DLIB_TEST(hog2.get_block_rect(0,0).height() == 4*4);
56
57 DLIB_TEST(get_rect(img).contains(hog1.get_block_rect(0,0)));
58 DLIB_TEST(get_rect(img).contains(hog1.get_block_rect(hog1.nr()-1,hog1.nc()-1)));
59 DLIB_TEST(get_rect(img).contains(hog2.get_block_rect(0,0)));
60 DLIB_TEST(get_rect(img).contains(hog2.get_block_rect(hog2.nr()-1,hog2.nc()-1)));
61
62 dlib::rand rnd;
63 for (int i = 0; i < 20000; ++i)
64 {
65 point p(rnd.get_random_16bit_number(), rnd.get_random_16bit_number());
66 p.x() -= 20000;
67 p.y() -= 20000;
68
69 DLIB_TEST((hog1.feat_to_image_space(hog1.image_to_feat_space(p)) - p).length() <= 3);
70 DLIB_TEST((hog2.feat_to_image_space(hog2.image_to_feat_space(p)) - p).length() <= 10);
71
72 DLIB_TEST_MSG((hog1.image_to_feat_space(hog1.feat_to_image_space(p)) - p).length() <= 3,
73 p << " " << hog1.feat_to_image_space(p) << " " << hog1.image_to_feat_space(hog1.feat_to_image_space(p)) );
74 DLIB_TEST((hog2.image_to_feat_space(hog2.feat_to_image_space(p)) - p).length() <= 10);
75 }
76
77
78 DLIB_TEST(hog1.feat_to_image_space(point(0,0)) == point(5,5));
79 DLIB_TEST(hog2.feat_to_image_space(point(0,0)) == point(9,9));
80
81 DLIB_TEST(hog1.feat_to_image_space(point(1,1)) == point(8,8));
82 DLIB_TEST(hog2.feat_to_image_space(point(1,1)) == point(17,17));
83
84 DLIB_TEST(hog1.image_to_feat_space(hog1.feat_to_image_space(point(0,0))) == point(0,0));
85 DLIB_TEST(hog2.image_to_feat_space(hog2.feat_to_image_space(point(0,0))) == point(0,0));
86 DLIB_TEST(hog1.image_to_feat_space(hog1.feat_to_image_space(point(1,1))) == point(1,1));
87 DLIB_TEST(hog2.image_to_feat_space(hog2.feat_to_image_space(point(1,1))) == point(1,1));
88 DLIB_TEST(hog1.image_to_feat_space(hog1.feat_to_image_space(point(1,2))) == point(1,2));
89 DLIB_TEST(hog2.image_to_feat_space(hog2.feat_to_image_space(point(1,2))) == point(1,2));
90
91

Callers

nothing calls this directly

Calls 15

print_spinnerFunction · 0.85
assign_all_pixelsFunction · 0.85
get_rectFunction · 0.85
serializeFunction · 0.70
deserializeFunction · 0.70
pointClass · 0.50
set_sizeMethod · 0.45
loadMethod · 0.45
widthMethod · 0.45
get_block_rectMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected