Oriented Objects Detection Parameters and Function

Hello everyone,
I want to perform multiple oriented objects detection on images like the color one shown above. Currently, I’m having some issues with the following parts: I don’t know the exact workflow for such kind of object detection so I was just trying different methods and parameters. It seems that canny detects these edges well, but some edges are not closed or connected to another cube’s edge so there may result in a missing cube of a big bounding box surrounding several objects. Another issue is that some colors after grayscaling get very similar to the background and cannot be detected for my code. My eventual goal is to get all cube’s center and orientation with accordingly oriented surrounding cubes (their size is the same and known). I’ll have two different settings: one is in simulation and one is in the real world. Thanks in advance for any suggestions!

many roads lead to rome.

assuming Canny leaves closed “contours”, you could invert the map and apply connected components labeling. it’ll label every object’s inside, and it’ll label the background and any enclosed islands of background, and it’ll label all the contours.

that may or may not work well. another idea:

since you have uneven illumination, perhaps take care of that by subtracting a big median blur (several times an object’s size).

then you could simply threshold the picture, since the objects are clearly darker than the background.

then you could erode, to separate widgets. that may fail if widgets don’t just touch corners, but entire edges.

you could threshold the color picture (transform to HSV) several times, to extract widgets of each individual color.

“graph cut” methods may work because they’re sensitive to edges/gradients.

Hi crackwitz,

Thank you very much for your answer!
I have a few more confusions: It seems that when I do canny, some edges are not closed, so that cannot be retrieved by using cv2.findcontour if I understand it correctly, and another issue is that some objects are very close to each other, so no matter I use threshold or canny their contours or area are then connected to each other and become one big bounding box, in the end, I’d like to have all different rotation bounding box for every object here.
Again, I really appreciate your great help!


1 Like

Thank you! I’m assuming my scenario is not too complicated to be detected, so I’m looking to play around with these functions to solve my problem. Do you have any suggestions to detect objects that are next to or close to each other individually and what about after grayscaling the image of objects that are similar to the background?
Thank you very much!

Hello everyone, it seems that canny detection looks fine to get all the edges (but since some are not closed so they cannot be retrieved by using findcontours function), and another issue is that some canny edges are connected to other cubes’ canny edges so they are bounded with one bounding box, is there any way I can fix this? Thank you!