Shape and color detaction

Hi, How can I detect a black rectangle in an image that also has a black circle?

Are they on top of each other?

Not quite, we have to find a black rectangle on a white field, there are a few black and silver balls on that white field that we have nothing to do with black balls

You can use color tracking to do this. Please try out the feature.

but How we can filter the object by their shape after finding them with color tracking?

Please read the docs about blob library… you can do this really easy with blob. roundness ()