我正在使用cv2.dnn_Net.forward()
(正向传播)进行人脸检测预训练模型。但是,我无法理解如何利用cv2.dnn_Net.forward()
函数返回的变量(下面是detections
变量)
face_net = cv2.dnn.readNet(face_prototxt_path, face_weights_path)
image = cv2.imread(args["image_path"])
(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(image, 1.0, (300, 300),
(104.0, 177.0, 123.0))
face_net.setInput(blob)
detections = face_net.forward() # cv2.dnn_Net.forward() function
# Utilizing 'detections' variable
confidence = detections[0, 0, i, 2]
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
cv2.dnn_Net.forward()
返回的确切内容是什么?如何将它们用作detections[0, 0, i, 2]
和detections[0, 0, i, 3:7]
cv2.dnn.readNet
获取模型的权重文件和配置文件以加载保存的模型net.forward()
-运行前向传递以计算净输出您的检测即
net.forward()
将Numpy ndarray
作为输出,您可以使用它在给定的输入图像上绘制框相关问题 更多 >
编程相关推荐