XnStatus DepthPanasonic::StartGenerating()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	m_bGenerating = TRUE;

	// start scheduler thread
	nRetVal = xnOSCreateThread(SchedulerThread, this, &m_hScheduler);
	if (nRetVal != XN_STATUS_OK)
	{
		m_bGenerating = FALSE;
		return (nRetVal);
	}

	m_generatingEvent.Raise();

	// Inicializa a câmera
	if  (InitImageDriver() != 0) {
		return XN_STATUS_DEVICE_NOT_CONNECTED;
	}

	// Define a frequência da luz (evitar interferênia com outras)
	if (Freqmode () != 1){
		ChangeFreq (1);
	}

	// Acorda a câmera
	if (Sleepmode () == 0){
		ChangeSleep (1);
	}

	return (XN_STATUS_OK);
}
Beispiel #2
0
XN_C_API XnStatus xnSchedulerStart(XnScheduler** ppScheduler)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XN_VALIDATE_OUTPUT_PTR(ppScheduler);

	*ppScheduler = NULL;

	// allocate handle
	XnScheduler* pScheduler = NULL;
	XN_VALIDATE_CALLOC(pScheduler, XnScheduler, 1);

	// create event
	nRetVal = xnOSCreateEvent(&pScheduler->hWakeThreadEvent, FALSE);
	XN_CHECK_RC_AND_FREE(nRetVal, pScheduler);

	// create critical section
	nRetVal = xnOSCreateCriticalSection(&pScheduler->hCriticalSection);
	XN_CHECK_RC_AND_FREE(nRetVal, pScheduler);

	// start thread
	nRetVal = xnOSCreateThread(xnSchedulerThreadFunc, (XN_THREAD_PARAM)pScheduler, &pScheduler->hThread);
	XN_CHECK_RC_AND_FREE(nRetVal, pScheduler);

	*ppScheduler = pScheduler;

	return (XN_STATUS_OK);
}
Beispiel #3
0
XnStatus xnUSBPlatformSpecificInit()
{
	xnLogVerbose(XN_MASK_USB, "Initializing USB...");

	// initialize the library
	int rc = libusb_init(&g_InitData.pContext);
	if (rc != 0)
	{
		return (XN_STATUS_USB_INIT_FAILED);
	}

	XnStatus nRetVal = xnOSCreateCriticalSection(&g_InitData.hLock);
	XN_IS_STATUS_OK(nRetVal);
	
#ifdef XN_USE_UDEV
	// initialize the UDEV Events thread
	g_bShouldRunUDEVThread = true;
	nRetVal = xnOSCreateThread(xnUSBUDEVEventsThread, NULL, &g_hUDEVThread);
	if (nRetVal != XN_STATUS_OK)
	{
		g_hUDEVThread = NULL;
		g_bShouldRunUDEVThread = false;
		// clean-up
		xnUSBPlatformSpecificShutdown();
		return nRetVal;
	}
#endif

	//libusb_set_debug(g_InitData.pContext, 3);

	xnLogInfo(XN_MASK_USB, "USB is initialized.");
	return (XN_STATUS_OK);	
}
Beispiel #4
0
XnStatus xnUSBAsynchThreadAddRef()
{
	XnStatus nRetVal = XN_STATUS_OK;

	xnl::AutoCSLocker locker(g_InitData.hLock);

	++g_InitData.nOpenDevices;
	
	if (g_InitData.hThread == NULL)
	{
		xnLogVerbose(XN_MASK_USB, "Starting libusb asynch thread...");
		
		// mark thread should run
		g_InitData.bShouldThreadRun = TRUE;
		
		// and start thread
		nRetVal = xnOSCreateThread(xnUSBHandleEventsThread, NULL, &g_InitData.hThread);
		if (nRetVal != XN_STATUS_OK)
		{
			// clean-up
			xnUSBPlatformSpecificShutdown();
			return nRetVal;
		}

		// set thread priority to critical
		nRetVal = xnOSSetThreadPriority(g_InitData.hThread, XN_PRIORITY_CRITICAL);
		if (nRetVal != 0)
		{
			xnLogWarning(XN_MASK_USB, "USB events thread: Failed to set thread priority to critical. This might cause loss of data...");
			printf("Warning: USB events thread - failed to set priority. This might cause loss of data...\n");
		}
	}
	
	return (XN_STATUS_OK);	
}
Beispiel #5
0
OniStatus Recorder::initialize(const char* fileName)
{
    m_fileName = fileName;

    // Probe if we can actually open the file.
    XN_FILE_HANDLE fileHandle = XN_INVALID_FILE_HANDLE;
    XnStatus status = xnOSOpenFile(
            /* file name  = */ fileName, 
            /* open flags = */ XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE, 
            /* out handle = */ &fileHandle);
    if (XN_STATUS_OK != status)
    {
        return ONI_STATUS_ERROR;
    }
    xnOSCloseFile(&fileHandle);

    m_assembler.initialize();   
    
    status = xnOSCreateThread(threadMain, this, &m_thread);
    if (XN_STATUS_OK != status)
    {
        return ONI_STATUS_ERROR;
    }
    
    send(Message::MESSAGE_INITIALIZE);
    return ONI_STATUS_OK;
}
Beispiel #6
0
XN_C_API XnStatus xnProfilingInit(XnUInt32 nProfilingInterval)
{
	XnStatus nRetVal = XN_STATUS_OK;

	if (nProfilingInterval == 0)
	{
		xnProfilingShutdown();
	}
	else if (!g_ProfilingData.bInitialized)
	{
		g_ProfilingData.nMaxSectionName = 0;
		g_ProfilingData.nSectionCount = 0;
		g_ProfilingData.nProfilingInterval = nProfilingInterval;
		g_ProfilingData.bKillThread = FALSE;

		XN_VALIDATE_CALLOC(g_ProfilingData.aSections, XnProfiledSection, MAX_PROFILED_SECTIONS);
		g_ProfilingData.nSectionCount = 0;

		nRetVal = xnOSCreateThread(xnProfilingThread, (XN_THREAD_PARAM)NULL, &g_ProfilingData.hThread);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = xnOSCreateCriticalSection(&g_ProfilingData.hCriticalSection);
		XN_IS_STATUS_OK(nRetVal);

		g_ProfilingData.bInitialized = TRUE;
	}

	return XN_STATUS_OK;
}
XnStatus XnServerSession::Init()
{
	XnStatus nRetVal = XN_STATUS_OK;

	nRetVal = m_privateIncomingPacker.Init();
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = m_privateOutgoingPacker.Init();
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = XnStreamDataSetCreate(&m_pStreamDataSet);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = xnOSCreateCriticalSection(&m_hCommLock);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = xnOSCreateCriticalSection(&m_hStreamsLock);
	XN_IS_STATUS_OK(nRetVal);

	// start thread
	nRetVal = xnOSCreateThread(ServeThreadCallback, this, &m_hThread);
	XN_IS_STATUS_OK(nRetVal);

	return (XN_STATUS_OK);
}
Beispiel #8
0
VideoStream::VideoStream(void* streamHandle, const OniSensorInfo* pSensorInfo, Device& device, const DriverHandler& libraryHandler, xnl::ErrorLogger& errorLogger) :
	m_errorLogger(errorLogger),
	m_pSensorInfo(NULL),
	m_running(true),
	m_device(device),
	m_driverHandler(libraryHandler),
	m_streamHandle(streamHandle),
	m_pContextNewFrameEvent(NULL),
	m_started(FALSE)
{
	xnOSCreateEvent(&m_newFrameInternalEvent, false);
	xnOSCreateEvent(&m_newFrameInternalEventForFrameHolder, false);
	xnOSCreateThread(newFrameThread, this, &m_newFrameThread);
	
	m_pSensorInfo = XN_NEW(OniSensorInfo);
	m_pSensorInfo->sensorType = pSensorInfo->sensorType;
	m_pSensorInfo->numSupportedVideoModes = pSensorInfo->numSupportedVideoModes;
	m_pSensorInfo->pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, m_pSensorInfo->numSupportedVideoModes);
	xnOSMemCopy(m_pSensorInfo->pSupportedVideoModes, pSensorInfo->pSupportedVideoModes, sizeof(OniVideoMode)*m_pSensorInfo->numSupportedVideoModes);

	m_driverHandler.streamSetNewFrameCallback(m_streamHandle, stream_NewFrame, this);
    m_driverHandler.streamSetPropertyChangedCallback(m_streamHandle, stream_PropertyChanged, this);

	refreshWorldConversionCache();
}
	OniStatus start()
	{
		m_osEvent.Create(TRUE);

		xnOSCreateThread(threadFunc, this, &m_threadHandle);

		return ONI_STATUS_OK;
	}
XnStatus XnVMessageListener::RunAsThread()
{
	XnStatus rc = xnOSCreateThread(MessageListenerThread, this, &m_hActivityThread);
	if (rc == XN_STATUS_OK)
	{
		m_bInternalThreadAlive = true;
	}
	return rc;
} // XnVMessageListener::RunAsThread
XnStatus XnServerSensorInvoker::Init(const XnChar* strDevicePath, const XnChar* strGlobalConfigFile, XnUInt32 nAdditionalProps, XnProperty** aAdditionalProps)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	nRetVal = m_sensor.SetGlobalConfigFile(strGlobalConfigFile);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = xnOSCreateCriticalSection(&m_hSensorLock);
	XN_IS_STATUS_OK(nRetVal);

	XnDeviceConfig config;
	config.DeviceMode = XN_DEVICE_MODE_READ;
	config.cpConnectionString = strDevicePath;
	config.pInitialValues = NULL;
	config.SharingMode = XN_DEVICE_SHARED;

	nRetVal = m_sensor.Init(&config);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = m_sensor.DeviceModule()->AddProperties(aAdditionalProps, nAdditionalProps);
	XN_IS_STATUS_OK(nRetVal);

	XnProperty* aInvokerAdditionalProps[] = { &m_numberOfBuffers, &m_allowOtherUsers };
	nRetVal = m_sensor.DeviceModule()->AddProperties(aInvokerAdditionalProps, sizeof(aInvokerAdditionalProps) / sizeof(aInvokerAdditionalProps[0]));
	XN_IS_STATUS_OK(nRetVal);

	// configure from global file
	nRetVal = m_sensor.ConfigureModuleFromGlobalFile(XN_MODULE_NAME_DEVICE, XN_SENSOR_SERVER_CONFIG_FILE_SECTION);
	XN_IS_STATUS_OK(nRetVal);

	// register to events
	XnCallbackHandle hDummy = NULL;
	nRetVal = m_sensor.OnStreamCollectionChangedEvent().Register(StreamCollectionChangedCallback, this, hDummy);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = m_sensor.OnNewStreamDataEvent().Register(NewStreamDataCallback, this, hDummy);
	XN_IS_STATUS_OK(nRetVal);

	// register to all properties
	XN_PROPERTY_SET_CREATE_ON_STACK(props);
	nRetVal = m_sensor.DeviceModule()->GetAllProperties(&props);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = RegisterToProps(&props);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = xnOSCreateEvent(&m_hNewDataEvent, FALSE);
	XN_IS_STATUS_OK(nRetVal);

	// start reader thread
	nRetVal = xnOSCreateThread(ReaderThread, this, &m_hReaderThread);
	XN_IS_STATUS_OK(nRetVal);
	
	return (XN_STATUS_OK);
}
Beispiel #12
0
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
XnStatus xnUSBPlatformSpecificInit()
{
	XnStatus nRetVal = XN_STATUS_OK;

	// give a unique class name (there might be multiple instances of this code in multiple DLLs)
	char className[MAX_PATH];
	sprintf_s(className, "xnUsbDeviceDetector%x", &g_xnUsbhModule);

	WNDCLASS wc;
	wc.style = 0;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = (HINSTANCE)g_xnUsbhModule;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = className;
	wc.lpfnWndProc = DevDetectWndProc;
	wc.hIcon = NULL;
	wc.hCursor = NULL;

	g_xnClass = RegisterClass(&wc);
	if (g_xnClass)
	{
		HANDLE hWaitEv = CreateEvent(NULL,FALSE,FALSE,NULL);
		g_bUsbDevDetectShoudRun = TRUE;
		nRetVal = xnOSCreateThread(DevDetectThread, hWaitEv, &g_xnUsbhPnThread);
		XN_IS_STATUS_OK(nRetVal);

		WaitForSingleObject(hWaitEv,INFINITE);
		CloseHandle(hWaitEv);
	}
	else
	{
		return (XN_STATUS_USB_FAILED_TO_REGISTER_CALLBACK);
	}

	DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
	ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) );
	NotificationFilter.dbcc_size =  sizeof(DEV_BROADCAST_DEVICEINTERFACE);
	NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
	NotificationFilter.dbcc_classguid = GUID_CLASS_PSDRV_USB;
	RegisterDeviceNotification(g_xnUsbhDevDetectWnd, &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);

	return (XN_STATUS_OK);
}
Beispiel #13
0
void kinectWeb::setup() {
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofLog(OF_LOG_VERBOSE, "Start setup()");
    
    // 画面の初期化
    ofSetFrameRate(30);
    ofBackground(255, 255, 255);
    ofSetWindowShape(640, 480);
    ofEnableSmoothing();    
    
    // ofxOpenNIの初期化
    context.setup();
    depthGenerator.setup(&context);
    imageGenerator.setup(&context);
    userGenerator.setup(&context);
    userGenerator.setUseMaskPixels(true);
    context.toggleRegisterViewport();
    context.toggleMirror();
    
#ifdef TARGET_OSX
    hardware.setup();
    hardware.setLedOption(LED_BLINK_GREEN);
#endif
    
    // メモリ確保
    grayPixels = new unsigned char[640 * 480];
    xnOSMemSet(grayPixels, 0, 640 * 480 * sizeof(unsigned char));
    saveImage.allocate(640, 480, OF_IMAGE_COLOR);
    
    // ソケットの初期化
    try {
        clients.bind("tcp://*:5555");
        ofLog(OF_LOG_NOTICE, "Open ZMQ Sokcet at 5555");
    } catch (zmq::error_t e) {
        ofLog(OF_LOG_ERROR, (string)e.what());
    }
    
    // 通信用ワーカースレッドの作成
    XnStatus rc = xnOSCreateThread(workerThread, 
                                   (XN_THREAD_PARAM)NULL, 
                                   &threadHandle); 
    if (rc != XN_STATUS_OK) {
        ofLog(OF_LOG_ERROR, xnGetStatusString(rc));
    }
}
Beispiel #14
0
XnStatus SampleDepth::StartGenerating()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	m_bGenerating = TRUE;

	// start scheduler thread
	nRetVal = xnOSCreateThread(SchedulerThread, this, &m_hScheduler);
	if (nRetVal != XN_STATUS_OK)
	{
		m_bGenerating = FALSE;
		return (nRetVal);
	}

	m_generatingEvent.Raise();

	return (XN_STATUS_OK);
}
	// Initialize the driver
	// ドライバを初期化する
	virtual OniStatus initialize(
		oni::driver::DeviceConnectedCallback connectedCallback,
		oni::driver::DeviceDisconnectedCallback disconnectedCallback,
		oni::driver::DeviceStateChangedCallback deviceStateChangedCallback,
		void* pCookie)
	{
		oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie);

		// Connect to the DepthSense device
		// DepthSense デバイスに接続する
		m_context = DepthSense::Context::create("localhost");

		// Enumerate the connected devices
		// 接続されているデバイスの情報を作成する
		m_depthSenseDevices = m_context.getDevices();
		int deviceIndex = 0;
		for ( auto it = m_depthSenseDevices.begin(); it != m_depthSenseDevices.end(); ++it ) {
			// Populate the device information
			// デバイス情報をコピーする
			OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo);
			xnOSStrCopy(pInfo->vendor, "DepthSense", ONI_MAX_STR);
			xnOSStrCopy(pInfo->name, DepthSense::Device::Model_toString( it->getModel() ).c_str(), ONI_MAX_STR);

			XnUInt32 uriLen;
			xnOSStrFormat(pInfo->uri, ONI_MAX_STR, &uriLen, "%s/%d", pInfo->name, deviceIndex++);

			// Register the device information with the map
			// デバイス情報を登録する
			m_devices[pInfo] = NULL;

			// Raise events
			// デバイスの接続を通知する
			deviceConnected(pInfo);
			deviceStateChanged(pInfo, 0);
		}

		// Create the thread for main loop
		// デバイスのメインループ用スレッドを生成する
		xnOSCreateThread(threadFunc, this, &m_threadHandle);

		return ONI_STATUS_OK;
	}
XnStatus SocketInConnection::Connect()
{
	XnStatus nRetVal = XN_STATUS_OK;
	Disconnect(); // In case we're already connected
	nRetVal = xnOSCreateThread(&ReadThreadProc, this, &m_hReadThread);
	XN_IS_STATUS_OK_LOG_ERROR("Create input socket read thread", nRetVal);
	xnLogVerbose(XN_MASK_LINK, "Waiting for connection on socket %u...", m_nPort);
	nRetVal = xnOSWaitEvent(m_hConnectEvent, CONNECT_TIMEOUT);
	XN_IS_STATUS_OK_LOG_ERROR("Wait for input socket to connect", nRetVal);
	if (m_nConnectionStatus != XN_STATUS_OK)
	{
		xnLogError(XN_MASK_LINK, "Failed to connect to socket %u: %s", m_nPort, xnGetStatusString(m_nConnectionStatus));
		XN_ASSERT(FALSE);
		return m_nConnectionStatus;
	}
	xnLogVerbose(XN_MASK_LINK, "Socket %u connected.", m_nPort);
	nRetVal = xnOSSetThreadPriority(m_hReadThread, XN_PRIORITY_CRITICAL);
	XN_IS_STATUS_OK_LOG_ERROR("Set read thread priority", nRetVal);
	return XN_STATUS_OK;
}
Beispiel #17
0
XnStatus XnSensorClient::InitImpl(const XnDeviceConfig* pDeviceConfig)
{
	XnStatus nRetVal = XN_STATUS_OK;
	XN_MUTEX_HANDLE hServerRunningMutex = NULL;
	XnOSEvent serverRunningEvent;

	nRetVal = serverRunningEvent.Open(XN_SENSOR_SERVER_RUNNING_EVENT_NAME);
	if (nRetVal != XN_STATUS_OK)
	{
		nRetVal = serverRunningEvent.Create(XN_SENSOR_SERVER_RUNNING_EVENT_NAME, TRUE);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to create server running event: %s", xnGetStatusString(nRetVal));
			return nRetVal;
		}
	}
	
	nRetVal = xnOSCreateNamedMutex(&hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_NAME);
	XN_IS_STATUS_OK(nRetVal);
	
	nRetVal = xnOSLockMutex(hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_TIMEOUT);
	if (nRetVal != XN_STATUS_OK)
	{
		xnOSCloseMutex(&hServerRunningMutex);
		return nRetVal;
	}

	XnBool bServerRunning = (serverRunningEvent.Wait(1) == XN_STATUS_OK);
	nRetVal = xnOSUnLockMutex(hServerRunningMutex);
	xnOSCloseMutex(&hServerRunningMutex);
	XN_IS_STATUS_OK(nRetVal);

	if (!bServerRunning)
	{
		nRetVal = StartServerProcess();
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to start server process: %s", xnGetStatusString(nRetVal));
			return nRetVal;
		}
	}

	nRetVal = serverRunningEvent.Wait(XN_SENSOR_CLIENT_WAIT_FOR_SERVER);
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to wait for server to start: %s", xnGetStatusString(nRetVal));
		return nRetVal;
	}

	// init network
	nRetVal = xnOSInitNetwork();
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = xnOSCreateCriticalSection(&m_hLock);
	XN_IS_STATUS_OK(nRetVal);

	// now init
	nRetVal = XnStreamReaderDevice::InitImpl(pDeviceConfig);
	if (nRetVal != XN_STATUS_OK)
	{
		xnOSCloseCriticalSection(&m_hLock);
		return nRetVal;
	}

	m_bConnected = TRUE;

	nRetVal = xnOSCreateEvent(&m_hReplyEvent, FALSE);
	if (nRetVal != XN_STATUS_OK)
	{
		xnOSCloseCriticalSection(&m_hLock);
		return nRetVal;
	}

	nRetVal = xnOSCreateThread(ListenThread, this, &m_hListenThread);
	if (nRetVal != XN_STATUS_OK)
	{
		xnOSCloseEvent(&m_hReplyEvent);
		xnOSCloseCriticalSection(&m_hLock);
		return nRetVal;
	}
	
	return (XN_STATUS_OK);
}
Beispiel #18
0
	OniStatus start()
	{
		xnOSCreateThread(threadFunc, this, &m_threadHandle);

		return ONI_STATUS_OK;
	}
Beispiel #19
0
OniStatus PlayerDevice::Initialize()
{
	static XnNodeNotifications notifications = 
	{
		OnNodeAdded,
		OnNodeRemoved,
		OnNodeIntPropChanged,
		OnNodeRealPropChanged,
		OnNodeStringPropChanged,
		OnNodeGeneralPropChanged,
		OnNodeStateReady,
		OnNodeNewData,
	};
	static XnPlayerInputStreamInterface inputInterface = 
	{
		FileOpen,
		FileRead,
		FileSeek,
		FileTell,
		FileClose,
		FileSeek64,
		FileTell64,
	};
	static PlayerNode::CodecFactory codecFactory = 
	{
		CodecCreate,
		CodecDestroy
	};

	// Initialize the player.
	XnStatus rc = m_player.Init();
	if (rc != XN_STATUS_OK)
	{
		return ONI_STATUS_ERROR;
	}

	// Set the notifications.
	rc = m_player.SetNodeNotifications(this, &notifications);
	if (rc != XN_STATUS_OK)
	{
		return ONI_STATUS_ERROR;
	}

	// Set the codec factory.
	rc = m_player.SetNodeCodecFactory(this, &codecFactory);
	if (rc != XN_STATUS_OK)
	{
		return ONI_STATUS_ERROR;
	}

	// Register to end of file reached event.
	XnCallbackHandle handle;
	rc = m_player.RegisterToEndOfFileReached(OnEndOfFileReached, this, handle);
	if (rc != XN_STATUS_OK)
	{
		return ONI_STATUS_ERROR;
	}

	// Set the input interface.
	rc = m_player.SetInputStream(this, &inputInterface);
	if (rc != XN_STATUS_OK)
	{
		return ONI_STATUS_ERROR;
	}

	// Create thread for running the player.
	XnStatus status = xnOSCreateThread(ThreadProc, this, &m_threadHandle);
	if (status != XN_STATUS_OK)
	{
		return ONI_STATUS_ERROR;
	}

	return ONI_STATUS_OK;
}