lh2705
lh2705

Reputation: 15

Obtain X Y coordinates from CvPoint

I have a code which finds contours in the image. This works fine and the contours found are stored and CvPoints are used to draw lines around the contours.

Now I want to set the ROI for the image and I don't know how to refer to the X/Y points of the CvPoint to use. The points pt all have defined values.

CvPoint *pt[4];
int ROIwidth = *pt[0].x - *pt[1].x;

This doesnt seem to work. I get errors saying the left of '.x' must have class/struct/union How do I do it? Another article I found suggested that by adding the .x or .y should be able to do the trick..

Upvotes: 0

Views: 973

Answers (1)

Alex
Alex

Reputation: 10126

The error in your case can be explained by the fact that * has lower priority than . Thus you are trying to dereference the integer. That causes the issue.

Thus you should use:

pt[0]->x;

or

*(pt[0]).x;

Upvotes: 2

Related Questions