opencv - 尝试使用 OpenCv 的内置人脸检测器检测人脸
问题描述
使用 OpenCV 内置的人脸检测器进行人脸检测。
星号之间的代码是什么意思?
这里使用的是 caffe 模型。
# loop over the detections
for i in range(0, **detections.shape[2]**):
# extract the confidence (i.e., probability) associated with the
# prediction
confidence = **detections[0, 0, i, 2]**
# filter out weak detections by ensuring the `confidence` is
# greater than the minimum confidence
if confidence > args["confidence"]:
# compute the (x, y)-coordinates of the bounding box for the
# object
**box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")**
# draw the bounding box of the face along with the associated
# probability
text = "{:.2f}%".format(confidence * 100)
**y = startY - 10 if startY - 10 > 10 else startY + 10
cv2.rectangle(image, (startX, startY), (endX, endY),
(0, 0, 255), 2)**
cv2.putText(image, text, (startX, y),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2)
# show the output image
cv2.imshow("Output", image)
cv2.waitKey(0)
解决方案
推荐阅读
- facebook - 是否可以使用过期令牌获得扩展的 facebook accessToken?
- angular - 来自 Protractor e2e 测试的 Ag-grid 访问和编辑单元格
- c# - 文本文件到数组到 Excel 导出数据文本更改
- c - 从选项 1 返回多个输出,如何将其存储在主函数中并将其用于选项 3
- java - log4j2中哪个方法实际执行翻转
- amazon-web-services - Amazon EC2 pricing for blocked IP addresses
- javascript - calculation of increment value in react js
- r - 字体未在 showtext font_add_google 中加载
- minecraft - CustomInventory on click wont work bukkit
- ios - How to pick multiple videos as well as photos from gallery using Swift