Ejemplo n.º 1
0
    def test_free(self):
        cam = RectifiedCamera(DefaultParams())
        free_list = cam.calc_free( {"baseline_shift":0, "f_shift":0, "cx_shift":0, "cy_shift":0} )
        self.assertEqual(free_list[0], False)

        free_list = cam.calc_free( {"baseline_shift":1, "f_shift":0, "cx_shift":0, "cy_shift":0} )
        self.assertEqual(free_list[0], True)

        self.assertEqual(len(free_list), 4)
Ejemplo n.º 2
0
    def test_project_easy_2(self):
        cam = RectifiedCamera(DefaultParams())
        P_list = [ 1, 0, 0,-1, \
                   0, 1, 0, 0, \
                   0, 0, 1, 0 ]

        pts = matrix([[0, 1, 0, 2], [0, 1, 1, 0], [1, 1, 2, 2], [1, 1, 1, 1]],
                     float)

        expected = matrix([[-1, 0, -.5, .5], [0, 1, .5, 0]])

        result = cam.project(P_list, pts)

        print ""
        print result

        self.assertAlmostEqual(numpy.linalg.norm(result - expected), 0.0, 6)
Ejemplo n.º 3
0
    def test_free(self):
        cam = RectifiedCamera(DefaultParams())
        free_list = cam.calc_free({
            "baseline_shift": 0,
            "f_shift": 0,
            "cx_shift": 0,
            "cy_shift": 0
        })
        self.assertEqual(free_list[0], False)

        free_list = cam.calc_free({
            "baseline_shift": 1,
            "f_shift": 0,
            "cx_shift": 0,
            "cy_shift": 0
        })
        self.assertEqual(free_list[0], True)

        self.assertEqual(len(free_list), 4)
Ejemplo n.º 4
0
    def test_project_easy_2(self):
        cam = RectifiedCamera(DefaultParams())
        P_list = [ 1, 0, 0,-1, \
                   0, 1, 0, 0, \
                   0, 0, 1, 0 ]

        pts = matrix( [ [ 0, 1, 0, 2 ],
                        [ 0, 1, 1, 0 ],
                        [ 1, 1, 2, 2 ],
                        [ 1, 1, 1, 1 ]], float )

        expected = matrix( [ [-1, 0,-.5,.5],
                             [ 0, 1, .5, 0] ] )

        result = cam.project(P_list, pts)

        print ""
        print result

        self.assertAlmostEqual(numpy.linalg.norm(result-expected), 0.0, 6)
Ejemplo n.º 5
0
 def test_deflate(self):
     params = DefaultParams()
     params['baseline_shift'] = 10
     cam = RectifiedCamera(params)
     self.assertEqual(cam.deflate()[0, 0], 10)
Ejemplo n.º 6
0
 def test_length(self):
     cam = RectifiedCamera(DefaultParams())
     self.assertEqual(cam.get_length(), 4)
Ejemplo n.º 7
0
 def test_params_to_config(self):
     cam = RectifiedCamera(DefaultParams())
     p = matrix([1, 0, 0, 0], float).T
     config = cam.params_to_config(p)
     self.assertAlmostEqual(config["baseline_shift"], 1, 6)
Ejemplo n.º 8
0
 def test_deflate(self):
     params = DefaultParams()
     params['baseline_shift'] = 10
     cam = RectifiedCamera(params)
     self.assertEqual(cam.deflate()[0,0], 10)
Ejemplo n.º 9
0
 def test_length(self):
     cam = RectifiedCamera(DefaultParams())
     self.assertEqual(cam.get_length(), 4)
Ejemplo n.º 10
0
 def test_params_to_config(self):
     cam = RectifiedCamera(DefaultParams())
     p = matrix([1, 0, 0, 0], float).T
     config = cam.params_to_config(p)
     self.assertAlmostEqual(config["baseline_shift"], 1, 6)