def get_num_imgs_in_range(range, celldir, querydir='/home/zhangz/.gvfs/data on 128.32.43.40/query3/'): queries = util.getSiftFileNames(querydir) total_in_range=0 for querysift in queries: lat, lon = info.getQuerySIFTCoord(querysift) 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))
def iter1(): for file in util.getSiftFileNames(self.querydir): image = _Query() image.siftpath = os.path.join(self.querydir, file) #TODO: this uses a hard coded dimension image.pgm_scale = max(Image.open(os.path.join(self.querydir, image.siftname[:-8] + '.pgm')).size) / max(2592.0, 1456.0) image.jpgpath = os.path.join(self.querydir, image.siftname[:-8] + '.jpg') image.setSensorCoord(0,0) image.check() yield image
def iter2(): for file in util.getSiftFileNames(self.querydir): image = _Query() if self.QUERY == 'query2': image.pgm_scale = 512/2592.0 image.siftpath = os.path.join(self.querydir, file) image.jpgpath = os.path.join(self.querydir, image.siftname[:-8] + '.JPG') image.setSensorCoord(*info.add_error(info.getQuerySIFTCoord(file), self.added_error)) if self.QUERY != 'query4-matlab': image.check() yield image
def characterizeFuzzy(querydir, dbdir, mainOutputDir, n, copytopmatch): start = time.time() if not os.path.exists(mainOutputDir): os.makedirs(mainOutputDir) if copytopmatch: if os.path.exists(resultsdir): shutil.rmtree(resultsdir) os.makedirs(resultsdir) files = util.getSiftFileNames(querydir) g_count = 0 y_count = 0 r_count = 0 b_count = 0 o_count = 0 count = 0 for queryfile in files: for newlat, newlon in skew_location(queryfile, ambiguity): closest_cells = util.getclosestcells(newlat, newlon, dbdir) count += 1 [g, y, r, b, o] = query2(querydir, queryfile, dbdir, mainOutputDir, n, copytopmatch, closest_cells, copy_top_n_percell=5) if g: g_count += 1 if verbosity > 0: print "G match-g:{0} y:{1} r:{2} b:{3} o:{4} out of {5}".format(g_count, y_count, r_count, b_count, o_count, count) elif y: y_count += 1 if verbosity > 0: print "Y match-g:{0} y:{1} r:{2} b:{3} o:{4} out of {5}".format(g_count, y_count, r_count, b_count, o_count, count) elif r: r_count += 1 if verbosity > 0: print "R match-g:{0} y:{1} r:{2} b:{3} o:{4} out of {5}".format(g_count, y_count, r_count, b_count, o_count, count) elif b: b_count += 1 if verbosity > 0: print "B match-g:{0} y:{1} r:{2} b:{3} o:{4} out of {5}".format(g_count, y_count, r_count, b_count, o_count, count) elif o: o_count += 1 if verbosity > 0: print "O match-g:{0} y:{1} r:{2} b:{3} o:{4} out of {5}".format(g_count, y_count, r_count, b_count, o_count, count) else: if verbosity > 0: print "No match-g:{0} y:{1} r:{2} b:{3} o:{4} out of {5}".format(g_count, y_count, r_count, b_count, o_count, count) end = time.time() elapsed = end - start if verbosity > 0: print "total time:{0}, avg time:{1}".format(elapsed, elapsed / count) total_count = g_count + y_count + r_count + b_count + o_count match_rate = float(total_count) / count print "g:{0} y:{1} r:{2} b:{3} o:{4} = {5}, out of {6}={7}".format(g_count, y_count, r_count, b_count, o_count, total_count, count, match_rate)