示例#1
0
void main(int argc, char* argv[])
{
    try{
        auto status = nite::NiTE::initialize();
        nite::UserTracker userTracker;
        status = userTracker.create();
        if ( status != nite::STATUS_OK ) {
            throw std::runtime_error( "userTracker.create" );
        }
        
        cv::Mat depthImage;

        while ( 1 ) {
            nite::UserTrackerFrameRef userFrame;
            userTracker.readFrame( &userFrame );

            depthImage = depthToImage( userFrame );
            drawUser( userFrame, depthImage );
            drawSkeleton( userFrame, userTracker, depthImage);
            cv::imshow( "User", depthImage );

            int key = cv::waitKey( 10 );
            if ( key == 'q' || key == 0x1b ) {
                break;
            }
        }
    }
    catch(std::exception&){
        std::cout << openni::OpenNI::getExtendedError() << std::endl;
    }
}
//----------------------------------------
void ofxOpenNITracker::draw(){
	ofPushStyle();
	// show green/red circle if any one is found
	if (tracked_users_index.size() > 0) {

		// draw all the users
		for(int i = 0;  i < (int)tracked_users_index.size(); ++i) {
			drawUser(i);
		}

	}
	ofPopStyle();
}
// Draw all the found users.
//----------------------------------------
void ofxUserGenerator::draw( ) {
	
	// show green/red circle if any one is found
	if (found_users > 0) {
		
		// draw all the users
		for(int i = 0;  i < found_users; ++i) {
			drawUser(i);
		}
		
		glColor3f(0, 1.0f, 0);
		
	} else glColor3f(1.0f, 0, 0);
	
	ofCircle(10, 10, 10);
	
	// reset to white for simplicity
	glColor3f(1.0f, 1.0f, 1.0f);
	
}
示例#4
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	int move = 30;

	switch (message)
	{
	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		switch (wmId)
		{
		case ID_FILE_NEW:
			gameOver();//Runs gameOver, so gameover gets set to false, and starts our game over.
			break;
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		DrawEnclosure(hWnd, hdc);//Draws our background, and Rectangle enclosure.
		DrawBlocks(hWnd, hdc);//Draws falling blocks and checks for collisions.
		drawUser(hWnd, hdc);//Draws the user's block.
		drawTitle(hWnd, hdc);//Draws the level, and updates the speed of the falling block.
		EndPaint(hWnd, &ps);
		break;
	case WM_TIMER:
		InvalidateRect(hWnd, NULL, true);
		break;

	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_LEFT://If the left arrow key is pressed.
			moveLeft();//Moves the user's block left.
			break;

		case VK_RIGHT://If the right arrow key is pressed.
			moveRight();//Moves the user's block right.
			break;
		}
		InvalidateRect(hWnd, NULL, TRUE);
		UpdateWindow(hWnd);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}