Exemple #1
0
//--------------------------------------------------------------
void testApp::draw()
{
	//depth.draw(0,0,320,240);
	//user.draw();
	image.draw(0, 0, 640, 480);
	
	ofxTrackedUser* tracked = user.getTrackedUser(0);
	if(tracked != NULL) 
	{
		tracked->debugDraw();
		
		int xl = tracked->left_lower_arm.end.x;
		int yl = tracked->left_lower_arm.end.y;
		
		int xr = tracked->right_lower_arm.end.x;
		int yr = tracked->right_lower_arm.end.y;
		
		int xh = tracked->neck.begin.x;
		int yh = tracked->neck.begin.y;
		
		ofSetColor(255, 255, 255);
		hands.draw(xl, yl);
		hands.draw(xr, yr);
		
		head.draw(xh, yh);
		
		XnUSBDeviceSpeed* pDevSpeed;
		xnUSBGetDeviceSpeed(usbhandle, pDevSpeed);
		
		char rstr[1024];
		sprintf(rstr, "DEV SPEED: %d", (int)pDevSpeed);
		ofDrawBitmapString(rstr, 400,400);		
		xnUSBCloseDevice(usbhandle);
	}
}
Exemple #2
0
void Device::Close()
{
    if (isOpened) {
        for (XnUInt32 index = 0; index < num; ++index) {
            xnUSBCloseDevice(devices[index]);
        }
        isOpened = false;
    }
}
	void OpenNIMotorController::Release()
	{
		if( m_bOpened )
		{
			SetLED( LED_BLINK_GREEN );
			xnUSBCloseDevice( m_xDevice );
			m_bOpened = false;
		}
	}
XnStatus XnSensorIO::CloseDevice()
{
	XnStatus nRetVal;

	xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Shutting down USB depth read thread...");
	xnUSBShutdownReadThread(m_pSensorHandle->DepthConnection.UsbEp);

	if (m_pSensorHandle->DepthConnection.UsbEp != NULL)
	{
		nRetVal = xnUSBCloseEndPoint(m_pSensorHandle->DepthConnection.UsbEp);
		XN_IS_STATUS_OK(nRetVal);
		m_pSensorHandle->DepthConnection.UsbEp = NULL;
	}

	xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Shutting down USB image read thread...");
	xnUSBShutdownReadThread(m_pSensorHandle->ImageConnection.UsbEp);

	if (m_pSensorHandle->ImageConnection.UsbEp != NULL)
	{
		nRetVal = xnUSBCloseEndPoint(m_pSensorHandle->ImageConnection.UsbEp);
		XN_IS_STATUS_OK(nRetVal);
		m_pSensorHandle->ImageConnection.UsbEp = NULL;
	}

	if (m_pSensorHandle->MiscConnection.bIsOpen)
	{
		xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Shutting down USB misc read thread...");
		xnUSBShutdownReadThread(m_pSensorHandle->MiscConnection.UsbEp);

		if (m_pSensorHandle->MiscConnection.UsbEp != NULL)
		{
			nRetVal = xnUSBCloseEndPoint(m_pSensorHandle->MiscConnection.UsbEp);
			XN_IS_STATUS_OK(nRetVal);
			m_pSensorHandle->MiscConnection.UsbEp = NULL;
		}
	}

	if (m_pSensorHandle->ControlConnection.bIsBulk)
	{
		if (m_pSensorHandle->ControlConnection.ControlInConnectionEp != NULL)
		{
			nRetVal = xnUSBCloseEndPoint(m_pSensorHandle->ControlConnection.ControlInConnectionEp);
			XN_IS_STATUS_OK(nRetVal);
			m_pSensorHandle->ControlConnection.ControlInConnectionEp = NULL;
		}

		if (m_pSensorHandle->ControlConnection.ControlOutConnectionEp != NULL)
		{
			nRetVal = xnUSBCloseEndPoint(m_pSensorHandle->ControlConnection.ControlOutConnectionEp);
			XN_IS_STATUS_OK(nRetVal);
			m_pSensorHandle->ControlConnection.ControlOutConnectionEp = NULL;
		}
	}

	if (m_pSensorHandle->USBDevice != NULL)
	{
		nRetVal = xnUSBCloseDevice(m_pSensorHandle->USBDevice);
		XN_IS_STATUS_OK(nRetVal);
		m_pSensorHandle->USBDevice = NULL;
	}

	xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Device closed successfully");

	// All is good...
	return (XN_STATUS_OK);
}