r2021b_windows.zip
时间: 2023-05-10 22:02:23 浏览: 130
r2021b_windows.zip是一个MATLAB软件的压缩包,这款软件是由MathWorks公司开发的一款数学计算软件,并广泛应用于科学、工程、金融和数据分析等领域。
r2021b_windows.zip包含了MATLAB软件在Windows系统下的安装文件。这个压缩包中有很多文件,包括MATLAB的安装文件和其他必要的组件。如果想要更好地使用MATLAB软件,必须要安装这些组件。安装后,用户可以使用MATLAB进行各种数学计算、数据分析、图像处理、信号处理、控制系统设计和仿真等工作。
与其他数学软件相比,MATLAB具有专业的算法库和优秀的可视化工具,用户可以方便地进行数据可视化和结果展示。MATLAB还支持多种编程语言,例如MATLAB代码、C语言、Java和Python等,用户可以使用不同的编程语言编写自己的程序。
总而言之,r2021b_windows.zip是MATLAB软件在Windows系统下的安装包,包含了MATLAB安装所需要的所有组件。MATLAB是一款功能强大、易于使用的数学计算软件,广泛应用于科学、工程、金融和数据分析等领域,是许多领域内专家学者和工程师的必备工具。
相关问题
import cv2 import face_recognition import numpy as np from PIL import Image, ImageDraw,ImageFont video_capture = cv2.VideoCapture(r'C:/Users/ALIENWARE/123.mp4')#如果输入是(0)为摄像头输入 #现输入为MP4进行识别检测人脸 first_image = face_recognition.load_image_file("1.jpg") first_face_encoding = face_recognition.face_encodings(first_image)[0] Second_image = face_recognition.load_image_file("2.jpg") Second_face_encoding = face_recognition.face_encodings(Second_image)[0] third_image = face_recognition.load_image_file("3.jpg") third_face_encoding = face_recognition.face_encodings(third_image)[0] inside_face_encodings = [first_face_encoding,Second_face_encoding,third_face_encoding] inside_face_names = ['A','B','C'] face_locations = [] face_encodings = [] face_names = [] process_this_frame = True while True: ret, frame = video_capture.read() small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) rgb_small_frame = small_frame[:, :, ::-1] if process_this_frame: face_locations = face_recognition.face_locations(rgb_small_frame) face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations) face_names = [] for face_encoding in face_encodings: matches = face_recognition.compare_faces(inside_face_encodings, face_encoding) name = '未录入人脸' if True in matches: first_match_index = matches.index(True) name = inside_face_names[first_match_index] face_names.append(name) process_this_frame = not process_this_frame for (top, right, bottom, left), name in zip(face_locations, face_names): top *= 4 right *= 4 bottom *= 4 left *= 4 cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) img_pil = Image.fromarray(frame) draw = ImageDraw.Draw(img_pil) fontStyle = ImageFont.truetype("C:/Windows/Fonts/simsun.ttc", 32, encoding="utf-8") draw.text((left + 6, bottom - 6), name, (0, 200, 0), font=fontStyle) frame = np.asarray(np.array(img_pil)) cv2.imshow('face_out', frame) if cv2.waitKey(1) & 0xFF == ord('q'): #退出需要按下Q键否则内核会崩溃 break video_capture.release() cv2.destroyAllWindows()
以下是修改后的代码,主要是添加了注释和一些规范化的修改:
```python
import cv2
import face_recognition
import numpy as np
from PIL import Image, ImageDraw, ImageFont
# 加载要识别的人脸图片
first_image = face_recognition.load_image_file("1.jpg")
first_face_encoding = face_recognition.face_encodings(first_image)[0]
Second_image = face_recognition.load_image_file("2.jpg")
Second_face_encoding = face_recognition.face_encodings(Second_image)[0]
third_image = face_recognition.load_image_file("3.jpg")
third_face_encoding = face_recognition.face_encodings(third_image)[0]
# 存储要检测的人脸编码及对应的人名
inside_face_encodings = [first_face_encoding, Second_face_encoding, third_face_encoding]
inside_face_names = ['A', 'B', 'C']
# 打开视频流
video_capture = cv2.VideoCapture(r'C:/Users/ALIENWARE/123.mp4')
# 循环读取视频帧
while True:
# 读取一帧
ret, frame = video_capture.read()
# 降低帧率,加快处理速度
if not ret:
break
# 缩小图片尺寸,加快处理速度
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
rgb_small_frame = small_frame[:, :, ::-1]
# 处理每一帧图片
face_locations = face_recognition.face_locations(rgb_small_frame)
face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
face_names = []
# 遍历每个检测到的人脸
for face_encoding in face_encodings:
# 比对人脸编码
matches = face_recognition.compare_faces(inside_face_encodings, face_encoding)
name = '未录入人脸'
# 找到匹配的人脸
if True in matches:
first_match_index = matches.index(True)
name = inside_face_names[first_match_index]
face_names.append(name)
# 在画面上标记人脸及名字
for (top, right, bottom, left), name in zip(face_locations, face_names):
# 将坐标放大4倍,因为之前缩小了4倍
top *= 4
right *= 4
bottom *= 4
left *= 4
# 画出人脸框
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
# 添加名字
img_pil = Image.fromarray(frame)
draw = ImageDraw.Draw(img_pil)
fontStyle = ImageFont.truetype("C:/Windows/Fonts/simsun.ttc", 32, encoding="utf-8")
draw.text((left + 6, bottom - 6), name, (0, 200, 0), font=fontStyle)
frame = np.asarray(np.array(img_pil))
# 显示画面
cv2.imshow('face_out', frame)
# 按下q键退出程序
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# 释放视频流
video_capture.release()
# 关闭所有窗口
cv2.destroyAllWindows()
```
阅读全文