vector point2f初始化
时间: 2023-11-06 09:07:56 浏览: 391
vector初始化
在C++中,可以使用以下方法来初始化vector point2f:
1. 直接初始化一个空的vector point2f:
vector<cv::Point2f> points;
2. 初始化一个带有初始值的vector point2f:
vector<cv::Point2f> points = {cv::Point2f(x1, y1), cv::Point2f(x2, y2), ...};
3. 使用push_back方法逐个添加元素到vector point2f:
vector<cv::Point2f> points;
points.push_back(cv::Point2f(x1, y1));
points.push_back(cv::Point2f(x2, y2));
...
4. 使用resize方法预先设置vector point2f的大小,并使用下标访问来赋值:
vector<cv::Point2f> points;
points.resize(num_points);
points = cv::Point2f(x1, y1);
points = cv::Point2f(x2, y2);
...
阅读全文