首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在GoCV中提取信心

如何在GoCV中提取信心
EN

Stack Overflow用户
提问于 2020-08-28 07:24:22
回答 1查看 61关注 0票数 0

我尝试用Golang重新制作Python ver Mask检测器,但我在使用GoCV时遇到了“提取置信度”的问题,python代码是这样说的

代码语言:javascript
复制
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获得置信度呢?

这是我目前的工作

代码语言:javascript
复制
    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)
EN

回答 1

Stack Overflow用户

发布于 2020-08-28 16:11:20

我使用下面这行代码成功地做到了这一点

代码语言:javascript
复制
detections := net.Forward("")

for i := 0; i < detections.Total(); i += 7 {
    confidence := detections.GetFloatAt(0, i+2)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63625408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档