This commit is contained in:
Alexandre VEROT 2023-02-09 08:43:26 +01:00
parent fb7884e217
commit eb92b45567
2 changed files with 19 additions and 2 deletions

View File

@ -40,8 +40,8 @@ for i in range(num_frames):
if len(face) > 0: if len(face) > 0:
x, y, w, h = face[0] x, y, w, h = face[0]
face = frame[y:y+h, x:x+w] face = frame[y:y+h, x:x+w]
frame = cv2.rectangle(frame, (int(x*1.15), y), frame = cv2.rectangle(frame, (int(x*1.15), int(y*1.15)),
(x + int(w*0.7), y + h), (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", frame) # cv2.imshow("Faces", frame)
# cv2.waitKey(0) # cv2.waitKey(0)

View File

@ -6,6 +6,8 @@ import numpy as np
# Charger le classificateur Haar Cascade # Charger le classificateur Haar Cascade
face_cascade = cv2.CascadeClassifier("Haar_Cascade.xml") face_cascade = cv2.CascadeClassifier("Haar_Cascade.xml")
average_rgb = []
# 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("PhotoTest.jpg") img = cv2.imread("PhotoTest.jpg")
@ -25,3 +27,18 @@ for x, y, w, h in face:
# Afficher l'image # Afficher l'image
cv2.imshow("Faces", img) cv2.imshow("Faces", img)
cv2.waitKey(0) cv2.waitKey(0)
b, g, r = cv2.split(img)
cv2.imshow("b", b)
cv2.imshow("g", g)
cv2.imshow("r", r)
cv2.waitKey(0)
# Calculate average on each channel
avg_b = np.mean(b) / 255
avg_g = np.mean(g) / 255
avg_r = np.mean(r) / 255
# Add to list
average_rgb.append([avg_b, avg_g, avg_r])
# frame_matrices.append(face)
print(average_rgb)