added crop option

This commit is contained in:
gocivici 2023-10-19 16:24:30 +03:00
parent e14ecd308f
commit f0876c31be
3 changed files with 7 additions and 1 deletions

BIN
cropScared.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -46,8 +46,14 @@ if cam.isOpened():
predictions = DeepFace.analyze(img,actions=['emotion']) predictions = DeepFace.analyze(img,actions=['emotion'])
fearPoint = predictions[0]["emotion"]["fear"] fearPoint = predictions[0]["emotion"]["fear"]
print("FEAR:" + str(fearPoint)) print("FEAR:" + str(fearPoint))
if fearPoint>20: if fearPoint>10:
cv2.imwrite('scared.jpg', img) cv2.imwrite('scared.jpg', img)
basewidth = 384
imgCrop = Image.open('scared.jpg')
wpercent = (basewidth/float(imgCrop.size[0]))
hsize = int((float(imgCrop.size[1])*float(wpercent)))
imgCrop = imgCrop.resize((basewidth,hsize), Image.ANTIALIAS)
imgCrop = imgCrop.save("cropScared.jpg")
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
img = Image.fromarray(img) img = Image.fromarray(img)
draw = ImageDraw.Draw(img) draw = ImageDraw.Draw(img)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 106 KiB