Closed gustavovisentini closed 4 months ago
VecVecPoint is Iterable
, so you can just use normal Iterable methods. e.g., something like
final points = [
[cv.Point(1, 1), cv.Point(2, 2), cv.Point(3, 3), cv.Point(4, 4)],
[cv.Point(9, 9), cv.Point(0, 0), cv.Point(1, 6), cv.Point(2, 8)],
[cv.Point(5, 5), cv.Point(6, 6), cv.Point(7, 7), cv.Point(8, 8)],
];
final vec = points.cvd;
final areas = vec.map(cv.contourArea).toList(growable: false);
final vecSorted = vec.indexed.toList(growable: false);
vecSorted.sort((a, b)=>areas[a.$1].compareTo(areas[b.$1]));
print(areas); // [0.0, 29.0, 0.0]
print(vecSorted.map((e) => e.$2)); // ((Point(1, 1), Point(2, 2), Point(3, 3), Point(4, 4)), (Point(5, 5), Point(6, 6), Point(7, 7), Point(8, 8)), (Point(9, 9), Point(0, 0), Point(1, 6), Point(2, 8)))
vector wrappers like VecU8, VecPoint etc. will be refactored in the next release for better performance and returning reference, I have tried my best to keep compatibility but this do is a breaking change.
If you have any further questions, please open a new issue, I am going to close this one, have fun with opencv_dart!
Question
its possible order by size of contourArea in this vector VecVecPoint?
The code reads a series of contours, calculates and orders their areas, and then uses these areas to calculate metrics such as total volume and a central metric (dmv). The logic behind this appears to be to analyze the distribution of contour areas and find a central point of balance based on volume.
My code in c++