def vehicle_offset(img, left_x, right_x, xm_per_pix):
  """Measures offset of the vehicle from the center of the lane."""
  
  lane_center = (left_x + right_x) / 2
  x_max = img.shape[1]
  vehicle_center = x_max / 2
  return xm_per_pix * (vehicle_center - lane_center)