parser.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Software License Agreement (BSD License)
4 #
5 # Copyright (c) 2009, Willow Garage, Inc.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 #
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above
15 # copyright notice, this list of conditions and the following
16 # disclaimer in the documentation and/or other materials provided
17 # with the distribution.
18 # * Neither the name of the Willow Garage nor the names of its
19 # contributors may be used to endorse or promote products derived
20 # from this software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34 
35 import rosunit
36 import subprocess
37 import unittest
38 import os
39 from camera_calibration_parsers import readCalibration
40 
41 class TestParser(unittest.TestCase):
42  def test_ini(self):
43  for files in [('calib5.ini', 'calib5.yaml'), ('calib8.ini', 'calib8.yaml')]:
44  for dir in [ '', './']:
45  p = subprocess.Popen('rosrun camera_calibration_parsers convert $(rospack find camera_calibration_parsers)/test/%s %s%s' % (files[0], dir, files[1]), shell=True, stderr=subprocess.PIPE)
46  out, err = p.communicate()
47  self.assertEqual(err, '')
48 
50  script_dir = os.path.dirname(os.path.realpath(__file__))
51  camera_name, camera_info = readCalibration(os.path.join(script_dir, 'calib5.ini'))
52  self.assertEqual(camera_name, 'mono_left')
53  self.assertEqual(camera_info.height, 480)
54  self.assertEqual(camera_info.width, 640)
55  self.assertEqual(camera_info.P[0], 262.927429)
56 
57  camera_name, camera_info = readCalibration(os.path.join(script_dir, 'calib8.ini'))
58  self.assertEqual(camera_info.distortion_model, 'rational_polynomial')
59 
60 if __name__ == '__main__':
61  rosunit.unitrun('camera_calibration_parsers', 'parser', TestParser)
bool readCalibration(const std::string &file_name, std::string &camera_name, sensor_msgs::CameraInfo &cam_info)
Read calibration parameters from a file.
Definition: parse.cpp:54
def test_ini(self)
Definition: parser.py:42
def test_readCalibration(self)
Definition: parser.py:49


camera_calibration_parsers
Author(s): Patrick Mihelich
autogenerated on Sat Apr 4 2020 03:14:56