fen1ksss
fen1ksss

Reputation: 1120

How to write coordinates in keypoint?

I've got coordinates of one pixel of my image (for example int i,j;), how can I write them into a vector like the following one?

std::vector<KeyPoint> keypoint_object;

Upvotes: 0

Views: 877

Answers (2)

bitmask
bitmask

Reputation: 34674

From the documentation, I see there is a constructor for KeyPoint that allows insertion of your indices. However it requires an additional parameter size, and I don't know what you need that to be.

However, the general idea would be this:

keypoint_object.push_back(KeyPoint(i,j,0));

Here, i and j are implicitly cast to float (I assume that is what you require) and the third argument is 0 (as it's mandatory) -- you probably want a more sensible argument here.

Upvotes: 1

Aklovo
Aklovo

Reputation: 97

You can do a class:

class Coordinate{
public:
   int x;
   int y;
}

...

vector <Coordinate> name;

Coordinate coordinate;
coordinate.x = 1~
coordinate.y = 5~

name.push_back(coordinate);

This is what are you looking for? I hope this will help you!

Upvotes: 2

Related Questions