OPENCV Mat图像在MFC PictureControl显示

来源:互联网 发布:微博用户画像算法 编辑:程序博客网 时间:2024/05/17 02:44

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;    }
0 0
原创粉丝点击