本文共 1673 字,大约阅读时间需要 5 分钟。
效果图:
UINT __stdcall StartVideo(void *c){ CVideoConf *conf = (CVideoConf *)c; int vid = conf->code; CString strurl(conf->rtmpurl); CWnd *pW = conf->pW; CCameraDS camera; if (!camera.OpenCamera(0,false)); { TRACE("OpenCamera error....."); } while(true) { CvvImage cimg; CRect rect; IplImage *m_Frame ; BYTE *data1 = camera.QueryFrame(); m_Frame = cvCreateImageHeader(cvSize(320,240),IPL_DEPTH_8U,3); m_Frame->origin = 1; cvSetData(m_Frame,data1,320*3); CDC *pDC = pW->GetDC(); HDC hDC = pDC->GetSafeHdc(); pW->GetClientRect(&rect); cimg.CopyOf((IplImage *)m_Frame); //复制图片 cimg.DrawToHDC(hDC, &rect); //显示指定区域 HWND hWnd = pW->GetSafeHwnd(); ReleaseDC(hWnd,hDC); } return 0; }
UINT __stdcall StartVideo(void *c){ CVideoConf *conf = (CVideoConf *)c; int vid = conf->code; CString strurl(conf->rtmpurl); CWnd *pW = conf->pW; CCameraDS camera; if (!camera.OpenCamera(0,false)); { TRACE("OpenCamera error....."); } CvCapture* pCapture = cvCreateCameraCapture(0); //opencv打开视频 while(true) { CvvImage cimg; CRect rect; IplImage *m_Frame=cvQueryFrame( pCapture );//opencv捕获帧 CDC *pDC = pW->GetDC(); HDC hDC = pDC->GetSafeHdc(); pW->GetClientRect(&rect); cimg.CopyOf((IplImage *)m_Frame); //复制图片 cimg.DrawToHDC(hDC, &rect); //显示指定区域 HWND hWnd = pW->GetSafeHwnd(); ReleaseDC(hWnd,hDC); }