'Vector point std::vector<cv::Point>

I am trying to draw a trajectory on an image and saving these trajectory points as std::vector<cv::Point> trajectoryPoint and I would like to access the data inside.

This a short snippet from my code:

cv::line(currentFrame, trajectoryPoint.back(), cv::Point(x, y), Scalar(255, 255, 255), 1, 8);
trajectoryPoint.push_back(Point(x, y));
std::cout << trajectoryPoint.at() << std::endl;

Normally, in Matlab it is easy to see the data inside vectors. However, I don't know how to continuously print out the data while drawing in C++ inside trajectoryPoint. Any suggestions?



Solution 1:[1]

you can try to wrap a cv::Mat around it (which has nice printing ops):

std::vector<cv::Point> trajectoryPoint = ...
cv::Mat viz(trajectoryPoint);
std::cout << viz << std::endl;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 berak