コード例 #1
0
ファイル: corr.py プロジェクト: jasonzliang/image_retreival
    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
コード例 #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
コード例 #3
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