This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

you can do the following
1-find all Regions in the image by using findcontour
2-find center for every region, you can use moments , the center point will represent the region
3- Pass the centers to Kmeans Kmean clustring or this link

Kmean will find the clusters group of points
4-For every cluster You can use one of the following function to detect the rectangle (boundingRect,approxPolyDP,RotatedRect)

2 | No.2 Revision |

you can do the ~~following
~~following

1-find all Regions in the image

~~by~~by using findcontour 2-find center for every region, you can~~use~~use moments~~represent~~represent the region 3- Pass the centers to Kmeans~~Kmean~~Kmean clustring or this link`Kmean will find the clusters group of points`

~~to~~todetect the

~~rectangle~~rectangle (boundingRect,approxPolyDP,RotatedRect)

3 | No.3 Revision |

you can do the following

1-find find all Regions in the image by

~~using findcontour~~~~2-find~~using findcontour- find center for every region,
~~you~~you can use moments , the center point will represent the~~region 3-~~region Pass the centers to Kmeans

~~Kmean~~Kmean

clustring or this link~~or this link~~`Kmean will find the clusters group of points`

`For every cluster You can use one of the following function`

~~to~~detect todetect the

~~rectangle (boundingRect,approxPolyDP,RotatedRect)~~rectangle(boundingRect, approxPolyDP,rotatedRect)

` `~~4-For ~~

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.