Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made simple dialog-based MFC code to display image using Opencv.

In OnInitDialog(), the following code is used to set the Opencv window into the dialog
C++
cv::namedWindow("MY_IMG", 1);
HWND hWndT = (HWND) cvGetWindowHandle("MY_IMG");
HWND hParentT = ::GetParent(hWndT);
::SetParent(hWndT, GetDlgItem(IDC_IMG01)->m_hWnd);
::ShowWindow(hParentT, SW_HIDE);

As you may see, the image loaded from file into cv::Mat would be displayed in a static control named IDC_IMG01.

Now I want to have mouse operation in the image (such as selecting certain region or drawing a curve on top of the image) using setMouseCallback function of Opencv. The problem is, how to make the setMouseCallback works? I've put it within OnLButtonDown function of the dialog, hoping that when I click the image area the mouse callback function can be invoked, but it didn't. I found out that I could not even get the point passed by CPoint of the dialog within the image area.

If you have any experience with such problem, would you mind to share the solution?

Thank you!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900