python - 部署在服务器 Django/Python 上时相机未打开
问题描述
无法在服务器上打开相机,其中相同的副本具有相同的设置
cam = cv2.VideoCapture(0)
使用它来初始化相机(网络摄像头)和下面的代码来处理数据流,下图显示服务器上的错误单击此处查看错误
def identify_faces(video_capture):
buf_length = 10
known_conf = 6
buf = [[]] * buf_length
i = 0
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_frame = small_frame[:, :, ::-1]
if process_this_frame:
predictions = predict(rgb_frame, model_path="folder/folder/models/trainedmodel.clf")
process_this_frame = not process_this_frame
face_names = []
for name, (top, right, bottom, left) in predictions:
top *= 4
right *= 4
bottom *= 4
left *= 4
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
identify1(frame, name, buf, buf_length, known_conf)
face_names.append(name)
buf[i] = face_names
i = (i + 1) % buf_length
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
cv2.destroyAllWindows()
解决方案
推荐阅读
- python - 使用 chromedriver 从 Selenium 打印 PDF
- javascript - 如何解决模拟函数中的 Promise?
- java - 响应不是来自使用改造 2 的服务器
- c# - 如何通过将文件从 HttpPostedFileBase 复制到 MemoryStream 来将文件附加到电子邮件?
- owasp - 使用授权标头扫描 API
- sql - 在 case 语句中计算 % 不能正常工作
- python - 将数学应用于熊猫中行具有相同值的列
- autodesk-forge - 如何显示与文件中所有问题相对应的问题 ID?
- javascript - 简化 Javascript 中的 if 语句
- javascript - 跟踪脚本的返回值