OpenCV MSER detection issue [closed]
I'm trying to separate the detected objects into images but since the MSER method are detecting too many times the boundaries when i save into images i get a lot of repetetive images.
This is the image with the MSER detection: MSER detection:
So i want to separate each object into an image, without any repetitions. Is anyone can help me?
Thank you! Rita Maia
This is my code so far:
img = cv2.imread('C:\Users\Rita\Desktop\ISCTE\2_ano\Tese\MSER\1_Exemplo\botoes_v2.PNG',1)
vis = img.copy()
mser = cv2.MSER_create()
mser = cv2.MSER_create( _min_area = 5000, _max_area = 25000, _max_variation = 1.0)
vis = img.copy()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
regions, _ = mser.detectRegions(gray)
hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions] cv2.polylines(vis, hulls, 1, (0, 255, 0))
for i, contour in enumerate(hulls):
x,y,w,h = cv2.boundingRect(contour)
cv2.imwrite('1_exemplo_{}.png'.format(i), img[y:y+h,x:x+w])
that's unclear, please explain. does it detect several boxes in the same place or such ?
in the loop i save all the images and i have duplicate images like: 2 times "habitação" and 2 times "Climatização" etc
I got the same problem. and I only found this out when I save each "detected" region into a single mask. They're repetitive in the meaning that many detected regions are basically the same (only differ slightly from each other). Have you solve this since then?