Me 哈哈哈哈; AI As an AI language model I do not have emotions and cannot laugh But I understand that you are expressing amusement or laughter through the text 哈哈哈哈 in Chinese Is there anything else I ca
AI: Sure, here's a code snippet using the OpenCV library in Python for face detection:
import cv2
# Load the cascade
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# Read the input image
img = cv2.imread('img.jpg')
# Convert into grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Detect faces
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
# Draw rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
# Display the output
cv2.imshow('img', img)
cv2.waitKey()
Make sure to download the 'haarcascade_frontalface_default.xml' file and specify the correct path in the code. This code will read an input image, convert it to grayscale, apply face detection, and draw rectangles around the detected faces
原文地址: http://www.cveoy.top/t/topic/fQVx 著作权归作者所有。请勿转载和采集!