在Oninit()
里添加
cv::namedWindow("view", cv::WINDOW_NORMAL); HWND hWnd = (HWND)cvGetWindowHandle("view"); HWND hParent = ::GetParent(hWnd); ::SetParent(hWnd, GetDlgItem(IDC_STATIC)->m_hWnd); ::ShowWindow(hParent, SW_HIDE); cv::resizeWindow("view", 803, 617);//和我的picture control大小一致
在button里添加
cv::VideoCapture capture; cv::Mat myImagine; capture.open(0); CRect rect; GetDlgItem(IDC_STATIC)->GetClientRect(&rect); for (;;) { capture >> myImagine; cv::imshow("view", myImagine); cvWaitKey(10); }