Ask Your Question

kazar13's profile - activity

2016-03-18 06:52:13 -0600 received badge  Enthusiast
2016-03-05 11:10:29 -0600 commented answer select multiple points with mouse (opencv 2.4.9,vs2010,winforms)

I've added following statement:

`if (points.size() > 0) //we do have points in vector

{ MessageBox::Show(System::Convert::ToString(points[0].x));

    }

`

After i click several times on image, i don't get any message box returned with coordinate. Am I still doing something wrong ?

2016-03-04 07:45:11 -0600 received badge  Editor (source)
2016-03-04 07:43:37 -0600 asked a question select multiple points with mouse (opencv 2.4.9,vs2010,winforms)

Hi,

I'm trying to select multiple points by mouse (with cv::EVENT_LBUTTONDOWN).

So I'm passing the std::vector<cv::point> to the Callback-Function:

//setting the roi manually
std::vector<cv::Point> 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<cv::Point>* ptPtr = (std::vector<cv::Point>*)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

2016-03-03 08:29:17 -0600 received badge  Scholar (source)
2016-03-03 08:29:15 -0600 commented answer cv::setMouseCallback with winforms (OpenCV 2.4.9,vs 2010)

Thank You, it helped moving the function up from class to the DCS_new-namespace. Im using the standard /clr (not pure or safe).

2016-03-03 07:53:54 -0600 commented answer cv::setMouseCallback with winforms (OpenCV 2.4.9,vs 2010)

This produces following error:

error C2664: 'cv::setMouseCallback' : cannot convert parameter 2 from 'void (__clrcall *)(int,int,int,int,void *)' to 'cv::MouseCallback'
None of the functions with this name in scope match the target type
2016-03-03 06:48:15 -0600 asked a question cv::setMouseCallback with winforms (OpenCV 2.4.9,vs 2010)

Hi ! Im working with OpenCV 2.4.9 with winforms (vs 2010).

Im trying to use cv::setMouseCallback with winforms of vs 2010. I have a mouse callback:

void mouse_call(int event,int x,int y, int, void*){
}

and then:

   cv::Mat img = cv::imread("f:/open/me.jpg");
   cv::namedWindow("Original");
   cv::imshow("Original",img);

 cv::setMouseCallback("Original", mouse_call, this);

I get an error:

error C3867: 'DCS_new::Evaluation_module_3::mouse_call': function call missing argument list; use '&DCS_new::Evaluation_module_3::mouse_call' to create a pointer to member

Any help please ?