Beispiel #1
0
        def euclidean_error_function(arr):
            error = 0.0
            ctr = 0
            buf = []
            cbuf = []
            for m in matches:
                d, q = m['db'], m['query']
                feature = map3d[int(d[0]), int(d[1])]
                if not feature:
                    continue
                ctr += 1
                pz, px = geom.lltom(self.lat + meter * arr[0],
                                    self.lon + meter * arr[1], feature['lat'],
                                    feature['lon'])
                py = feature['alt']  # feature['alt'] - arr[2]
                x, y, z = geom.camera_transform(px, py, pz, self.pitch,
                                                self.yaw, self.roll)
                coord = geom.project2d(x, y, z, self.focal_length)
                pixel = geom.center(coord, self.imsize)
                error += abs(pixel[0] - q[0])
                buf.append((pixel[0], pixel[1]))
                cbuf.append((q[0], q[1]))
#      for i,j in buf:
#        print i,j
#      print
#      for i,j in cbuf:
#        print i,j
            if error < best[0]:
                best[0] = min(error, best[0])
#        print best[0]/ctr
            return error / ctr
Beispiel #2
0
    def euclidean_error_function(arr):
      error = 0.0
      ctr = 0
      buf = []
      cbuf = []
      for m in matches:
        d, q = m['db'], m['query']
        feature = map3d[int(d[0]), int(d[1])]
        if not feature:
          continue
        ctr += 1
        pz, px = geom.lltom(self.lat + meter*arr[0], self.lon + meter*arr[1], feature['lat'], feature['lon'])
        py = feature['alt'] # feature['alt'] - arr[2]
        x, y, z = geom.camera_transform(px, py, pz, self.pitch, self.yaw, self.roll)
        coord = geom.project2d(x, y, z, self.focal_length)
        pixel = geom.center(coord, self.imsize)
        error += abs(pixel[0] - q[0])
        buf.append((pixel[0], pixel[1]))
        cbuf.append((q[0], q[1]))
#      for i,j in buf:
#        print i,j
#      print
#      for i,j in cbuf:
#        print i,j
      if error < best[0]:
        best[0] = min(error, best[0])
#        print best[0]/ctr
      return error/ctr
Beispiel #3
0
 def __init__(self, image):
   self.lat = 0
   self.lon = 0
   self.alt = 0
   self.yaw = 0
   self.roll = 0
   self.viewId = 0
   self.image = Image.open(image)
   self.focal_length = 700 # XXX arbitrary!
   center = geom.center((0,0), self.image.size)
   self.pitch = 0
Beispiel #4
0
  def map_tags_camera(self, elat=0, elon=0, ep=0, ey=0, er=0):
    "Returns (tag, (dist, pixel)) pairs using camera transform."
    if not elat or not elon:
      elat = self.lat
      elon = self.lon
    tags = []
    possible_tags = self.get_frustum()

    for tag in possible_tags:
      pz, px = geom.lltom(elat, elon, tag.lat, tag.lon)
      py = tag.alt - self.alt;
      x, y, z = geom.camera_transform(px, py, pz, self.pitch + ep, self.yaw + ey, self.roll + er)
      coord = geom.project2d(x, y, z, self.source.focal_length)
      pixel = geom.center(coord, self.image.size)
#      tags.append((tag, (0, geom.constrain(pixel, self.image.size))))
      tags.append((tag, (0, pixel)))

    return tags
Beispiel #5
0
  def __init__(self, image, infofile):
    with open(infofile) as f:
      self.info = eval(f.read())
    self.lat = self.info['view-location']['lat']
    self.lon = self.info['view-location']['lon']
    self.alt = self.info['view-location']['alt']
    self.yaw = self.info['view-direction']['yaw']
    self.pitch = self.info['view-direction']['pitch']
    self.roll = 0
    self.fov = self.info['field-of-view']*np.pi/180
    self.viewId = self.info['id']
    self.image = Image.open(image) if image else None
    if not self.image:
      return
    self.focal_length = 0.8625 * self.image.size[0]
    center = geom.center((0,0), self.image.size)
#    try:
#      cloc = self.get_pixel_location(center)
#    except Exception, e:
#      print e
#      cloc = None
#    if not cloc:
    self.pitch = 0