OPENCV Mat图像在MFC PictureControl显示

    xiaoxiao2021-04-12  32

    OPENCV Mat图像在MFC PictureControl显示

    直接看代码

    FlagVideoWindow保证opencv windows 与 picture control不会重复关联,IDC_PHOTONAME1为picture control名称:

    if (FlagVideoWindow)//此段代码近执行一次 { FlagVideoWindow = false; CRect rect; GetDlgItem(IDC_PHOTONAME1)->GetClientRect(rect); namedWindow("摄像头画面", WINDOW_NORMAL); resizeWindow("摄像头画面", rect.Width(), rect.Height()); HWND hWnd = (HWND)cvGetWindowHandle("摄像头画面"); HWND hParent = ::GetParent(hWnd); ::SetParent(hWnd, GetDlgItem(IDC_PHOTONAME1)->m_hWnd); ::ShowWindow(hParent, SW_HIDE); } camera.open(0); if (!camera.isOpened()) { AfxMessageBox(_T("Camera_Open failed!")); exit(1); } while (1) { camera >> cameraFrame; if (cameraFrame.empty()) { //AfxMessageBox("Camera_Show failed!"); exit(1); } imshow("摄像头画面", cameraFrame); if (waitKey(30) >= 0) break; }
    转载请注明原文地址: https://ju.6miu.com/read-667641.html

    最新回复(0)