parameters: (path_images, keypoints, rec)
return_statement: return tracks_manager, image_ix_to_shot_id
docstring: Read images.bin, building shots and tracks graph
docstring_summary: Read images.bin, building shots and tracks graph
docstring_tokens: Read images . bin building shots and tracks graph
function: def import_images_reconstruction(path_images, keypoints, rec):
      """
      Read images.bin, building shots and tracks graph
      """
      logger.info("Importing images from {}".format(path_images))
      tracks_manager = pymap.TracksManager()
      image_ix_to_shot_id = {}
      with open(path_images, "rb") as f:
          n_ims = unpack("<Q", f.read(8))[0]
          for image_ix in range(n_ims):
              image_id = unpack("<I", f.read(4))[0]
              q0 = unpack("<d", f.read(8))[0]
              q1 = unpack("<d", f.read(8))[0]
              q2 = unpack("<d", f.read(8))[0]
              q3 = unpack("<d", f.read(8))[0]
              t0 = unpack("<d", f.read(8))[0]
              t1 = unpack("<d", f.read(8))[0]
              t2 = unpack("<d", f.read(8))[0]
              camera_id = unpack("<I", f.read(4))[0]
              filename = ""
              while True:
                  c = f.read(1).decode()
                  if c == "\0":
                      break
                  filename += c
              q = np.array([q0, q1, q2, q3])
              q /= np.linalg.norm(q)
              t = np.array([t0, t1, t2])
  
              pose = pygeometry.Pose(rotation=quaternion_to_angle_axis(q), translation=t)
              shot = rec.create_shot(filename, str(camera_id), pose)
              image_ix_to_shot_id[image_ix] = shot.id
  
              n_points_2d = unpack("<Q", f.read(8))[0]
              for point2d_ix in range(n_points_2d):
                  x = unpack("<d", f.read(8))[0]
                  y = unpack("<d", f.read(8))[0]
                  point3d_id = unpack("<Q", f.read(8))[0]
                  if point3d_id != np.iinfo(np.uint64).max:
                      kp = keypoints[image_id][point2d_ix]
                      r, g, b = rec.points[str(point3d_id)].color
                      obs = pymap.Observation(
                          x,
                          y,
                          kp[2],
                          int(r),
                          int(g),
                          int(b),
                          point2d_ix,
                      )
                      tracks_manager.add_observation(shot.id, str(point3d_id), obs)
  
      return tracks_manager, image_ix_to_shot_id
function_tokens: def import_images_reconstruction ( path_images , keypoints , rec ) : logger . info ( "Importing images from {}" . format ( path_images ) ) tracks_manager = pymap . TracksManager ( ) image_ix_to_shot_id = { } with open ( path_images , "rb" ) as f : n_ims = unpack ( "<Q" , f . read ( 8 ) ) [ 0 ] for image_ix in range ( n_ims ) : image_id = unpack ( "<I" , f . read ( 4 ) ) [ 0 ] q0 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] q1 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] q2 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] q3 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] t0 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] t1 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] t2 = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] camera_id = unpack ( "<I" , f . read ( 4 ) ) [ 0 ] filename = "" while True : c = f . read ( 1 ) . decode ( ) if c == "\0" : break filename += c q = np . array ( [ q0 , q1 , q2 , q3 ] ) q /= np . linalg . norm ( q ) t = np . array ( [ t0 , t1 , t2 ] ) pose = pygeometry . Pose ( rotation = quaternion_to_angle_axis ( q ) , translation = t ) shot = rec . create_shot ( filename , str ( camera_id ) , pose ) image_ix_to_shot_id [ image_ix ] = shot . id n_points_2d = unpack ( "<Q" , f . read ( 8 ) ) [ 0 ] for point2d_ix in range ( n_points_2d ) : x = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] y = unpack ( "<d" , f . read ( 8 ) ) [ 0 ] point3d_id = unpack ( "<Q" , f . read ( 8 ) ) [ 0 ] if point3d_id != np . iinfo ( np . uint64 ) . max : kp = keypoints [ image_id ] [ point2d_ix ] r , g , b = rec . points [ str ( point3d_id ) ] . color obs = pymap . Observation ( x , y , kp [ 2 ] , int ( r ) , int ( g ) , int ( b ) , point2d_ix , ) tracks_manager . add_observation ( shot . id , str ( point3d_id ) , obs ) return tracks_manager , image_ix_to_shot_id