I have a result like this std::list<std::list<cv::Point2i>> and I would like to visualize the result using polylines() and imshow(). Is there a way to realize this without having to copy the list elements to vectors?
Unfortunately, the answer is no. cv::polylines accepts only continuously stored data. So it can't process points stored in std::list.
If you don't want to store your points in std::vector you may implement polylines for std::list.
For example:
void polylines(cv::Mat& img, const std::list<std::list<cv::Point2i>>& polylines)
{
for (auto& polyline : polylines)
{
auto current = polyline.begin();
auto next = std::next(current, 1);
for (; next != polyline.end(); current++, next++)
{
cv::line(img, *current, *next, cv::Scalar(255));
}
}
}
Then you can call cv::imshow for drawing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With