I have a vector of a 2-dimensional points in OpenCV
std::vector<cv::Point2f> points;
I would like to calculate the mean values for x and y coordinates in points. Something like:
cv::Point2f mean_point; //will contain mean values for x and y coordinates
mean_point = some_function(points);
This would be simple in Matlab. But I’m not sure if I can utilize some high level OpenCV functions to accomplish the same. Any suggestions?
InputArraydoes a good job here. You can simply callDetails:
In the newer OpenCV versions, the
InputArraydata type is introduced. This way, one can send as parameters to an OpenCV function either matrices (cv::Mat) either vectors. Avector<Vec3f>will be interpreted as a float matrix with three channels, one row, and the number of columns equal to the vector size. Because no data is copied, this transparent conversion is very fast.The advantage is that you can work with whatever data type fits better in your app, while you can still use OpenCV functions to ease mathematical operations on it.