關(guān)于攝像頭的控制操作,無非就是獲取攝像頭圖像并且保存攝像頭視頻等常用的操作,。 關(guān)于在MFC項目中利用opencv捕獲攝像頭信息,,在下面這篇文章中寫的很詳細: http://blog.csdn.net/weixingstudio/article/details/7360941 writer=cvCreateVideoWriter("MyVideo.avi",CV_FOURCC('x','v','I','D'),25,cvSize(640,480)); CvCapture* capture; CRect rect; CDC *pDC; HDC hDC; CWnd *pwnd;
void CVideoMFCDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here //AfxMessageBox("OK"); if(!capture) { capture = cvCaptureFromCAM(0); //AfxMessageBox("OK"); } if (!capture) { AfxMessageBox("無法打開攝像頭"); return; } writer=cvCreateVideoWriter("MyVideo.avi",CV_FOURCC('x','v','I','D'),25,cvSize(640,480)); // 測試 IplImage* m_Frame; m_Frame=cvQueryFrame(capture); CvvImage m_CvvImage; m_CvvImage.CopyOf(m_Frame,1); if (true) { m_CvvImage.DrawToHDC(hDC, &rect); //cvWaitKey(10); } // 設(shè)置計時器,每10ms觸發(fā)一次事件 SetTimer(1,10,NULL); }
void CVideoMFCDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add your message handler code here and/or call default /************************************************************************/ /* 顯示攝像頭 */ /************************************************************************/ IplImage* m_Frame; m_Frame=cvQueryFrame(capture); CvvImage m_CvvImage; m_CvvImage.CopyOf(m_Frame,1); if (true) { m_CvvImage.DrawToHDC(hDC, &rect); cvWriteFrame(writer,m_Frame); //cvWaitKey(10); } CDialogEx::OnTimer(nIDEvent); }
http://download.csdn.net/detail/weixingstudio/4284066 |
|
來自: 昵稱10504424 > 《C#》