当我把它们画在imag上时,east文本检测模型返回的边界框的数量会改变

2024-04-20 00:53:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用east文本检测模型,并使用它来检测一些品牌标签中的文本(为此进行了培训)。我正在打印模型返回的框的数量,首先它显示(返回的框的数量=13),但是当我在图像上循环并绘制边界框时,返回的框的数量发生了变化(返回的框的数量=9)。我不明白当我试图把模型画在图像上时,模型返回的盒子数量是如何变化的。你知道吗

  1. 返回的框数是13(当我注释最后几行代码时,它基本上是显示图像的)
    boxes = detection_text_single_image(image, settings.DOCKER_PORTS[0])
    print("------------------boxes returned by the east model")
    print(boxes)
    print("*"*70)
    print(len(boxes))
    print("*"*70)

    ## ones we get the boxes using the east model we will draw those     rectangle over the brand tag image

    ##sort_poly is used to sort the each box's point clockwise

    ##then after sorting we will take the top left and bottom right point of each box and draw the rectangles using for loop

      image1 = image.copy()
      if boxes is not None:
        for box in boxes:
            print("box no. inside the boxes")
            print(box)
            box = sort_poly(box.astype(np.int32))
            cv2.rectangle(image1, (box[0][0],box[0][1]), (box[2][0],box[2][1]), (255,0,0), 2)


    #cv2.imshow("image1", image1)
    #cv2.waitKey(0)
    #cv2.destroyAllWindows()

2.当我不注释显示图像的部分(代码的最后一行)时,返回的框数是9。你知道吗

    boxes = detection_text_single_image(image, settings.DOCKER_PORTS[0])
    print("------------------boxes returned by the east model")
    print(boxes)
    print("*"*70)
    print(len(boxes))
    print("*"*70)

    ## ones we get the boxes using the east model we will draw those rectangle over the brand tag image
    ##sort_poly is used to sort the each box's point clockwise
    ##then after sorting we will take the top left and bottom right point of each box and draw the rectangles using for loop

    image1 = image.copy()
    if boxes is not None:
        for box in boxes:
            print("box no. inside the boxes")
            print(box)
            box = sort_poly(box.astype(np.int32))
            cv2.rectangle(image1, (box[0][0],box[0][1]), (box[2][0],box[2][1]), (255,0,0), 2)


    cv2.imshow("image1", image1)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

我认为在这两种情况下,它应该返回相同数量的盒子


Tags: the模型图像imagebox数量modelsort