Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Mouse callback - I wan't to know what I'm doing

I took function from book to create callback function and it's work. Fuction specifies the location of the mouse on the image and write to console cordinates.

Function looks like:

      void mouse_ev (int event, int x, int y, int flags, void* param)
     {

      Mat *img = ((Mat *)param);

      switch (event) {

      case EVENT_MOUSEMOVE: cout << "x: " << x << "y: " << y << endl;

          break;
      }

      }

and im main function I use it by this:

     setMouseCallback ( window_name, mouse_ev, NULL);

How exactly x and y are sent to mouse_ev function? Is setMouseCallback send all this information to second param of function?

For what is that: Mat *img = ((Mat *)param); line?

My question may seem silly but I want to know 100 percent what I'm doing.

Mouse callback - I wan't to know what I'm doing

I took function from book to create callback function and it's work. Fuction specifies the location of the mouse on the image and write to console cordinates.

Function looks like:

      void mouse_ev (int event, int x, int y, int flags, void* param)
     {

      Mat *img = ((Mat *)param);

      switch (event) {

      case EVENT_MOUSEMOVE: cout << "x: " << x << "y: " << y << endl;

          break;
      }

      }

and im main function I use it by this:

     setMouseCallback ( window_name, mouse_ev, NULL);

How exactly x and y are sent to mouse_ev function? Is setMouseCallback send all this information to second param of function?

For what is that: Mat *img = ((Mat *)param); line?

My question may seem silly but I want to know 100 percent what I'm doing.