Exemplo n.º 1
0
  def map_tags_hybrid3(self, pixelmap, C):
    tags = self.map_tags_camera()
    accepted = []
    outside = []
    bad = []
    obs = self.source.get_loc_dict()
    for (tag, (_, pixel)) in tags:
      location = geom.picknearestll(pixelmap, tag)
      error = tag.xydistance(location)
      if error < 2.0:
        accepted.append((tag, (_, pixel)))
      elif error < 15.0 or not geom.contains(pixel, self.image.size):
        outside.append((tag, (_, pixel)))
      else:
        bad.append((tag, (999, pixel)))

    cell = util.getclosestcell(self.lat, self.lon, C.dbdir)[0]
    cellpath = os.path.join(C.dbdir, cell)
    pm = reader.get_reader(C.params['descriptor'])\
      .load_PointToViewsMap(cellpath, C.infodir)

    for (tag, (_, pixel)) in outside:
      vis, t = pm.hasView(C, tag.lat, tag.lon,\
        self.lat, self.lon, self.yaw, 25)
      emv = tag.emIsVisible(self.source, C, 25)
      if (vis or emv):
        if geom.norm_compatible(tag, self):
          accepted.append((tag, (_, pixel)))
        else:
          bad.append((tag, (12, pixel)))
      else:
        bad.append((tag, (15, pixel)))
    return accepted, bad
def get_num_imgs_in_range(range, celldir, querydir='/home/zhangz/.gvfs/data on 128.32.43.40/query3/'):
    queries = util.getSURFFileNames(querydir)
    total_in_range=0
    for querysurf in queries:
        lat, lon = info.getQuerySURFCoord(querysurf)
        cell, dist = util.getclosestcell(lat, lon, celldir)
        numinrange = util.getNumJPGInRange(lat, lon, os.path.join(celldir,cell), range)
        total_in_range+=numinrange
    print "average # of imgs within {0} meters of query: {1}".format(range, float(total_in_range)/len(queries))
Exemplo n.º 3
0
def get_num_imgs_in_range(
        range,
        celldir,
        querydir='/home/zhangz/.gvfs/data on 128.32.43.40/query3/'):
    queries = util.getSURFFileNames(querydir)
    total_in_range = 0
    for querysurf in queries:
        lat, lon = info.getQuerySURFCoord(querysurf)
        cell, dist = util.getclosestcell(lat, lon, celldir)
        numinrange = util.getNumJPGInRange(lat, lon,
                                           os.path.join(celldir, cell), range)
        total_in_range += numinrange
    print "average # of imgs within {0} meters of query: {1}".format(
        range,
        float(total_in_range) / len(queries))
Exemplo n.º 4
0
  def map_tags_lookup(self, C):
    tags = self.map_tags_camera()
    cell = util.getclosestcell(self.lat, self.lon, C.dbdir)[0]
    cellpath = os.path.join(C.dbdir, cell)

    pm = reader.get_reader(C.params['descriptor'])\
      .load_PointToViewsMap(cellpath, C.infodir)

    accepted, bad = [], []

    for (tag, (_, pixel)) in tags:
      vis, t = pm.hasView(C, tag.lat, tag.lon, self.lat, self.lon, self.yaw, 20)
      if vis:
        accepted.append((tag, (_, pixel)))
      else:
        bad.append((tag, (999, pixel)))
    return accepted + bad
Exemplo n.º 5
0
  def map_tags_hybrid2(self, pixelmap, C):
    """Tags are filtered by using the image's pt cloud
       when source tag is visible in the db image. Otherwise,
       a combination of earthmine occlusion queries and
       database occlusion queries are performed."""
    tags = self.map_tags_camera(self.lat, self.lon)
    accepted = []
    outside = []
    bad = []
    THRESHOLD = 15
    outside = tags # XXX
#    for (tag, (_, pixel)) in tags:
#      location = pixelmap[geom.picknearest(pixelmap, *pixel)]
#      if location is None:
#        if not geom.contains(pixel, self.image.size):
#          outside.append((tag, (_, pixel)))
#        else:
#          bad.append((tag, (999, pixel)))
#      else:
#        dist = tag.xydistance(location)
#        if dist < THRESHOLD:
#          accepted.append((tag, (_, pixel)))
#        elif not geom.contains(pixel, self.image.size):
#          outside.append((tag, (_, pixel)))
#        else:
#          bad.append((tag, (999, pixel)))

    cell = util.getclosestcell(self.lat, self.lon, C.dbdir)[0]
    cellpath = os.path.join(C.dbdir, cell)
    pm = reader.get_reader(C.params['descriptor'])\
      .load_PointToViewsMap(cellpath, C.infodir)

    for (tag, (_, pixel)) in outside:
      vis, t = pm.hasView(C, tag.lat, tag.lon, self.lat, self.lon, self.yaw, 30)
      emv = tag.emIsVisible(self.source, C, 30)
      if (vis or emv):
        if geom.norm_compatible(tag, self):
          accepted.append((tag, (_, pixel)))
        else:
          bad.append((tag, (12, pixel)))
      else:
        bad.append((tag, (17, pixel)))

    return accepted + bad
Exemplo n.º 6
0
  def map_tags_hybrid(self, pixelmap, C, elat, elon):
    """Uses tag projection from estimated lat, lon.
       Tags are filtered by using the image's pt cloud
       when source tag is visible in the db image. Otherwise,
       3d occlusion detection is performed."""
    THRESHOLD = 15.0 # meters
    tags = self.map_tags_camera(elat, elon)
    accepted = []
    outside = []
    bad = []
    for (tag, (_, pixel)) in tags:
      location = pixelmap[geom.picknearest(pixelmap, *pixel)]
      if location is None:
        if not geom.contains(pixel, self.image.size):
          outside.append((tag, (_, pixel)))
        else:
          bad.append((tag, (999, pixel)))
      else:
        dist = tag.xydistance(location)
        if dist < THRESHOLD:
          accepted.append((tag, (_, pixel)))
        elif not geom.contains(pixel, self.image.size):
          outside.append((tag, (_, pixel)))
        else:
          bad.append((tag, (999, pixel)))

    # use ocs method for tags outside db image
    cell = util.getclosestcell(self.lat, self.lon, C.dbdir)[0]
    cellpath = os.path.join(C.dbdir, cell)
    tree3d = reader.get_reader(C.params['descriptor']).load_tree3d(cellpath, C)
    for (tag, (d, pixel)) in outside:
#      if tag.isVisible2(self.source, tree3d, elat, elon):
#        accepted.append((tag, (_, pixel)))
#      else:
#        bad.append((tag, (15, pixel)))
        accepted.append((tag, (d, pixel)))

    return accepted + bad