在绘制边界框后找到检测到的对象的最低点

时间:2019-07-10 15:42:58

标签: python opencv object-detection bounding-box yolo

我训练了一个深度学习模型来检测圆,现在我绘制了矩形的边界框。这部分代码可以做到这一点。我正在使用python和opencv的组合。

> #initializing the lists detected bounding boxes, and class IDs, confidences respectively
    boxes = []
    classIDs = []
    confidences = []


#  for loop for each of the layer outputs
    for out in raw_out_put:
# for loop for each of the detections
        for detection in out:

            # here we get the class ID and probability of the detected object inside the loop
            scores = detection[5:]
            classID = np.argmax(scores)
            confidence = scores[classID]


# here we remove weak predictions by ensuring the detected probability is bigger than our threshold

            if confidence > threshold_confidence:

# Here the bounding box coordinates are scaled back to the size of the image.
# having said that, YOLO  returns the center-coordinates of the bounding box which is x, y  and  boxes' width and height

                X = int(detection[0] * fWidth)
                Y = int(detection[1] * fHeight)
                width = int(detection[2] * fWidth)
                height = int(detection[3] * fHeight)

#here by using x and y which is center coordinates, we calculate the top and left corner of the bounding box.

                left = int(X - width / 2)
                top = int(Y - height / 2)

# Then we update bounding box coordinates, confidences score, and class labels
                classIDs.append(classID)
                confidences.append(float(confidence))
                boxes.append([left, top, width, height])

我的问题是,通过知道该圆的中心点(YOLO给出了边界框的中心点),我该如何以找到最低点的方式进行编码? 说了我的图片中有多个圆圈,我需要找到所有圆圈的最低点。这一点将是圆的最低(向下)部分。图片可以说明我的需求。请查看以下链接。

https://imgur.com/IePRSq6

0 个答案:

没有答案