OpenCV MSER detection issue [closed]

asked 2018-05-22 05:34:45 -0600

maia07 gravatar image

updated 2018-05-22 05:42:46 -0600

berak gravatar image

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: C:\fakepath\GDFXn.png

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])
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-11-09 09:37:51.896716

Comments

without any repetitions.

that's unclear, please explain. does it detect several boxes in the same place or such ?

berak gravatar imageberak ( 2018-05-22 05:44:16 -0600 )edit
1

in the loop i save all the images and i have duplicate images like: 2 times "habitação" and 2 times "Climatização" etc

maia07 gravatar imagemaia07 ( 2018-05-22 05:49:27 -0600 )edit

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?

JimRaynor gravatar imageJimRaynor ( 2019-11-07 19:18:09 -0600 )edit