Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Segfault when accessing keypoint[i].pt (keypoint coordinates)

I'm trying to access the coordinates of keypoints picked up from an image by SimpleBlobDetect. As per here my code is as follows:

vector<KeyPoint> keypoints;
float kpt_x, kpt_y;

for(int i=0; i<=keypoints.size(); i++)
{
     kpt_x = keypoints[i].pt.x;
     kpt_y = keypoints[i].pt.y;
}

But this throws a segfault on each line within the for loop. Why? Is this the correct way of accessing keypoint coordinates?

Segfault when accessing keypoint[i].pt (keypoint coordinates)

I'm trying to access the coordinates of keypoints picked up from an image by SimpleBlobDetect. As per here my code is as follows:

vector<KeyPoint> keypoints;
float kpt_x, kpt_y;

for(int i=0; i<=keypoints.size(); i++)
{
     kpt_x = keypoints[i].pt.x;
     kpt_y = keypoints[i].pt.y;
}

But this throws a segfault on each line within the for loop. loop.

Why? Is this the correct way of accessing keypoint coordinates?

EDIT: When I run debugger, it shows that the error is on the line kpt_x = keypoints[i].pt.x;