-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.py
59 lines (36 loc) · 1.37 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from sklearn.cluster import KMeans
import random as rng
import cv2
import imutils
import argparse
from imutils import contours
from skimage.io import imread
import numpy as np
import matplotlib.pyplot as plt
import os
from utils import *
ImgPath = 'data/barefeet1.jpeg'
def main():
oimg = imread(ImgPath)
if not os.path.exists('output'):
os.makedirs('output')
preprocessedOimg = preprocess(oimg)
cv2.imwrite('output/preprocessedOimg.jpg', preprocessedOimg)
clusteredImg = kMeans_cluster(preprocessedOimg)
cv2.imwrite('output/clusteredImg.jpg', clusteredImg)
edgedImg = edgeDetection(clusteredImg)
cv2.imwrite('output/edgedImg.jpg', edgedImg)
boundRect, contours, contours_poly, img = getBoundingBox(edgedImg)
pdraw = drawCnt(boundRect[1], contours, contours_poly, img)
cv2.imwrite('output/pdraw.jpg', pdraw)
croppedImg, pcropedImg = cropOrig(boundRect[1], clusteredImg)
cv2.imwrite('output/croppedImg.jpg', croppedImg)
newImg = overlayImage(croppedImg, pcropedImg)
cv2.imwrite('output/newImg.jpg', newImg)
fedged = edgeDetection(newImg)
fboundRect, fcnt, fcntpoly, fimg = getBoundingBox(fedged)
fdraw = drawCnt(fboundRect[2], fcnt, fcntpoly, fimg)
cv2.imwrite('output/fdraw.jpg', fdraw)
print("feet size (cm): ", calcFeetSize(pcropedImg, fboundRect)/10)
if __name__ == '__main__':
main()