-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetCamVideoThread.cpp
62 lines (51 loc) · 1.22 KB
/
GetCamVideoThread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// GetCamVideoThread.cpp : implementation file
//
#include "stdafx.h"
#include "whu_MFC_Hand.h"
#include "GetCamVideoThread.h"
#include "whu_Golobal.h"
#include "whu_MFC_HandDlg.h"
// CGetCamVideoThread
IMPLEMENT_DYNCREATE(CGetCamVideoThread, CWinThread)
CGetCamVideoThread::CGetCamVideoThread()
{
}
CGetCamVideoThread::~CGetCamVideoThread()
{
cvReleaseCapture(&pCapture);
cvReleaseImage(&m_CamImg);
}
BOOL CGetCamVideoThread::InitInstance()
{
// TODO: perform and per-thread initialization here
return TRUE;
}
int CGetCamVideoThread::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
void CGetCamVideoThread::GetCamVideo(UINT wParam,LONG lParam)
{
CvSize m_Size;
m_Size.width=400;
m_Size.height=400;
m_CamImg = cvCreateImage(m_Size,IPL_DEPTH_8U,3);
pCapture = cvCreateCameraCapture(-1);
while (true)
{
if (m_gCamVideo)//Õâ¸öÕâ¸ö
{
m_CamImg = cvQueryFrame(pCapture);
::PostMessageW((HWND)(GetMainWnd()->GetSafeHwnd()),WM_DISPLAYVIDEO,(WPARAM)m_CamImg,NULL);
Sleep(100);
}else
{
Sleep(100);
}
}
}
BEGIN_MESSAGE_MAP(CGetCamVideoThread, CWinThread)
ON_THREAD_MESSAGE(WM_GETCAMVIDEO,GetCamVideo)
END_MESSAGE_MAP()
// CGetCamVideoThread message handlers