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
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!