Esempio n. 1
0
def GetPointData(info):
    reconstruction = Info.ReadReconstructionData(info)['shots']
    reconstruction_data = []
    latlon_data = []
    frame_lst = []
    f = open(Info.GetMatchLstFileName(info), 'r')
    for line in f:
        line = line[0:-1].split('\t')
        frame_name = line[0]
        pano_name = line[1]
        try:
            [x, y, z] = optical_center(reconstruction[frame_name])
        except:
            continue
        lat = float(line[2])
        lon = float(line[3])
        frame_lst.append(line[0])
        reconstruction_data.append([x, y])
        latlon_data.append([lat, lon])
    f.close()
    reconstruction_data = np.array(reconstruction_data, dtype=np.float32)
    latlon_data = np.array(latlon_data, dtype=np.float32)

    #plt.figure()
    #plt.subplot('111')
    #plt.plot(reconstruction_data[:,0], reconstruction_data[:,1], 'o')
    #plt.show()

    return [frame_lst, reconstruction_data, latlon_data]
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()