Exemple #1
0
def Merge(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    f_name = info['match_path'] + '/' + name
    f = open(f_name, 'r')
    data = json.load(f)
    f.close()
    key_lst = sorted(data.keys())
    pano_lst = []
    for key in key_lst:
        loc = data[key]
        print key
        try:
            panoid = GSV.getIDbyloc(lat=loc[0], lon=loc[1])
        except:
            data.pop(key)
            continue
        #print panoid
        if panoid is None:
            data.pop(key)
            continue
        elif not panoid in pano_lst:
            pano_lst.append(panoid)
            try:
                loc = GSV.getLocationbyID(panoid)
                data[key] = [float(loc[0]), float(loc[1])]
            except:
                data.pop(key)
                continue
        else:
            data.pop(key)
    f = open(info['match_path'] + '/google_info.json', 'w')
    f.write(json.dumps(data, indent=4))
    f.close()
def GetResultLst(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    frame_sift_lst = [x for x in sorted(os.listdir(info['frame_sift_path'])) if x.endswith('.sift')]
    pano_sift_lst = [x for x in sorted(os.listdir(info['pano_sift_path'])) if x.endswith('.sift')]
    fisher_result = np.load(Info.GetFisherResultFileName(info))
    match_score = np.load(Info.GetMatchFunMFileName(info))
    #print match_score
    f = open(Info.GetMatchLstFileName(info), 'w')
    for frame_index, frame_sift_name in enumerate(frame_sift_lst):
        arg_sort_index = np.argsort(match_score[frame_index, :])
        highest_index = arg_sort_index[-1]
        highest_score = match_score[frame_index, highest_index]
        second_index = arg_sort_index[-2]
        second_score = match_score[frame_index, second_index]

        ratio = float(highest_score) / float(second_score)
        if highest_score >= THRESHOLD:
            frame_name = frame_sift_name.split('.')[0] + '.jpg'
            pano_sift_name = pano_sift_lst[fisher_result[frame_index, highest_index]]
            pano_name = pano_sift_name.split('.')[0] + '.jpg'
            pano_id = pano_name[5:27]
            print pano_id
            
            loc = GoogleSV.getLocationbyID(pano_id)
            if loc is None:
                continue
            s = '%s\t%s\t%s\t%s\t%d\n'%(frame_name, pano_name, loc[0], loc[1], highest_score)
            f.write(s)
    f.close()
def Label(ID):
    info = Info.GetVideoInfo(ID)
    frame_lst = [x for x in sorted(os.listdir(info['frame_path'])) if x.endswith]
    i = 0
    f = open(Info.GetMatchLstFileName(info), 'w')
    while True:
        f_name = info['frame_path'] + '/' + frame_lst[i]
        command = 'eog %s'%f_name
        subprocess.call(command, shell=True)
        panoid = raw_input('Pano ID : ')
        loc = GSV.getLocationbyID(panoid)
        print loc
        s = '%s\t%s\t%s\t%s\n'%(frame_lst[i], panoid, loc[0], loc[1])
        f.write(s)
        i += 10
        if i >= 125:
            f.close()
            return
    f.close()
def Label(ID):
    info = Info.GetVideoInfo(ID)
    frame_lst = [
        x for x in sorted(os.listdir(info['frame_path'])) if x.endswith
    ]
    i = 0
    f = open(Info.GetMatchLstFileName(info), 'w')
    while True:
        f_name = info['frame_path'] + '/' + frame_lst[i]
        command = 'eog %s' % f_name
        subprocess.call(command, shell=True)
        panoid = raw_input('Pano ID : ')
        loc = GSV.getLocationbyID(panoid)
        print loc
        s = '%s\t%s\t%s\t%s\n' % (frame_lst[i], panoid, loc[0], loc[1])
        f.write(s)
        i += 10
        if i >= 125:
            f.close()
            return
    f.close()
def GetResultLst(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    frame_sift_lst = [
        x for x in sorted(os.listdir(info['frame_sift_path']))
        if x.endswith('.sift')
    ]
    pano_sift_lst = [
        x for x in sorted(os.listdir(info['pano_sift_path']))
        if x.endswith('.sift')
    ]
    fisher_result = np.load(Info.GetFisherResultFileName(info))
    match_score = np.load(Info.GetMatchFunMFileName(info))
    #print match_score
    f = open(Info.GetMatchLstFileName(info), 'w')
    for frame_index, frame_sift_name in enumerate(frame_sift_lst):
        arg_sort_index = np.argsort(match_score[frame_index, :])
        highest_index = arg_sort_index[-1]
        highest_score = match_score[frame_index, highest_index]
        second_index = arg_sort_index[-2]
        second_score = match_score[frame_index, second_index]

        ratio = float(highest_score) / float(second_score)
        if highest_score >= THRESHOLD:
            frame_name = frame_sift_name.split('.')[0] + '.jpg'
            pano_sift_name = pano_sift_lst[fisher_result[frame_index,
                                                         highest_index]]
            pano_name = pano_sift_name.split('.')[0] + '.jpg'
            pano_id = pano_name[5:27]
            print pano_id

            loc = GoogleSV.getLocationbyID(pano_id)
            if loc is None:
                continue
            s = '%s\t%s\t%s\t%s\t%d\n' % (frame_name, pano_name, loc[0],
                                          loc[1], highest_score)
            f.write(s)
    f.close()