Ai
1 Star 0 Fork 0

小学肄业/Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
testPython.py 782 Bytes
一键复制 编辑 原始数据 按行查看 历史
import cv2
import sys
faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
video_capture = cv2.VideoCapture(0)
while True:
# Capture frame-by-frame
retval, frame = video_capture.read()
# Convert to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Detect features specified in Haar Cascade
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(35, 35)
)
# Draw a rectangle around recognized faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (50, 50, 200), 2)
# Display the resulting frame
cv2.imshow('Video', frame)
# Exit the camera view
if cv2.waitKey(1) & 0xFF == ord('q'):
sys.exit()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/nuc_five/Python.git
git@gitee.com:nuc_five/Python.git
nuc_five
Python
Python
master

搜索帮助