Ask Your Question
0

cv::setMouseCallback with winforms (OpenCV 2.4.9,vs 2010)

asked 2016-03-03 06:47:54 -0600

kazar13 gravatar image

updated 2020-06-10 20:59:02 -0600

supra56 gravatar image

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 ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-03-03 07:28:19 -0600

berak gravatar image

since you have to pass the address of a free function (not a class member) to setMouseCallback(), you need:

static void mouse_call(...)

edit flag offensive delete link more

Comments

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
kazar13 gravatar imagekazar13 ( 2016-03-03 07:53:54 -0600 )edit

bear with me, have not used clr in a long time.

are you using /clr:pure or such ? play with the flags there.

try to put the function out of your class

berak gravatar imageberak ( 2016-03-03 07:57:56 -0600 )edit
1

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

kazar13 gravatar imagekazar13 ( 2016-03-03 08:29:15 -0600 )edit

how can you resolve this problem??

Walid gravatar imageWalid ( 2019-11-22 02:38:47 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-03 06:47:54 -0600

Seen: 528 times

Last updated: Jun 10 '20