1

Hi im trying to remove big object from a picture in openCV in python I found a way to do it remove small and it worked perfectly. How could I tweak the code to only keep object from a specific range of size.

Here How to remove small connected objects using OpenCV

But when I do it for big object I get this:

error:OpenCV(3.4.1) Error: Assertion failed (iDepth == 0 || iDepth == 1) in cv::connectedComponents_sub1, file C:\projects\opencv-python\opencv\modules\imgproc\src\connectedcomponents.cpp, line 3941 Traceback (most recent call last):

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87

1 Answers1

0

Such an error states that there is some mismatch with the depth of the image. The function expects the input image to be 8 bit in depth. Convert your image using the following and then pass it to the function cv2.connectedComponents():

img=img.astype(numpy.uint8)
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87