how to extract ROI from a komplexer background

asked 2019-08-23 11:06:48 -0600

luca123 gravatar image

hello,guys, i have a problem for the roi extract. in the following picture i want to extract "kinzalkomb" object region sothat i can exactly process the object information. image description

i have tried to convert image in gray and binar image and then use findcontour to find extract contour of object. but it not always works good when the object changes oder brightness changes. do you have any ideas? thank you in advance

edit retag flag offensive close merge delete

Comments

The problem you are dealing with is called "text detection". An alternative approach to yours would be using a neuronal network for detection like here: https://www.pyimagesearch.com/2018/08...

I you have a bit money you could consider using the google cloud vision api(which will also give your the writing as text - it will "read"). I think from a accuracy point of view its pretty good. I am currently training an own text detection model(actually i am still farming data from html websites) - as i am not happy with the east text detecion model.

holger gravatar imageholger ( 2019-08-24 04:27:34 -0600 )edit

Do you want to extract the whole medicine package? Do you want to extract ANY medicine package you put there? For any or for one static background?

Witek gravatar imageWitek ( 2019-08-24 19:03:47 -0600 )edit

@Witek i want to extract only the medicine, which robot arm grasps(hier is the big size medicine with name kinzalkom)。the othes should be elimated and be changed into black bakcground。

luca123 gravatar imageluca123 ( 2019-08-25 01:46:07 -0600 )edit

Can you take more than one picture: with the robotic arm holding the medicine and when it has moved away from the view?

Witek gravatar imageWitek ( 2019-08-25 03:22:16 -0600 )edit

@Witek yeah, i can take a picture with robotic arm holding the medicine and it has moved away, sothat i can use background subtraction, but it seems like working not good, because function BackgroundSubtractorMOG2 only can recognize dynamic frame, for the static frame it can not work. do you have solution for this? oder i have done maybe something wrong.

luca123 gravatar imageluca123 ( 2019-08-25 03:38:08 -0600 )edit

BackgroundSubtractorMOG2 is an overkill for just 2 images and it won't work. Simply subtract these 2 images, threshold the result and you should get a mask of any new objects in the view. It won't be perfect and it will contain the robotic arm, but I would start there.

Witek gravatar imageWitek ( 2019-08-25 03:58:37 -0600 )edit

@Witek, i have tried to do subtract two images as you said, after that i made the threshod and use findContours function to find contours, but it doesn't exactly to show the disired object contours. do you have any another method fot this? thank you in advance!

luca123 gravatar imageluca123 ( 2019-08-29 13:10:10 -0600 )edit

Well the author mentioned i want to extract "kinzalkomb" object region.This suggest you want to read/detect that region. Now we are discussing about detecting the box. Well...

My suggestion for solving this: Just train an object detector(detects the medicine) followed by a text detector(detects text), followed by a character classifier(maybe just use tesseract for this)

holger gravatar imageholger ( 2019-08-30 04:34:21 -0600 )edit

@luca123 can you upload these two images? Do you need to get the exact contours of the medicine box or approximate location is fine?

Witek gravatar imageWitek ( 2019-08-30 13:48:40 -0600 )edit