本文整理汇总了C++中Kinect::startVideoStream方法的典型用法代码示例。如果您正苦于以下问题:C++ Kinect::startVideoStream方法的具体用法?C++ Kinect::startVideoStream怎么用?C++ Kinect::startVideoStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kinect
的用法示例。
在下文中一共展示了Kinect::startVideoStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WinMain
INT WINAPI WinMain(HINSTANCE Instance, HINSTANCE, LPSTR, INT) {
gInstance = Instance;
INITCOMMONCONTROLSEX icc;
// Initialise common controls.
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&icc);
// Initialize menu bar and set the check boxes' initial state
gMainMenu = LoadMenu(Instance, "mainMenu");
CheckMenuItem(gMainMenu, IDM_DISPLAYVIDEO, MF_BYCOMMAND | MF_CHECKED);
const char* mainClassName = "KinectBoard";
gKinectON = LoadIcon(Instance, "kinect1-ON");
gKinectOFF = LoadIcon(Instance, "kinect2-OFF");
HBRUSH mainBrush = CreateSolidBrush(RGB(0, 0, 0));
// Define a class for our main window
WNDCLASSEX WindowClass;
ZeroMemory(&WindowClass, sizeof(WNDCLASSEX));
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style = 0;
WindowClass.lpfnWndProc = &MainProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = Instance;
WindowClass.hIcon = gKinectOFF;
WindowClass.hCursor = LoadCursor(nullptr, IDC_ARROW);
WindowClass.hbrBackground = mainBrush;
WindowClass.lpszMenuName = "mainMenu";
WindowClass.lpszClassName = mainClassName;
WindowClass.hIconSm = gKinectOFF;
RegisterClassEx(&WindowClass);
MSG Message;
HACCEL hAccel;
/* ===== Make two windows to display ===== */
// Set the size, but not the position
RECT winSize = {0, 0, static_cast<int>(ImageVars::width),
static_cast<int>(ImageVars::height)};
AdjustWindowRect(
&winSize,
WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
TRUE); // window has menu
// Create a new window to be used for the lifetime of the application
gDisplayWindow = CreateWindowEx(0,
mainClassName,
"KinectBoard",
WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
(GetSystemMetrics(SM_CXSCREEN) - (winSize.right - winSize.left)) / 2,
(GetSystemMetrics(SM_CYSCREEN) - (winSize.bottom - winSize.top)) / 2,
winSize.right - winSize.left, // returns image width (resized as window)
winSize.bottom - winSize.top, // returns image height (resized as window)
nullptr,
gMainMenu,
Instance,
nullptr);
/* ======================================= */
// Load keyboard accelerators
hAccel = LoadAccelerators(gInstance, "KeyAccel");
gProjectorKnt.setScreenRect(gCurrentMonitor.dim);
// Make window receive video stream events and image from Kinect instance
gProjectorKnt.registerVideoWindow(gDisplayWindow);
gProjectorKnt.startVideoStream();
gProjectorKnt.startDepthStream();
gProjectorKnt.enableColor(Processing::Red);
gProjectorKnt.enableColor(Processing::Blue);
while (GetMessage(&Message, nullptr, 0, 0) > 0) {
if (!TranslateAccelerator(gDisplayWindow, // Handle to receiving window
hAccel, // Handle to active accelerator table
&Message)) // Message data
{
// If a message was waiting in the message queue, process it
TranslateMessage(&Message);
DispatchMessage(&Message);
}
}
DestroyIcon(gKinectON);
DestroyIcon(gKinectOFF);
UnregisterClass(mainClassName, Instance);
UnregisterClass("monitorButton", Instance);
TestScreen::unregisterClass();
return Message.wParam;
}
示例2: MainProc
LRESULT CALLBACK MainProc(HWND handle, UINT message, WPARAM wParam,
LPARAM lParam) {
switch (message) {
case WM_CREATE: {
HWND recalibButton = CreateWindowEx(0,
"BUTTON",
"Recalibrate",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
9,
ImageVars::height - 9 - 28,
100,
28,
handle,
reinterpret_cast<HMENU>(IDC_RECALIBRATE_BUTTON),
gInstance,
nullptr);
SendMessage(recalibButton,
WM_SETFONT,
reinterpret_cast<WPARAM>(GetStockObject(DEFAULT_GUI_FONT)),
MAKELPARAM(FALSE, 0));
HWND toggleStreamButton = CreateWindowEx(0,
"BUTTON",
"Start",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
ImageVars::width - 9 - 100,
ImageVars::height - 9 - 28,
100,
28,
handle,
reinterpret_cast<HMENU>(IDC_STREAMTOGGLE_BUTTON),
gInstance,
nullptr);
SendMessage(toggleStreamButton,
WM_SETFONT,
reinterpret_cast<WPARAM>(GetStockObject(DEFAULT_GUI_FONT)),
MAKELPARAM(FALSE, 0));
break;
}
case WM_COMMAND: {
int wmId = LOWORD(wParam);
switch (wmId) {
case IDC_RECALIBRATE_BUTTON: {
// If there is no Kinect connected, don't bother trying to retrieve images
if (gProjectorKnt.isVideoStreamRunning()) {
TestScreen testWin(gInstance, false);
testWin.create(gCurrentMonitor.dim);
testWin.setColor(Processing::Red);
testWin.display();
// Give Kinect time to get image w/ test pattern in it
std::this_thread::sleep_for(std::chrono::milliseconds(750));
gProjectorKnt.setCalibImage(Processing::Red);
testWin.setColor(Processing::Blue);
testWin.display();
// Give Kinect time to get image w/ test pattern in it
std::this_thread::sleep_for(std::chrono::milliseconds(750));
gProjectorKnt.setCalibImage(Processing::Blue);
gProjectorKnt.calibrate();
}
break;
}
case IDC_STREAMTOGGLE_BUTTON: {
// If button was pressed from video display window
if (handle == gProjectorKnt.getRegisteredVideoWindow()) {
if (gProjectorKnt.isVideoStreamRunning()) {
gProjectorKnt.stopVideoStream();
}
else {
gProjectorKnt.startVideoStream();
}
}
// If button was pressed from depth image display window
else if (handle == gProjectorKnt.getRegisteredDepthWindow()) {
if (gProjectorKnt.isDepthStreamRunning()) {
gProjectorKnt.stopDepthStream();
}
else {
gProjectorKnt.startDepthStream();
}
}
break;
}
case IDM_STARTTRACK: {
gProjectorKnt.setMouseTracking(true);
MessageBox(handle, "Mouse tracking has been enabled",
"Mouse Tracking", MB_ICONINFORMATION | MB_OK);
//.........这里部分代码省略.........