-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
108 lines (84 loc) · 2.89 KB
/
main.cpp
File metadata and controls
108 lines (84 loc) · 2.89 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//------------------------------------------------------------------------------
// ViroVision.cpp
//------------------------------------------------------------------------------
#define _WIN32_WINNT 0x0500
#include "ViroVision.h"
#include "ViroVisionFilters.h"
using namespace ViroVision;
using namespace ViroVisionFilters;
#include "main.h"
HWND m_hWnd = NULL;
CViroVisionBase *g_pViroVision = NULL;
LRESULT CALLBACK WndMainProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_VIROVISION_NOTIFY:
g_pViroVision->HandleGraphEvent();
break;
case WM_SIZE:
g_pViroVision->ResizeVideoWindow();
break;
case WM_CLOSE:
// Hide the main window while the graph is destroyed
ShowWindow(m_hWnd, SW_HIDE);
delete g_pViroVision; // Stop capturing and release interfaces
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
// Pass this message to the video window for notification of system changes
//if (m_pVideoWindow)
// m_pVideoWindow->NotifyOwnerMessage((LONG_PTR) hwnd, message, wParam, lParam);
return DefWindowProc (hwnd , message, wParam, lParam);
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hInstP, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg={0};
WNDCLASS wc;
::CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Register the window class
ZeroMemory(&wc, sizeof wc);
wc.lpfnWndProc = WndMainProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASSNAME;
wc.lpszMenuName = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = NULL;
if(!RegisterClass(&wc))
{
exit(1);
}
// Create the main window. The WS_CLIPCHILDREN style is required.
m_hWnd = CreateWindow(CLASSNAME, APPLICATIONNAME,
WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT,
DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT,
0, 0, hInstance, 0);
if(m_hWnd)
{
g_pViroVision = new CViroVisionBase();
CViroVisionFilters *pvvFilters = new CViroVisionFilters();
unsigned int filterParam = 1;
if (SUCCEEDED(g_pViroVision->FilterVideo(m_hWnd,
(LRESULT CALLBACK) CViroVisionFilters::MotionDetectionFilter,
(LPVOID) &filterParam, pvvFilters)))
{
ShowWindow(m_hWnd, nCmdShow);
}
else
{
delete g_pViroVision;
DestroyWindow(m_hWnd);
}
// Main message loop
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}