vector内元素按升序存储:
#include <opencv2/opencv.hpp>
#include <iostream>
#pragma comment(lib,"opencv_world341.lib")
using namespace cv;
using namespace std;
int main()
{
vector<Point2f> pts_v{ Point2f(100,200),Point2f(300,150),Point2f(200,400) };
sort(pts_v.begin(), pts_v.end(),
[](Point2f pts1, Point2f pts2) {return pts1.x < pts2.x; });
cout << pts_v << endl;
return 0;
}
//
vector<Rect> temp;
std::sort(temp.begin(), temp.end(),
[](Rect& rect1, Rect& rect2) { return rect1.x < rect2.x; }
);
image.png
参考:
- https://blog.csdn.net/sss_369/article/details/88983580
网友评论