Create MFC Application
Add Picture Control
Add Initial codes in OnInitDialog
// TODO: Add extra initialization hereCRect rect;
CWnd *pWnd = GetDlgItem(IDC_LIVE);
pWnd->GetWindowRect(&rect);
ScreenToClient(&rect); //optional step - see below
cv::namedWindow("IDC_STATIC_OUTPUT", 0);
cvResizeWindow("IDC_STATIC_OUTPUT", rect.right - rect.left, rect.bottom - rect.top);
HWND hWnd = (HWND)cvGetWindowHandle("IDC_STATIC_OUTPUT");
HWND hParent = ::GetParent(hWnd);
::SetParent(hWnd, GetDlgItem(IDC_LIVE)->m_hWnd);
::ShowWindow(hParent, SW_HIDE);
if (m_video.open(0))
{
SetTimer(0, 33, NULL);
}
Add OnTimer Handler to drawing
void COpenCV_Static_MFCDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
cv::Mat frame;
m_video >> frame;
cv::imshow("IDC_STATIC_OUTPUT", frame);
CDialogEx::OnTimer(nIDEvent);
}
Update project setting
/Configuration Prperties/General
Use of MFC –> Use MFC in a Static Librar/Configuration Properties/C/C++/Code Generation
Character Set –> Use Multi-Byte Character Set
Runtime Library –> Multi-thread (/MT)/Configuration Properties/VC++ Directories
Security Check –> Disable Security Check (/GS-)
Include Directories: D:\OpenCV-3.2.0\opencv\build\include/Configuration Properties/Linker/Input
Library Directires
Additional Dependencies
opencv_highgui320.lib
opencv_core320.lib
ippicvmt.lib
zlib.lib
opencv_imgproc320.lib
opencv_imgcodecs320.lib
IlmImf.lib
libjpeg.lib
libjasper.lib
libpng.lib
libtiff.lib
libwebp.lib
opencv_video320.lib
opencv_videoio320.lib
vfw32.lib
沒有留言:
張貼留言
請提供您寶貴的意見