35 import roslib; roslib.load_manifest(
'calibration_estimation')
47 return {
'baseline_shift':0,
48 'frame_id':
'default_frame',
49 'chain_id':
'default_chain',
53 'cov': {
'u':0.5, 'v':0.5} }
59 P_list = [ 1, 0, 0, 0, \
63 pts = matrix( [ [ 0, 1, 0, 2 ],
66 [ 1, 1, 1, 1 ]], float )
68 expected = matrix( [ [ 0, 1, 0, 1],
71 result = cam.project(P_list, pts)
76 self.assertAlmostEqual(numpy.linalg.norm(result-expected), 0.0, 6)
80 P_list = [ 1, 0, 0,-1, \
84 pts = matrix( [ [ 0, 1, 0, 2 ],
87 [ 1, 1, 1, 1 ]], float )
89 expected = matrix( [ [-1, 0,-.5,.5],
92 result = cam.project(P_list, pts)
97 self.assertAlmostEqual(numpy.linalg.norm(result-expected), 0.0, 6)
101 P_list = [ 1, 0, 0, 0, \
105 cam.inflate(matrix([-1]))
107 pts = matrix( [ [ 0, 1, 0, 2 ],
110 [ 1, 1, 1, 1 ]], float )
112 expected = matrix( [ [-1, 0,-.5,.5],
115 result = cam.project(P_list, pts)
120 self.assertAlmostEqual(numpy.linalg.norm(result-expected), 0.0, 6)
125 free_list = cam.calc_free( {
"baseline_shift":0,
"f_shift":0,
"cx_shift":0,
"cy_shift":0} )
126 self.assertEqual(free_list[0],
False)
128 free_list = cam.calc_free( {
"baseline_shift":1,
"f_shift":0,
"cx_shift":0,
"cy_shift":0} )
129 self.assertEqual(free_list[0],
True)
131 self.assertEqual(len(free_list), 4)
135 p = matrix([1, 0, 0, 0], float).T
136 config = cam.params_to_config(p)
137 self.assertAlmostEqual(config[
"baseline_shift"], 1, 6)
141 self.assertEqual(cam.get_length(), 4)
145 params[
'baseline_shift'] = 10
147 self.assertEqual(cam.deflate()[0,0], 10)
149 if __name__ ==
'__main__':
151 rostest.unitrun(
'calibration_estimation',
'test_RectifiedCamera', TestRectifiedCamera, coverage_packages=[
'calibration_estimation.camera'])
def test_params_to_config(self)
def test_project_easy_1(self)
def test_project_easy_2(self)
def test_project_easy_3(self)