-
-
Save BedirYilmaz/a3652ef7708cfd9efd9904c68c2b7c14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## Assignment 2-3 Closest person to each person in each image | |
########## - Calculate the Euclidean Distance between every pair in every annotation | |
########## - Match everyone with their closet | |
########## 10/04/2018 | |
########## Nithikan Srinakrung - Bam | |
########## DF4, FTSM, UKM | |
import os,sys | |
import scipy.io as sio | |
import numpy as np | |
from scipy.spatial import distance | |
foldername = '.' | |
filtername = 'mat' | |
foldercontents = os.listdir(foldername) | |
filteredcontents = [i for i in foldercontents if i.split('.')[-1] == filtername] | |
minDis = [] | |
for i in filteredcontents: | |
filename = "D:/Coop/UCF_CC_50/" + str(i) | |
data = sio.loadmat(filename) | |
print(filename) | |
for i in range(len(data["annPoints"])): | |
#print (str(i) + " x " + str(j[0]) + " y " + str(j[1])) | |
j = data["annPoints"][i] | |
distances = [] | |
jRepmat = np.zeros(annPoints.shape) | |
jRepmat[:,0] = j[0] | |
jRepmat[:,1] = j[1] | |
distances = (jRepmat - data["annPoints"])**2 | |
distances = np.sum(distances, axis =1) | |
distances = np.sqrt(distances) | |
#print("closest to " + str(i) + " is "+ str(np.argsort(distances)[1])) | |
#print("closest to " + str(j) + " is "+ str(data["annPoints"][np.argsort(distances)[1]])) | |
print ("**********************-------------end of file--------------**************") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment