# Revision history [back]

### Contours sorting.

Are contours returned by findContours() sorted somehow? It seems that they aren't.

In fact, I've got 1D std::vector of centroids of contours. (Got with the help of moments())

I need to sort these centroids and "reduce" this 1D vector into 2D vector (vector of vectors) so that I could easily navigate among these centroids in two dimensional domain by i and j indexes.

I should also insert so called "missed" centroids (e.g. as negative ones) to make 2D array square or rectangular (alignment). Centroids form fine grid so I can measure distances between them on x and y coordinates to find out is there a "missed" centroid or two or several ones between two existing ones.

Couldn't you suggest an easy simple way to perform this?

 2 retagged sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

### Contours sorting.

Are contours returned by findContours() sorted somehow? It seems that they aren't.

In fact, I've got 1D std::vector of centroids of contours. (Got with the help of moments())

I need to sort these centroids and "reduce" this 1D vector into 2D vector (vector of vectors) so that I could easily navigate among these centroids in two dimensional domain by i and j indexes.

I should also insert so called "missed" centroids (e.g. as negative ones) to make 2D array square or rectangular (alignment). Centroids form fine grid so I can measure distances between them on x and y coordinates to find out is there a "missed" centroid or two or several ones between two existing ones.

Couldn't you suggest an easy simple way to perform this?

 3 retagged sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

### Contours sorting.

Are contours returned by findContours() sorted somehow? It seems that they aren't.

In fact, I've got 1D std::vector of centroids of contours. (Got with the help of moments())

I need to sort these centroids and "reduce" this 1D vector into 2D vector (vector of vectors) so that I could easily navigate among these centroids in two dimensional domain by i and j indexes.

I should also insert so called "missed" centroids (e.g. as negative ones) to make 2D array square or rectangular (alignment). Centroids form fine grid so I can measure distances between them on x and y coordinates to find out is there a "missed" centroid or two or several ones between two existing ones.

Couldn't you suggest an easy simple way to perform this?