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

Function test_find_affine_transform

dlib/test/geometry.cpp:657–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655// ----------------------------------------------------------------------------------------
656
657 void test_find_affine_transform()
658 {
659 //typedef dlib::vector<double,2> vect;
660 typedef point vect;
661 std::vector<vect> from, to;
662
663 from.push_back(vect(0,0));
664 to.push_back(vect(0,1));
665
666 from.push_back(vect(0,1));
667 to.push_back(vect(1,1));
668
669 from.push_back(vect(1,1));
670 to.push_back(vect(1,0));
671
672 from.push_back(vect(1,0));
673 to.push_back(vect(0,0));
674
675 point_transform_affine t = find_affine_transform(from,to);
676 point_transform_affine tinv = inv(t);
677
678 for (unsigned long i = 0; i < from.size(); ++i)
679 {
680 dlog << LINFO << "affine transformation error: "<< length(t(from[i])-to[i]);
681 DLIB_TEST(length(t(from[i])-to[i]) < 1e-14);
682 DLIB_TEST(length(tinv(t(from[i]))-from[i]) < 1e-14);
683 DLIB_TEST(length(t(tinv(from[i]))-from[i]) < 1e-14);
684
685 point_transform_affine temp = t*inv(t);
686 DLIB_TEST(length(temp.get_b()) < 1e-14);
687 DLIB_TEST(max(abs(temp.get_m() - identity_matrix<double>(2))) < 1e-14);
688 }
689
690 ostringstream sout;
691 serialize(t, sout);
692 istringstream sin(sout.str());
693 point_transform_affine t2;
694 DLIB_TEST(length(t2(point(2,3)) - point(2,3)) < 1e-14);
695 deserialize(t2, sin);
696 DLIB_TEST(max(abs(t2.get_m()-t.get_m())) < 1e-14);
697 DLIB_TEST(max(abs(t2.get_b()-t.get_b())) < 1e-14);
698 }
699
700// ----------------------------------------------------------------------------------------
701

Callers 1

perform_testMethod · 0.85

Calls 13

find_affine_transformFunction · 0.85
absFunction · 0.85
get_bMethod · 0.80
serializeFunction · 0.70
deserializeFunction · 0.70
invFunction · 0.50
lengthFunction · 0.50
maxFunction · 0.50
pointClass · 0.50
push_backMethod · 0.45
sizeMethod · 0.45
get_mMethod · 0.45

Tested by

no test coverage detected