Content-Length: 294052 | pFad | http://github.com/opencv/opencv/issues/25666

47 findContours inner holes has problems with their corners · Issue #25666 · opencv/opencv · GitHub
Skip to content

findContours inner holes has problems with their corners #25666

@YoniChechik

Description

@YoniChechik

System Information

opencv-python-headless==4.9.0.80
Operating System / Platform: Ubuntu 22.04 in docker
Python version: 3.11.9

Detailed description

ploting a square with square hole:
image

using this code:

    # Create a binary mask with several polygons, some with holes
    im = np.zeros((100, 100), dtype=np.uint8)

    # Polygon (square with a hole)
    im[30:50, 30:50] = 1
    im[35:45, 35:45] = 0
    fig, ax = plt.subplots()
    plt.imshow(im)
    plt.show()

    contours_tuple_of_Nx1x2_uv_arrays, hierarchy_1xNx4 = cv2.findContours(im, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
    for x in contours_tuple_of_Nx1x2_uv_arrays:
        print(x.shape)
# result of print:
# (4, 1, 2)
# (8, 1, 2)

running this will give us the inner hole contour with bad corners - as you can see the inner hole should be square but we get 8 points in the contour and it looks like this:

image

Steps to reproduce

above

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: http://github.com/opencv/opencv/issues/25666

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy