Detecting objects OpenCV

Hey there,

I’ve tried multiple things (canny edge detection, dbscan, disttransform, watershed) but I can’t find a solution.

I need to be able to seperate these dice.
I have to use opencv in this case.

Can you identify the dice shapes, which could be squares (1 die) or rectangles (2 dice) whose sides are in the ratio 2:1?

If it’s a rectangle, split it into 2 squares and count the dots on each die.