【发布时间】:2021-04-15 13:38:58
【问题描述】:
我将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]?
【问题讨论】: