First time here? Check out the FAQ!

Ask Your Question
0

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

asked Mar 3 '16

kazar13 gravatar image

updated Jun 11 '0

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 ?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Mar 3 '16

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(...)

Preview: (hide)

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 (Mar 3 '16)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 (Mar 3 '16)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 (Mar 3 '16)edit

how can you resolve this problem??

Walid gravatar imageWalid (Nov 22 '19)edit

Question Tools

1 follower

Stats

Asked: Mar 3 '16

Seen: 568 times

Last updated: Jun 10 '20