OpenCV related, get item from vector of cv:Point

May 3, 2022 at 7:40am
Write your question here.

[code]
string path = "man.png";
Mat img = imread(path);
Mat matrix, imgWarp2;


std::vector<std::vector<cv::Point> > contours3 {{{1,2},{3,4},{5,6}}};

I need to get item from vector of CV::Point, but i can only output a pair.
Please advise
May 3, 2022 at 2:36pm
up
May 3, 2022 at 3:22pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Example program
#include <iostream>
#include <vector>

namespace cv {
    
struct Point {
    int x;
    int y;
};
   
}

int main()
{
    std::vector<std::vector<cv::Point> > contours3 {{{1,2},{3,4},{5,6}}};
    
    contours3[0]; // std::vector<cv:::Point>
    contours3[0][0]; // cv::Point
    int x = contours3[0][0].x; // int (cv::Point::value_type)
    
    std::cout << x << '\n';
}
Last edited on May 3, 2022 at 3:23pm
May 12, 2022 at 9:04am
solved, thank you
Last edited on May 12, 2022 at 11:13am
Topic archived. No new replies allowed.