Пример #1
0
    def test_image_coord_regress(self):

        self.calibration.set_pos(np.array([0, 0, 40]))
        self.calibration.set_angles(np.array([0, 0, 0]))
        self.calibration.set_primary_point(np.array([0, 0, 10]))
        self.calibration.set_glass_vec(np.array([0, 0, 20]))
        self.calibration.set_radial_distortion(np.array([0, 0, 0]))
        self.calibration.set_decentering(np.array([0, 0]))
        self.calibration.set_affine_trans(np.array([1, 0]))

        self.mult = MultimediaParams(n1=1,
                                     n2=np.array([1]),
                                     n3=1,
                                     d=np.array([1]))

        input = np.array([[10., 5., -20.], [10., 5., -20.]])  # vec3d
        output = np.zeros((2, 2))

        x = 10. / 6.
        y = x / 2.
        correct_output = np.array([[x, y], [x, y]])

        flat_image_coordinates(input=input,
                               cal=self.calibration,
                               mult_params=self.mult,
                               output=output)
        np.testing.assert_array_equal(output, correct_output)

        output = np.full((2, 2), 999.)
        image_coordinates(input=input,
                          cal=self.calibration,
                          mult_params=self.mult,
                          output=output)

        np.testing.assert_array_equal(output, correct_output)
Пример #2
0
 def test_mm_np_instantiation(self):
     
     n2_np = numpy.array([11,22,33])
     d_np = numpy.array([55,66,77])
     
     m = MultimediaParams(nlay=3, n1=2, n2=n2_np, d=d_np, n3=4, lut=1)
     
     self.failUnlessEqual(m.get_nlay(), 3)
     self.failUnlessEqual(m.get_n1(), 2)
     self.failUnlessEqual(m.get_n3(), 4)
     self.failUnlessEqual(m.get_lut(), 1)
     
     numpy.testing.assert_array_equal(m.get_d(), d_np)
     numpy.testing.assert_array_equal(m.get_n2(), n2_np)
     
     self.failUnlessEqual(m.__str__(), "nlay=\t3 \nn1=\t2.0 \nn2=\t{11.0, 22.0, 33.0} \nd=\t{55.0, 66.0, 77.0} \nn3=\t4.0 \nlut=\t1 ")
 def test_mm_np_instantiation(self):
     
     n2_np = numpy.array([11, 22, 33])
     d_np = numpy.array([55, 66, 77])
     
     # Initialize MultimediaParams object (uses all setters of MultimediaParams)
     m = MultimediaParams(n1=2, n2=n2_np, d=d_np, n3=4)
     self.failUnlessEqual(m.get_nlay(), 3)
     self.failUnlessEqual(m.get_n1(), 2)
     self.failUnlessEqual(m.get_n3(), 4)
     self.failUnlessEqual(m.get_nlay(), len(d_np))
     
     numpy.testing.assert_array_equal(m.get_d(), d_np)
     numpy.testing.assert_array_equal(m.get_n2(), n2_np)
     
     self.failUnlessEqual(m.__str__(), "nlay=\t3 \nn1=\t2.0 \nn2=\t{11.0, 22.0, 33.0} \nd=\t{55.0, 66.0, 77.0} \nn3=\t4.0 ")
     
     # pass two arrays with different number of elements
     new_arr = numpy.array([1, 2, 3, 4])
     with self.assertRaises(ValueError):
         m.set_layers(new_arr, d_np)
     new_arr = numpy.array([1, 2, 3])
     
     arr = m.get_n2(copy=False)  # don't copy the values: link directly to memory 
     arr[0] = 77.77
     arr[1] = 88.88
     arr[2] = 99.99
     # assert that the arr affected the contents of m object
     numpy.testing.assert_array_equal(m.get_n2(), [77.77, 88.88, 99.99])
Пример #4
0
 def test_mm_np_instantiation(self):
     
     n2_np = numpy.array([11, 22, 33])
     d_np = numpy.array([55, 66, 77])
     
     # Initialize MultimediaParams object (uses all setters of MultimediaParams)
     m = MultimediaParams(n1=2, n2=n2_np, d=d_np, n3=4)
     self.failUnlessEqual(m.get_nlay(), 3)
     self.failUnlessEqual(m.get_n1(), 2)
     self.failUnlessEqual(m.get_n3(), 4)
     self.failUnlessEqual(m.get_nlay(), len(d_np))
     
     numpy.testing.assert_array_equal(m.get_d(), d_np)
     numpy.testing.assert_array_equal(m.get_n2(), n2_np)
     
     self.failUnlessEqual(m.__str__(), "nlay=\t3 \nn1=\t2.0 \nn2=\t{11.0, 22.0, 33.0} \nd=\t{55.0, 66.0, 77.0} \nn3=\t4.0 ")
     
     # pass two arrays with different number of elements
     new_arr = numpy.array([1, 2, 3, 4])
     with self.assertRaises(ValueError):
         m.set_layers(new_arr, d_np)
     new_arr = numpy.array([1, 2, 3])
     
     arr = m.get_n2(copy=False)  # don't copy the values: link directly to memory 
     arr[0] = 77.77
     arr[1] = 88.88
     arr[2] = 99.99
     # assert that the arr affected the contents of m object
     numpy.testing.assert_array_equal(m.get_n2(), [77.77, 88.88, 99.99])