From 81b6f5975bf89fbb379f32a93a49fa0bbbc03c86 Mon Sep 17 00:00:00 2001 From: Kai Ni Date: Wed, 24 Mar 2010 02:20:54 +0000 Subject: [PATCH] added unit tests --- cpp/testSimpleCamera.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cpp/testSimpleCamera.cpp b/cpp/testSimpleCamera.cpp index 070b79258..2f2ac89c2 100644 --- a/cpp/testSimpleCamera.cpp +++ b/cpp/testSimpleCamera.cpp @@ -69,6 +69,23 @@ TEST( SimpleCamera, backproject) CHECK(assert_equal( camera.backproject(Point2( 100, 100), 0.5), point4)); } +/* ************************************************************************* */ +TEST( SimpleCamera, backproject2) +{ + Point3 origin; + Rot3 rot(1., 0., 0., 0., 0., 1., 0., -1., 0.); // a camera looking down + SimpleCamera camera(K, Pose3(rot, origin)); + + + Point3 actual = camera.backproject(Point2(), 1.); + Point3 expected(0., 1., 0.); + pair x = camera.projectSafe(expected); + + CHECK(assert_equal(expected, actual)); + CHECK(assert_equal(Point2(), x.first)); + CHECK(x.second); +} + /* ************************************************************************* */ Point2 project2(const Pose3& pose, const Point3& point) { return project(SimpleCamera(K,pose), point);