opencv的nameWindow嵌套MFC窗口
作者:
小小蒟蒻
,
2021-03-01 00:33:30
,
所有人可见
,
阅读 447
void CAttachImShowDlg::Resize(const std::string strPath, Mat& dst)
{
CRect rect;
GetDlgItem(IDC_PIC)->GetClientRect(rect);
int height = rect.bottom - rect.top;
int width = rect.right - rect.left;
Mat src = imread(strPath); //从路径名中读取图片
resize(src, dst, Size{ width, height }, (0, 0), (0, 0), INTER_LINEAR);//重新调整图像大小
}
BOOL CAttachImShowDlg::AttachMfcWindow()
{
Mat img;
Resize("D:\\123.jpg", img);
namedWindow("Resize");
HWND hWnd = (HWND)cvGetWindowHandle("Resize");
if (!hWnd) return FALSE;
HWND hParent = ::GetParent(hWnd);
if (!hParent) return FALSE;
::ShowWindow(hParent, SW_HIDE);
::SetParent(hWnd, GetDlgItem(IDC_PIC)->GetSafeHwnd());
imshow("Resize", img);
waitKey(1);
return TRUE;
}
在OnInitDialog中调用