电脑为win10 64位 VS2015
// Video.cpp: implementation of the CVideo class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Fatiguedetection.h"
#include "Video.h"
#ifdef DEBUG
#undef THIS_FILE
static char THIS_FILE[]=_FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVideo::CVideo()
{
}
CVideo::~CVideo()
{
}
int CVideo::OpenCamera(HDC hdc, CRect rect)
{
Sleep(3000);
CvCapture *capture;
capture=cvCaptureFromCAM(-1); //捕获摄像头
if(!capture)
{
AfxMessageBox("打开摄像头失败!");
return 1;
}
m_pcapture=capture; //视像头指针传递
m_rect=rect; //获得picture控件的RECT
m_hdc=hdc; //获得picture控件的画图句柄
return -1;
}
void CVideo::PlayCamera()
{
m_pframe = cvQueryFrame(m_pcapture);//获取一帧
if (m_pframe)
{
m_showimage.CopyOf(m_pframe, 1);
m_showimage.DrawToHDC(m_hdc, &m_rect); //显示到控件
}
}