【问题标题】:how to check if there is a boundng box using tensorflow object detection如何使用tensorflow对象检测检查是否存在边界框
【发布时间】:2020-10-14 12:45:42
【问题描述】:

我正在为小型无人机编写程序。我正在计算每一帧平台的距离和坐标。无人机根据边界框的坐标顺时针或逆时针旋转,直到边界框居中。

                maxBoxes=1 #max boxes to draw
                vis_util.visualize_boxes_and_labels_on_image_array(
                    image,
                    np.squeeze(boxes),
                    np.squeeze(classes).astype(np.int32),
                    np.squeeze(scores),
                    category_index,
                    max_boxes_to_draw=maxBoxes,
                    min_score_thresh=0.5,
                    use_normalized_coordinates=True,
                    line_thickness=4)
                #if here, to check whether there is a detected object and then calculate
                ymin = int((boxes[0][0][0]*imageHeight))
                xmin = int((boxes[0][0][1]*imageWidth))
                ymax = int((boxes[0][0][2]*imageHeight))
                xmax = int((boxes[0][0][3]*imageWidth))
                boxWidth=xmax-xmin
                boxHeight=ymax-ymax
                #Distance calculation
                distance=round(W*F/boxWidth,2) #distance from the object

我的问题是如何检查给定帧是否存在检测到的对象(边界框),因为有时它无法找到对象但仍沿随机方向旋转。

【问题讨论】:

    标签: tensorflow deep-learning object-detection object-detection-api bounding-box


    【解决方案1】:

    所以,通过github查看源代码后,我已经能够弄清楚了。方法是检查第一个分数是否低于阈值,如下面的示例。

                maxBoxes=1 #max boxes to draw
                minScoreThreshold=0.5 #minimum score threshold
                vis_util.visualize_boxes_and_labels_on_image_array(
                    image,
                    np.squeeze(boxes),
                    np.squeeze(classes).astype(np.int32),
                    np.squeeze(scores),
                    category_index,
                    max_boxes_to_draw=maxBoxes,
                    min_score_thresh=minScoreThreshold,
                    use_normalized_coordinates=True,
                    line_thickness=4)
                #if here, to check whether there is a detected object and then calculate
                if (scores[0]<minScoreThreshold).all():
                    print("Nothing has been detected")
                else:
                    print("Object has been detected. Continuing with calculations")
                    ymin = int((boxes[0][0][0]*imageHeight))
                    xmin = int((boxes[0][0][1]*imageWidth))
                    ymax = int((boxes[0][0][2]*imageHeight))
                    xmax = int((boxes[0][0][3]*imageWidth))
                    boxWidth=xmax-xmin
                    boxHeight=ymax-ymax
                    #Distance calculation
                    distance=round(W*F/boxWidth,2) #distance from the object
    

    【讨论】:

      猜你喜欢
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      • 2019-04-22
      • 2014-08-02
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      • 2022-10-24
      相关资源
      最近更新 更多