parameters: (left_imgs, right_imgs, bagname)
docstring: Creates a bag file containing stereo image pairs
docstring_summary: Creates a bag file containing stereo image pairs
docstring_tokens: Creates a bag file containing stereo image pairs
function: def CreateStereoBag(left_imgs, right_imgs, bagname):
      '''Creates a bag file containing stereo image pairs'''
      bag =rosbag.Bag(bagname, 'w')
  
      try:
          for i in range(len(left_imgs)):
              print("Adding %s" % left_imgs[i])
              fp_left = open( left_imgs[i], "r" )
              p_left = ImageFile.Parser()
  
              while 1:
                  s = fp_left.read(1024)
                  if not s:
                      break
                  p_left.feed(s)
  
              im_left = p_left.close()
  
              fp_right = open( right_imgs[i], "r" )
              print("Adding %s" % right_imgs[i])
              p_right = ImageFile.Parser()
  
              while 1:
                  s = fp_right.read(1024)
                  if not s:
                      break
                  p_right.feed(s)
  
              im_right = p_right.close()
  
              Stamp = roslib.rostime.Time.from_sec(time.time())
  
              Img_left = Image()
              Img_left.header.stamp = Stamp
              Img_left.width = im_left.size[0]
              Img_left.height = im_left.size[1]
              Img_left.encoding = "rgb8"
              Img_left.header.frame_id = "camera/left"
              Img_left_data = [pix for pixdata in im_left.getdata() for pix in pixdata]
              Img_left.data = Img_left_data
              Img_right = Image()
              Img_right.header.stamp = Stamp
              Img_right.width = im_right.size[0]
              Img_right.height = im_right.size[1]
              Img_right.encoding = "rgb8"
              Img_right.header.frame_id = "camera/right"
              Img_right_data = [pix for pixdata in im_right.getdata() for pix in pixdata]
              Img_right.data = Img_right_data
  
              bag.write('camera/left/image_raw', Img_left, Stamp)
              bag.write('camera/right/image_raw', Img_right, Stamp)
      finally:
          bag.close()
function_tokens: def CreateStereoBag ( left_imgs , right_imgs , bagname ) : bag = rosbag . Bag ( bagname , 'w' ) try : for i in range ( len ( left_imgs ) ) : print ( "Adding %s" % left_imgs [ i ] ) fp_left = open ( left_imgs [ i ] , "r" ) p_left = ImageFile . Parser ( ) while 1 : s = fp_left . read ( 1024 ) if not s : break p_left . feed ( s ) im_left = p_left . close ( ) fp_right = open ( right_imgs [ i ] , "r" ) print ( "Adding %s" % right_imgs [ i ] ) p_right = ImageFile . Parser ( ) while 1 : s = fp_right . read ( 1024 ) if not s : break p_right . feed ( s ) im_right = p_right . close ( ) Stamp = roslib . rostime . Time . from_sec ( time . time ( ) ) Img_left = Image ( ) Img_left . header . stamp = Stamp Img_left . width = im_left . size [ 0 ] Img_left . height = im_left . size [ 1 ] Img_left . encoding = "rgb8" Img_left . header . frame_id = "camera/left" Img_left_data = [ pix for pixdata in im_left . getdata ( ) for pix in pixdata ] Img_left . data = Img_left_data Img_right = Image ( ) Img_right . header . stamp = Stamp Img_right . width = im_right . size [ 0 ] Img_right . height = im_right . size [ 1 ] Img_right . encoding = "rgb8" Img_right . header . frame_id = "camera/right" Img_right_data = [ pix for pixdata in im_right . getdata ( ) for pix in pixdata ] Img_right . data = Img_right_data bag . write ( 'camera/left/image_raw' , Img_left , Stamp ) bag . write ( 'camera/right/image_raw' , Img_right , Stamp ) finally : bag . close ( )