Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhaodan2000
face_recognition
提交
1e202e6f
F
face_recognition
项目概览
zhaodan2000
/
face_recognition
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
face_recognition
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1e202e6f
编写于
1月 05, 2018
作者:
A
Adam Geitgey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an example of automatically blurring faces in images or videos
上级
e924ab22
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
0 deletion
+52
-0
examples/blur_faces_on_webcam.py
examples/blur_faces_on_webcam.py
+52
-0
未找到文件。
examples/blur_faces_on_webcam.py
0 → 100644
浏览文件 @
1e202e6f
import
face_recognition
import
cv2
# This is a demo of blurring faces in video.
# PLEASE NOTE: This example requires OpenCV (the `cv2` library) to be installed only to read from your webcam.
# OpenCV is *not* required to use the face_recognition library. It's only required if you want to run this
# specific demo. If you have trouble installing it, try any of the other demos that don't require it instead.
# Get a reference to webcam #0 (the default one)
video_capture
=
cv2
.
VideoCapture
(
0
)
# Initialize some variables
face_locations
=
[]
while
True
:
# Grab a single frame of video
ret
,
frame
=
video_capture
.
read
()
# Resize frame of video to 1/4 size for faster face detection processing
small_frame
=
cv2
.
resize
(
frame
,
(
0
,
0
),
fx
=
0.25
,
fy
=
0.25
)
# Find all the faces and face encodings in the current frame of video
face_locations
=
face_recognition
.
face_locations
(
small_frame
,
model
=
"cnn"
)
# Display the results
for
top
,
right
,
bottom
,
left
in
face_locations
:
# Scale back up face locations since the frame we detected in was scaled to 1/4 size
top
*=
4
right
*=
4
bottom
*=
4
left
*=
4
# Extract the region of the image that contains the face
face_image
=
frame
[
top
:
bottom
,
left
:
right
]
# Blur the face image
face_image
=
cv2
.
GaussianBlur
(
face_image
,
(
99
,
99
),
30
)
# Put the blurred face region back into the frame image
frame
[
top
:
bottom
,
left
:
right
]
=
face_image
# Display the resulting image
cv2
.
imshow
(
'Video'
,
frame
)
# Hit 'q' on the keyboard to quit!
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
'q'
):
break
# Release handle to the webcam
video_capture
.
release
()
cv2
.
destroyAllWindows
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录