def test_multiple_boards(self):
        small_board = ChessboardInfo()
        small_board.n_cols = 5
        small_board.n_rows = 4
        small_board.dim = 0.025

        stereo_cal = StereoCalibrator([board, small_board])
        
        my_archive_name = roslib.packages.find_resource('camera_calibration', 'multi_board_calibration.tar.gz')[0]
        stereo_cal.do_tarfile_calibration(my_archive_name)

        stereo_cal.report()
        stereo_cal.ost()
        
        # Check error for big image
        archive = tarfile.open(my_archive_name)
        l1_big = image_from_archive(archive, "left-0000.png")
        r1_big = image_from_archive(archive, "right-0000.png")
        epi_big = stereo_cal.epipolar_error_from_images(l1_big, r1_big)
        self.assert_(epi_big < 1.0, "Epipolar error for large checkerboard > 1.0. Error: %.2f" % epi_big)

        # Small checkerboard has larger error threshold for now
        l1_sm = image_from_archive(archive, "left-0012-sm.png")
        r1_sm = image_from_archive(archive, "right-0012-sm.png")
        epi_sm =  stereo_cal.epipolar_error_from_images(l1_sm, r1_sm)
        self.assert_(epi_sm < 2.0, "Epipolar error for small checkerboard > 2.0. Error: %.2f" % epi_sm)
 def setUp(self):
     tar_path = roslib.packages.find_resource('camera_calibration', 'camera_calibration.tar.gz')[0]
     self.tar = tarfile.open(tar_path, 'r')
     self.limages = [image_from_archive(self.tar, "wide/left%04d.pgm" % i) for i in range(3, 15)]
     self.rimages = [image_from_archive(self.tar, "wide/right%04d.pgm" % i) for i in range(3, 15)]
     self.l = {}
     self.r = {}
     self.sizes = [(320,240), (640,480), (800,600), (1024,768)]
     for dim in self.sizes:
         self.l[dim] = []
         self.r[dim] = []
         for li,ri in zip(self.limages, self.rimages):
             rli = cv2.resize(li, (dim[0], dim[1]))
             rri = cv2.resize(ri, (dim[0], dim[1]))
             self.l[dim].append(rli)
             self.r[dim].append(rri)
Exemple #3
0
 def setUp(self):
     self.mydir = roslib.packages.get_pkg_dir(PKG)
     self.tar = tarfile.open('%s/camera_calibration.tar.gz' % self.mydir, 'r')
     self.limages = [image_from_archive(self.tar, "wide/left%04d.pgm" % i) for i in range(3, 15)]
     self.rimages = [image_from_archive(self.tar, "wide/right%04d.pgm" % i) for i in range(3, 15)]
     self.l = {}
     self.r = {}
     self.sizes = [(320,240), (640,480), (800,600), (1024,768)]
     for dim in self.sizes:
         self.l[dim] = []
         self.r[dim] = []
         for li,ri in zip(self.limages, self.rimages):
             rli = cv.CreateMat(dim[1], dim[0], cv.CV_8UC3)
             rri = cv.CreateMat(dim[1], dim[0], cv.CV_8UC3)
             cv.Resize(li, rli)
             cv.Resize(ri, rri)
             self.l[dim].append(rli)
             self.r[dim].append(rri)
Exemple #4
0
 def setUp(self):
     tar_path = roslib.packages.find_resource(
         'camera_calibration', 'camera_calibration.tar.gz')[0]
     self.tar = tarfile.open(tar_path, 'r')
     self.limages = [
         image_from_archive(self.tar, "wide/left%04d.pgm" % i)
         for i in range(3, 15)
     ]
     self.rimages = [
         image_from_archive(self.tar, "wide/right%04d.pgm" % i)
         for i in range(3, 15)
     ]
     self.l = {}
     self.r = {}
     self.sizes = [(320, 240), (640, 480), (800, 600), (1024, 768)]
     for dim in self.sizes:
         self.l[dim] = []
         self.r[dim] = []
         for li, ri in zip(self.limages, self.rimages):
             rli = cv2.resize(li, (dim[0], dim[1]))
             rri = cv2.resize(ri, (dim[0], dim[1]))
             self.l[dim].append(rli)
             self.r[dim].append(rri)
    def test_multiple_boards(self):
        small_board = ChessboardInfo()
        small_board.n_cols = 5
        small_board.n_rows = 4
        small_board.dim = 0.025

        stereo_cal = StereoCalibrator([board, small_board])
        if not os.path.isfile('/tmp/multi_board_calibration.tar.gz'):
            url = 'http://download.ros.org/data/camera_calibration/multi_board_calibration.tar.gz'
            r = requests.get(url, allow_redirects=True)
            with open('/tmp/multi_board_calibration.tar.gz', 'wb') as mcf:
                mcf.write(r.content)

        my_archive_name = '/tmp/multi_board_calibration.tar.gz'
        stereo_cal.do_tarfile_calibration(my_archive_name)

        stereo_cal.report()
        stereo_cal.ost()

        # Check error for big image
        archive = tarfile.open(my_archive_name)
        l1_big = image_from_archive(archive, "left-0000.png")
        r1_big = image_from_archive(archive, "right-0000.png")
        epi_big = stereo_cal.epipolar_error_from_images(l1_big, r1_big)
        self.assertTrue(
            epi_big < 1.0,
            "Epipolar error for large checkerboard > 1.0. Error: %.2f" %
            epi_big)

        # Small checkerboard has larger error threshold for now
        l1_sm = image_from_archive(archive, "left-0012-sm.png")
        r1_sm = image_from_archive(archive, "right-0012-sm.png")
        epi_sm = stereo_cal.epipolar_error_from_images(l1_sm, r1_sm)
        self.assertTrue(
            epi_sm < 2.0,
            "Epipolar error for small checkerboard > 2.0. Error: %.2f" %
            epi_sm)