Modification of the photo + ROI

This commit is contained in:
Alexandre VEROT 2023-02-08 22:28:23 +01:00
parent 741b3138f7
commit fb7884e217
2 changed files with 3 additions and 3 deletions

BIN
PhotoTest.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View File

@ -8,7 +8,7 @@ face_cascade = cv2.CascadeClassifier("Haar_Cascade.xml")
# Charger l'image dans OpenCV # Charger l'image dans OpenCV
# Convertir l'image en niveaux de gris # Convertir l'image en niveaux de gris
img = cv2.imread("Image.jpg") img = cv2.imread("PhotoTest.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Just to check if there is a photo # Just to check if there is a photo
if gray_img.shape[0] == 0 or gray_img.shape[1] == 0: if gray_img.shape[0] == 0 or gray_img.shape[1] == 0:
@ -19,8 +19,8 @@ face = face_cascade.detectMultiScale(gray_img, scaleFactor=1.1, minNeighbors=5)
print(face) print(face)
# Dessiner un rectangle autour de chaque visage détecté # Dessiner un rectangle autour de chaque visage détecté
for x, y, w, h in face: for x, y, w, h in face:
img = cv2.rectangle(img, (int(x*1.15), int(y*1.1)), img = cv2.rectangle(img, (int(x*1.2), int(y*1.15)),
(x + int(w*0.8), y + int(h*0.5)), (0, 255, 0), 3) (x + int(w*0.7), y + int(h*0.2)), (0, 255, 0), 3)
# Afficher l'image # Afficher l'image
cv2.imshow("Faces", img) cv2.imshow("Faces", img)