Hi,
I'm trying to select multiple points by mouse (with cv::EVENT_LBUTTONDOWN).
So I'm passing the std::vector to the Callback-Function:
//setting the roi manually
std::vector points;
cv::Mat img = cv::imread("f:/open/me.jpg");
cv::namedWindow("Original");
cv::setMouseCallback("Original", mouse_call, (void*)&points);
int X,Y;
cv::imshow("Original",img);
And in Callback:
static void mouse_call(int event,int x,int y, int, void* param)
{
if(event==cv::EVENT_LBUTTONDOWN){
std::vector* ptPtr = (std::vector*)param;
ptPtr->push_back(cv::Point(x,y));
}
And, when I'm trying to access the vector-elements with:
points[0].x
points[0].y
It's compiling, but at runtime i get an error:
"Debug Assertion Failed "
"Expression: vector subscript out of range"
Any clue ?
Thanks
↧