在MFC中显示图片(opencv Mat类型)

1,在MFC窗体中添加picture control控件,并添加对应的变量名

2,在窗体的初始化窗口中添加:

    namedWindow("show", 0);
    HWND hWnd = (HWND)cvGetWindowHandle("show");
    HWND hParent = ::GetParent(hWnd);
    ::SetParent(hWnd, GetDlgItem(IDC_STATIC)->m_hWnd);
    ::ShowWindow(hParent, SW_SHOW);
    GetDlgItem(IDC_STATIC_CV)->GetClientRect(&m_glb.rectD);        

3,在需要显示窗口的地方添加:

cv::Mat m_dst;
            cv::resize(binaryDiffFrame, m_dst, cv::Size(rectD.Width(), rectD.Height()));
            imshow("view",m_dst);
            waitKey(2);

 来源:https://www.zhihu.com/question/29611790/answer/45068617

 

posted @ 2016-03-12 15:03  Daringoo  阅读(3737)  评论(0编辑  收藏  举报