mardi 8 juin 2021

How to access each numerical element in cv::Point_

I have a cv::Rect object. From it, I am getting the bottom right point of the rectangle. I want to separate the point object into two separate int variables. How do I do this?

This is what I have so far:

cv::Rect rectangle;
bottomRight = rectangle.br() // this gives me a Point <int>, such as [545, 364]

I want to separate bottomRight into its two coordinate points as different int variables, such as:

// bottomRight is [545, 364]
bottomRight_x = bottomRight[0] // should be 545
bottomRight_y = bottomRight[1] // should be 364

When I try to subscript, I get this error:

type 'Point_' does not provide a subscript operator

In Python, I would just subscript as above. How do I do this in C++?

Aucun commentaire:

Enregistrer un commentaire