我尝试用Golang重新制作Python ver Mask检测器,但我在使用GoCV时遇到了“提取置信度”的问题,python代码是这样说的
detections = net.forward()
# loop over the detections
for i in range(0, detections.shape[2]):
# extract the confidence (i.e., probability) associated with
# the detection
confidence = detections[0, 0, i, 2]它在python上工作得很好,但是我怎么才能用GoCV获得置信度呢?
这是我目前的工作
currPath := "/media/fz/Project (Running)/Unknown/TryDetectMask/face_detector"
prototxtPath := path.Join(currPath, "deploy.prototxt")
weightsPath := path.Join(currPath, "res10_300x300_ssd_iter_140000.caffemodel")
//definedConfidence := 0.5
//modelPath := "mask_detector.model"
net := gocv.ReadNet(prototxtPath, weightsPath)
//model, _ := tf.LoadSavedModel(modelPath, []string{"serve"}, nil)
img := gocv.IMRead("/home/fz/Desktop/download.jpeg", gocv.IMReadUnchanged)
//orig := img.CopyTo
//imgSize := img.Size()
img.ConvertTo(&img, gocv.MatTypeCV32F)
imgBlob := gocv.BlobFromImage(img, 1.0, image.Point{X: 300, Y: 300}, gocv.NewScalar(104.0, 177.0, 123.0, 0), false, false)
net.SetInput(imgBlob, "")
detections := net.Forward("")
//a, _ := detections.FromPtr(1,1,gocv.MatTypeCV32F,1,2)
fmt.Printf("%v", detections.Total())
//detectionsMat := detections.Reshape(1,1)
//_, maxVal, _, maxLoc := gocv.MinMaxLoc(detectionsMat)
//
//fmt.Println(maxVal)
//fmt.Println(maxLoc.X)发布于 2020-08-28 16:11:20
我使用下面这行代码成功地做到了这一点
detections := net.Forward("")
for i := 0; i < detections.Total(); i += 7 {
confidence := detections.GetFloatAt(0, i+2)https://stackoverflow.com/questions/63625408
复制相似问题