Skip to content

Instantly share code, notes, and snippets.

@nithikan
Created April 4, 2018 09:23
Show Gist options
  • Save nithikan/1c7e77b62ee54f90f30c169df61a1e16 to your computer and use it in GitHub Desktop.
Save nithikan/1c7e77b62ee54f90f30c169df61a1e16 to your computer and use it in GitHub Desktop.
##### Assignment 2-2 Center point of the crowd in each image
##### -> Accumulate x and y positions and divide by person count
##### 04/04/2018
##### Nithikan Srinakrung - Bam
##### DF4, FTSM, UKM
import os,sys
import scipy.io as sio
import numpy as np
foldername = '.'
filtername = 'mat'
foldercontents = os.listdir(foldername)
filteredcontents = [i for i in foldercontents if i.split('.')[-1] == filtername]
#print(filteredcontents)
for i in filteredcontents:
filename = "D:/Coop/UCF_CC_50/" + str(i)
data = sio.loadmat(filename)
xPoint = []
yPoint = []
for j in data["annPoints"]:
print (str(i) + " x " + str(j[0]) + " y " + str(j[1]))
xPoint.append(j[0])
yPoint.append(j[1])
sumX = np.sum(xPoint)
sumY = np.sum(yPoint)
print('********************************** center coordinates x: ' + str(sumX / len(xPoint)) + " y " + str(sumY / len(yPoint)) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment