My class name is HandMotionRecognition, and I call the getColorPixel method in the mouse callback. This is in OpenCV using Visual Studio 2010, and the project type is C ++ β cli.
Standard code (if I'm not mistaken) for handling mouse events
cvSetMouseCallback( "CameraIn", getColorPixel, (void*) frameHSV);
But when I compile, it gives a compile time error
error C3867: "HandMotionRecognition :: getColorPixel": list of missing function arguments; use '& HandMotionRecognition :: getColorPixel' to create a pointer to an element
Then I will do as I said, and put the code like this:
cvSetMouseCallback( "CameraIn", &HandMotionRecognition::getColorPixel, (void*) frameHSV);
But again, I get a compilation error.
error C3374: Unable to get address "HandMotionRecognition :: getColorPixel" if delegate instance is not created
So, I create such a delegate ... [creating a delegate..I donβt know that this is 100% correct]
I put delegate void MouseCallbackDelegate( int event, int x, int y, int flags, void *param ); in HandMotionRecognition.h
I put this code in HandMotionRecognition.cpp instead of cvSetMouseCallback( "CameraIn", &HandMotionRecognition::getColorPixel, (void*) frameHSV);
MouseCallbackDelegate ^StaticDelInst = gcnew MouseCallbackDelegate(this, &HandMotionRecognition::getColorPixel);
cvSetMouseCallback ("CameraIn", StaticDelInst, (void *) frameHSV);
But then it gives a compilation error: (this is the only error I get)
error C2664: 'cvSetMouseCallback': cannot convert parameter 2 from 'HandMotionRecognition :: MouseCallbackDelegate ^' to 'CvMouseCallback'
(As you can see, this is due to using cli instead of win32)
Is there any work around this or am I doing something wrong here?
Please, help...
c ++ opencv delegates mouseevent
Sachira
source share