4

I'm trying to get mouse position inside and opened window in c# using openCVsharp methods.

First I define a callback function:

public void mc(MouseEvent me, int x, int y, MouseEvent me2) {}

Then in initiating phase I open the window an assign that callback function to it:

CvMouseCallback mo = new CvMouseCallback(mc);
Cv.NamedWindow("capture");
Cv.SetMouseCallback("capture", mo);

But callback is not called with mouse clicks in the opened window.

I tried to google it but no sample code or instructions was found for opencvsharp. And since in openCV its just a regular callback method -no need to that CVmousecallback - I couldn't find out how to perform this on openCVsharp.

Has anybody done that in openCVsharp?

1 Answer 1

1

This works for me:

Mat img = ...;
Window foo = new Window("bar", img); // class OpenCvSharp.CPlusPlus.Window
foo.OnMouseCallback += new CvMouseCallback(mc);

I also tried SetMouseCallback method on the first time, but it didn't work for me either.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.