def calculatePicture(file):
"""gettings infos of the image and applie the matrixes"""
img = cv2.imread(file)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces, eyes = detect(img, gray)
# print("faces: " + str(faces) + " # eyes:" + str(eyes))
height, width, channels = img.shape
if faces is None or eyes is None:
return None
face = faces[0]
eye = [eyes[0], eyes[1]]
moveMatrix, rotMatrix = matrixPicture(face, eye, height, width)
dst = cv2.warpAffine(img, moveMatrix, (width, height))
dst = cv2.warpAffine(dst, rotMatrix, (width, height))
return dst
评论列表
文章目录