Exemplo n.º 1
0
static XnStatus GetOSName(xnOSInfo* pOSInfo)
{
	// Get OS Info
	OSVERSIONINFOEX osVersionInfo;
	osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

#pragma warning(push)
#pragma warning(disable:4996)
	if (0 == GetVersionEx((LPOSVERSIONINFO)&osVersionInfo))
#pragma warning(pop)
    {
		DWORD nErr = GetLastError();
		xnLogWarning(XN_MASK_OS, "Failed getting OS version information. Error code: %d", nErr);
		return XN_STATUS_ERROR;
	}

	sprintf(pOSInfo->csOSName, "%s", GetOSName(osVersionInfo));
	if (osVersionInfo.szCSDVersion[0] != '\0')
	{
		strcat(pOSInfo->csOSName, " ");
		strcat(pOSInfo->csOSName, osVersionInfo.szCSDVersion);
	}

	return XN_STATUS_OK;
}
void XnFrameStreamProcessor::FrameIsCorrupted()
{
	if (!m_bFrameCorrupted)
	{
		xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "%s frame is corrupt!", m_csName);
		m_bFrameCorrupted = TRUE;
	}
}
Exemplo n.º 3
0
void XN_CALLBACK_TYPE PlayerImpl::CloseFile(void* pCookie)
{
	PlayerImpl* pThis = (PlayerImpl*)pCookie;
	if (pThis == NULL)
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Got NULL cookie");
		return;
	}
	pThis->CloseFileImpl();
}
Exemplo n.º 4
0
XnStatus XnDeviceManagerLoadAllDevices()
{
	XnStatus nRetVal = XN_STATUS_OK;

	#define XN_DEVICE_INTERFACE_FUNCTION(name, sig) pDescriptor->Interface.name = XN_DEVICE_PROTO_NAME(name);

	XnDeviceDescriptor* pDescriptor = g_pDeviceManager->aDevices[g_pDeviceManager->nDevicesCount];

	#define XN_DEVICE_EXPORT_PREFIX SensorV2_
	#include <XnDeviceProto.inl>
	#undef XN_DEVICE_EXPORT_PREFIX

	nRetVal = XnDeviceManagerUpdateDefinition(pDescriptor);
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogWarning(XN_MASK_DEVICE_MANAGER, "'SensorV2' is not a valid device: %s", xnGetStatusString(nRetVal));
	}
	else
	{
		g_pDeviceManager->nDevicesCount++;
	}

	XnDeviceDescriptor* pDescriptor = g_pDeviceManager->aDevices[g_pDeviceManager->nDevicesCount];

	#define XN_DEVICE_EXPORT_PREFIX File_
	#include <XnDeviceProto.inl>
	#undef XN_DEVICE_EXPORT_PREFIX

	nRetVal = XnDeviceManagerUpdateDefinition(pDescriptor);
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogWarning(XN_MASK_DEVICE_MANAGER, "'SensorV2' is not a valid device: %s", xnGetStatusString(nRetVal));
	}
	else
	{
		g_pDeviceManager->nDevicesCount++;
	}

	#undef XN_DEVICE_INTERFACE_FUNCTION

	return (XN_STATUS_OK)
}
Exemplo n.º 5
0
XnStatus RecorderImpl::RemoveRawNode(const XnChar* strNodeName)
{
	if (!IsRawNode(strNodeName))
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Tried to remove non-existing raw node by the name of '%s'", strNodeName);
		XN_ASSERT(FALSE);
		return XN_STATUS_NO_MATCH;
	}

	return Notifications().OnNodeRemoved(ModuleHandle(), strNodeName);
}
Exemplo n.º 6
0
XnStatus RecorderImpl::NotifyRawNodeStateReady(const XnChar* strNodeName)
{
	if (!IsRawNode(strNodeName))
	{
		xnLogWarning(XN_MASK_OPEN_NI, "There is no node by the name of '%s'", strNodeName);
		XN_ASSERT(FALSE);
		return XN_STATUS_NO_MATCH;
	}
	
	return Notifications().OnNodeStateReady(ModuleHandle(), strNodeName);
}
Exemplo n.º 7
0
XnStatus RecorderImpl::SetRawNodeGeneralProp(const XnChar* strNodeName, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer)
{
	if (!IsRawNode(strNodeName))
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Tried to set property of non-existing node by the name of '%s'", strNodeName);
		XN_ASSERT(FALSE);
		return XN_STATUS_NO_MATCH;
	}

	return Notifications().OnNodeGeneralPropChanged(ModuleHandle(), strNodeName, strPropName, nBufferSize, pBuffer);
}
Exemplo n.º 8
0
XnStatus LinkContInputStream::Init(LinkControlEndpoint* pLinkControlEndpoint,
                                   XnStreamType streamType,
                                   XnUInt16 nStreamID, 
                                   IConnection* pConnection)
{
	XnStatus nRetVal = XN_STATUS_OK;
	if (m_hCriticalSection == NULL)
	{
		xnLogError(XN_MASK_INPUT_STREAM, "Cannot initialize - critical section was not created successfully");
		XN_ASSERT(FALSE);
		return XN_STATUS_ERROR;
	}

	xnl::AutoCSLocker csLock(m_hCriticalSection);
	if (m_bInitialized)
	{
		//We shutdown first so we can re-initialize.
		Shutdown();
	}

    nRetVal = LinkInputStream::Init(pLinkControlEndpoint, streamType, nStreamID, pConnection);
    XN_IS_STATUS_OK_LOG_ERROR("Init base input stream", nRetVal);

	m_nStreamID = nStreamID;
	m_nUserBufferMaxSize = CONT_STREAM_PREDEFINED_BUFFER_SIZE;
	m_nUserBufferCurrentSize = m_nWorkingBufferCurrentSize = 0;
	//Allocate buffers
	m_pUserBuffer = reinterpret_cast<XnUInt8*>(xnOSCallocAligned(1, m_nUserBufferMaxSize, XN_DEFAULT_MEM_ALIGN));
	if (m_pUserBuffer == NULL)
	{
		Shutdown();
		xnLogError(XN_MASK_INPUT_STREAM, "Failed to allocate buffer of size %u", m_nUserBufferMaxSize);
		XN_ASSERT(FALSE);
		return XN_STATUS_ALLOC_FAILED;
	}
	m_pWorkingBuffer = reinterpret_cast<XnUInt8*>(xnOSCallocAligned(1, CONT_STREAM_PREDEFINED_BUFFER_SIZE, XN_DEFAULT_MEM_ALIGN));
	if (m_pWorkingBuffer == NULL)
	{
		Shutdown();
		xnLogError(XN_MASK_INPUT_STREAM, "Failed to allocate buffer of size %u", m_nUserBufferMaxSize);
		XN_ASSERT(FALSE);
		return XN_STATUS_ALLOC_FAILED;
	}
	
    nRetVal = xnLinkGetStreamDumpName(m_nStreamID, m_strDumpName, sizeof(m_strDumpName));
    if (nRetVal != XN_STATUS_OK)
    {
        xnLogWarning(XN_MASK_INPUT_STREAM, "Failed to get stream dump name: %s", xnGetStatusString(nRetVal));
        XN_ASSERT(FALSE);
    }

    m_bInitialized = TRUE;
	return XN_STATUS_OK;
}
Exemplo n.º 9
0
void LinkContInputStream::SetDumpName(const XnChar* strDumpName)
{
    XnStatus nRetVal = XN_STATUS_OK;
    (void)nRetVal;
    nRetVal = xnOSStrCopy(m_strDumpName, strDumpName, sizeof(m_strDumpName));
    if (nRetVal != XN_STATUS_OK)
    {
        xnLogWarning(XN_MASK_INPUT_STREAM, "Failed to set dump name: %s", xnGetStatusString(nRetVal));
        XN_ASSERT(FALSE);
    }
}
Exemplo n.º 10
0
PlayerNode::PlayerNodeInfo* PlayerNode::GetPlayerNodeInfo(XnUInt32 nNodeID)
{
	if (nNodeID >= m_nMaxNodes)
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Got node ID %u, bigger than said max of %u", nNodeID, m_nMaxNodes);
		XN_ASSERT(FALSE);
		return NULL;
	}

	return &m_pNodeInfoMap[nNodeID];
}
Exemplo n.º 11
0
XnStatus RecorderImpl::SetRawNodeNewData(const XnChar* strNodeName, XnUInt64 nTimeStamp, XnUInt32 nFrame, const void* pData, XnUInt32 nSize)
{
	if (!IsRawNode(strNodeName))
	{
		xnLogWarning(XN_MASK_OPEN_NI, "There is no node by the name of '%s'", strNodeName);
		XN_ASSERT(FALSE);
		return XN_STATUS_NO_MATCH;
	}

	return Notifications().OnNodeNewData(ModuleHandle(), strNodeName, nTimeStamp, nFrame, pData, nSize);
}
Exemplo n.º 12
0
XN_C_API XnStatus xnOSGetModulePathForProcAddress(void* procAddr, XnChar *strModulePath)
{
	Dl_info info;
	if (!dladdr(procAddr, &info))
	{
		xnLogWarning(XN_MASK_OS, "Failed to get the dl info: %s\n", dlerror());
		return XN_STATUS_ERROR;
	}

	return xnOSStrCopy(strModulePath, info.dli_fname, XN_FILE_MAX_PATH);
}
Exemplo n.º 13
0
void LinkContInputStream::SetDumpOn(XnBool bDumpOn)
{
    XnStatus nRetVal = XN_STATUS_OK;
    (void)nRetVal;
    
    nRetVal = xnDumpSetMaskState(m_strDumpName, bDumpOn);
    if (nRetVal != XN_STATUS_OK)
    {
        xnLogWarning(XN_MASK_INPUT_STREAM, "Failed to set dump state: %s", xnGetStatusString(nRetVal));
        XN_ASSERT(FALSE);
    }
}
Exemplo n.º 14
0
void XnImageProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader)
{
	XnUInt32 nExpectedSize = CalculateExpectedSize();
	if (GetWriteBuffer()->GetSize() != nExpectedSize)
	{
		xnLogWarning(XN_MASK_SENSOR_READ, "Read: Image buffer is corrupt. Size is %u (!= %u)", GetWriteBuffer()->GetSize(), nExpectedSize);
		FrameIsCorrupted();
	}

	// call base
	XnFrameStreamProcessor::OnEndOfFrame(pHeader);
}
Exemplo n.º 15
0
static XnBool xnIsNodeMatch(XnContext* pContext, const XnNodeQuery* pQuery, XnNodeInfo* pNodeInfo)
{
	// check existing node
	XnNodeHandle hNode = xnNodeInfoGetRefHandle(pNodeInfo);
	if (pQuery->bExistingNodeOnly && (hNode == NULL))
	{
		return (FALSE);
	}

	if (pQuery->bNonExistingNodeOnly && (hNode != NULL))
	{
		return (FALSE);
	}

	if (!xnIsInfoQueryMatch(pQuery, pNodeInfo))
	{
		if (hNode != NULL)
		{
			xnProductionNodeRelease(hNode);
		}

		return (FALSE);
	}

	// check if we need to create an instance, to check capabilities
	if (pQuery->nSupportedCapabilities > 0 ||
		pQuery->nSupportedMapOutputModes > 0 ||
		pQuery->nMinUserPositions > 0)
	{
		if (hNode == NULL)
		{
			const XnProductionNodeDescription* pDescription = xnNodeInfoGetDescription(pNodeInfo);
			xnLogVerbose(XN_MASK_OPEN_NI, "Creating node '%s' of type '%s' for querying...", pDescription->strName, xnProductionNodeTypeToString(pDescription->Type));
			XnStatus nRetVal = xnCreateProductionTree(pContext, pNodeInfo, &hNode);
			if (nRetVal != XN_STATUS_OK)
			{
				xnLogWarning(XN_MASK_OPEN_NI, "Failed to create node of type '%s' for querying: %s", xnProductionNodeTypeToString(pDescription->Type), xnGetStatusString(nRetVal));
				return (FALSE);
			}
		}
	}

	XnBool bResult = xnIsNodeInstanceMatch(pQuery, hNode);

	// in any case, we need to release the node. if we created it, this will cause it to be destroyed. If we just took
	// a reference to it, we need to release it.
	if (hNode != NULL)
	{
		xnProductionNodeRelease(hNode);
	}

	return (bResult);
}
Exemplo n.º 16
0
void XnSensorServer::ShutdownServer()
{
	XnStatus nRetVal = XN_STATUS_OK;

	XnAutoMutexLocker serverRunningLock(m_hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_TIMEOUT);
	nRetVal = serverRunningLock.GetStatus();
	if (nRetVal != XN_STATUS_OK)
	{
		//This could mean there's another server/client that's frozen and they're jamming the mutex...
		xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to lock server mutex: %s - proceeding with shutdown.", xnGetStatusString(nRetVal));
		XN_ASSERT(FALSE);
	}

	if (m_hServerRunningEvent != NULL)
	{
		nRetVal = xnOSResetEvent(m_hServerRunningEvent);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to reset sensor server event: %s - proceeding with shutdown.", xnGetStatusString(nRetVal));
			XN_ASSERT(FALSE);
		}

		xnOSCloseEvent(&m_hServerRunningEvent);
		m_hServerRunningEvent = NULL;
	}

	XN_ASSERT(m_sessions.IsEmpty());

	if (m_hListenSocket != NULL)
	{
		xnOSCloseSocket(m_hListenSocket);
		m_hListenSocket = NULL;
	}

	if (m_hSessionsLock != NULL)
	{
		xnOSCloseCriticalSection(&m_hSessionsLock);
		m_hSessionsLock = NULL;
	}
}
Exemplo n.º 17
0
XN_C_API XnStatus xnSchedulerAddTask(XnScheduler* pScheduler, XnUInt64 nInterval, XnTaskCallbackFuncPtr pCallback, void* pCallbackArg, XnScheduledTask** ppTask)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XN_VALIDATE_INPUT_PTR(pScheduler);
	XN_VALIDATE_INPUT_PTR(pCallback);
	XN_VALIDATE_OUTPUT_PTR(ppTask);

	// create node
	XnScheduledTask* pTask;
	XN_VALIDATE_ALLOC(pTask, XnScheduledTask);

	pTask->nInterval = nInterval;
	pTask->pCallback = pCallback;
	pTask->pCallbackArg = pCallbackArg;

	// calculate next execution
	XnUInt64 nNow;
	xnOSGetTimeStamp(&nNow);
	pTask->nNextTime = nNow + nInterval;
	pTask->pNextTask = NULL;

	// enter critical section
	nRetVal = xnOSEnterCriticalSection(&pScheduler->hCriticalSection);
	if (nRetVal != XN_STATUS_OK)
	{
		xnOSFree(pTask);
		return (nRetVal);
	}

	xnSchedulerAddTaskInternal(pScheduler, pTask);

	// leave critical section
	nRetVal = xnOSLeaveCriticalSection(&pScheduler->hCriticalSection);
	if (nRetVal != XN_STATUS_OK)
	{
		xnOSFree(pTask);
		return (nRetVal);
	}

	// notify that the list has changed
	nRetVal = xnOSSetEvent(pScheduler->hWakeThreadEvent);
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogWarning(XN_MASK_SCHEDULER, "Failed setting event when adding task: %s", xnGetStatusString(nRetVal));
	}

	*ppTask = pTask;

	return (XN_STATUS_OK);
}
Exemplo n.º 18
0
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
XnVideoSource::XnVideoSource(LPUNKNOWN lpunk, HRESULT *phr) :
    CSource(g_videoName, lpunk, CLSID_OpenNIVideo),
    m_pVideoProcAmp(NULL),
    m_pCameraControl(NULL),
    m_Dump(xnDumpFileOpen(XN_MASK_FILTER, "FilterFlow.log"))
{
    ASSERT(phr != NULL);

    xnLogVerbose(XN_MASK_FILTER, "Creating video source filter");

    CAutoLock cAutoLock(&m_cStateLock);

    // initialize OpenNI
    XnStatus nRetVal = m_context.Init();
    if (nRetVal != XN_STATUS_OK)
    {
        xnLogWarning(XN_MASK_FILTER, "Can't init context");
        *phr = E_UNEXPECTED;
    }

    // try to create an image generator
    nRetVal = m_image.Create(m_context);
    if (nRetVal != XN_STATUS_OK)
    {
        xnLogWarning(XN_MASK_FILTER, "Can't create image generator");
        *phr = VFW_E_NO_CAPTURE_HARDWARE;
        return;
    }

    // create output pins. Every pin registers itself with the source object
    XnVideoStream* pStream = new XnVideoStream(phr, this, m_image, L"VideoOut");
    if (pStream == NULL)
    {
        *phr = E_OUTOFMEMORY;
    }

    *phr = NOERROR;
}
Exemplo n.º 19
0
void ClientUSBInDataEndpoint::Disconnect()
{
	XnStatus nRetVal = XN_STATUS_OK;
	if (m_bConnected)
	{
		nRetVal = xnUSBShutdownReadThread(m_hEndpoint);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogWarning("Failed to shutdown usb read thread: %s", xnGetStatusString(nRetVal));
			XN_ASSERT(FALSE);
		}
		m_bConnected = FALSE;
	}
}
Exemplo n.º 20
0
void LinkOniStream::stop()
{
	if (m_started)
	{
		m_started = FALSE;

		XnStatus nRetVal = m_pInputStream->Stop();
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogWarning(XN_MASK_LINK_STREAM, "Failed to stop streaming: %s", xnGetStatusString(nRetVal));
			XN_ASSERT(FALSE);
		}
	}
}
Exemplo n.º 21
0
XnStatus RecorderImpl::WriteFileImpl(const XnChar* strNodeName, 
									 const void* pData, 
									 XnUInt32 nSize)
{
	//strNodeName may be NULL
	XN_VALIDATE_PTR(m_pOutFile, XN_STATUS_ERROR);
	size_t nBytesWritten = fwrite(pData, 1, nSize, m_pOutFile);
	if (nBytesWritten < nSize)
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Written only %u bytes out of %u to file", nBytesWritten, nSize);
		return XN_STATUS_OS_FILE_WRITE_FAILED;
	}
	return XN_STATUS_OK;
}
void SocketInConnection::Disconnect()
{
	XnStatus nRetVal = XN_STATUS_OK;
	if (m_hReadThread != NULL)
	{
		m_bStopReadThread = TRUE; //Signal read thread to stop running
		nRetVal = xnOSWaitAndTerminateThread(&m_hReadThread, READ_THREAD_TERMINATE_TIMEOUT);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogWarning("Failed to terminate input socket read thread: %s", xnGetStatusString(nRetVal));
			XN_ASSERT(FALSE);
		}
		m_bStopReadThread = FALSE;
	}
}
Exemplo n.º 23
0
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
XN_C_API XnStatus xnOSLoadLibrary(const XnChar* cpFileName, XN_LIB_HANDLE* pLibHandle)
{
	// Validate the input/output pointers (to make sure none of them is NULL)
	XN_VALIDATE_INPUT_PTR(cpFileName);
	XN_VALIDATE_OUTPUT_PTR(pLibHandle);

#ifndef XN_PLATFORM_ANDROID_OS
	// Resolve the file name to the absolute path. This is necessary because
	// we need to get the absolute path of this library by dladdr() later.
	// Note dladdr() seems to return the path specified to dlopen() "as it is".
	XnChar* strAbsoluteFileName = realpath(cpFileName, NULL);
	if (strAbsoluteFileName == NULL)
	{
		// error
		xnLogWarning(XN_MASK_OS, "Failed to get absolute path for lib: %s\n", cpFileName);
		return XN_STATUS_OS_CANT_LOAD_LIB;
	}

	// Load the requested shared library via the OS
	*pLibHandle = dlopen(strAbsoluteFileName, RTLD_NOW);

	free(strAbsoluteFileName); // Don't forget to free the memory allocated by realpath().
#else
	*pLibHandle = dlopen(cpFileName, RTLD_NOW);
#endif

	// Make sure it succeeded (return value is not NULL). If not return an error....
	if (*pLibHandle == NULL)
	{
		xnLogWarning(XN_MASK_OS, "Failed loading lib: %s\n", dlerror());
		return XN_STATUS_OS_CANT_LOAD_LIB;
	}

	// All is good...
	return (XN_STATUS_OK);
}
Exemplo n.º 24
0
HRESULT XnVideoStream::Active( void )
{
	XN_METHOD_START;

	XnStatus nRetVal = m_imageGen.StartGenerating();
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogWarning(XN_MASK_FILTER, "Can't start ImageGenerator: %s", xnGetStatusString(nRetVal));
		XN_METHOD_RETURN(E_UNEXPECTED);
	}

	HRESULT hr = CSourceStream::Active();

	XN_METHOD_RETURN(hr);
}
Exemplo n.º 25
0
void XN_CALLBACK_TYPE MapWatcher::HandleCroppingChange(ProductionNode& /*node*/, void* pCookie)
{
	MapWatcher *pThis = (MapWatcher*)pCookie;
	if (pThis == NULL)
	{
		XN_ASSERT(FALSE);
		return;
	}
	XnStatus nRetVal = pThis->NotifyCropping();
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Failed to notify output mode: %s", xnGetStatusString(nRetVal));
		XN_ASSERT(FALSE);
	}
}
Exemplo n.º 26
0
XnStatus XnDeviceManagerLoadAllDevices(const XnChar* strDir)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XnChar cpSearchString[XN_FILE_MAX_PATH] = "";

	if (strDir == NULL)
	{
		strDir = XN_FILE_LOCAL_DIR;
	}

	// Build the search pattern string
	XN_VALIDATE_STR_APPEND(cpSearchString, strDir, XN_FILE_MAX_PATH, nRetVal);
	XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_DIR_SEP, XN_FILE_MAX_PATH, nRetVal);
	XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_PREFIX, XN_FILE_MAX_PATH, nRetVal);
	XN_VALIDATE_STR_APPEND(cpSearchString, XN_DEVICE_FILE_PREFIX, XN_FILE_MAX_PATH, nRetVal);
	XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_ALL_WILDCARD, XN_FILE_MAX_PATH, nRetVal);
	XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_POSTFIX, XN_FILE_MAX_PATH, nRetVal);

	// Get a file list of Xiron devices
	XnChar acsFileList[XN_DEVICE_MANAGER_MAX_NUMBER_OF_DEVICES][XN_FILE_MAX_PATH];
	XnUInt32 nFileCount = 0;

	xnLogVerbose(XN_MASK_DEVICE_MANAGER, "Searching for %s...", cpSearchString);
	nRetVal = xnOSGetFileList(cpSearchString, NULL, acsFileList, XN_DEVICE_MANAGER_MAX_NUMBER_OF_DEVICES, &nFileCount);
	if ((nRetVal != XN_STATUS_OS_FILE_NOT_FOUND) && (nRetVal != XN_STATUS_OK))
	{
		return (nRetVal);
	}

	// now try to load each file
	for (XnUInt32 nIndex = 0; nIndex < nFileCount; ++nIndex)
	{
		xnLogVerbose(XN_MASK_DEVICE_MANAGER, "Trying to load a device '%s'...", acsFileList[nIndex]);
		nRetVal = XnDeviceManagerLoadDevice(acsFileList[nIndex], &g_pDeviceManager->aDevices[g_pDeviceManager->nDevicesCount]);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogWarning(XN_MASK_DEVICE_MANAGER, "'%s' is not a valid device: %s", acsFileList[nIndex], xnGetStatusString(nRetVal));
		}
		else
		{
			xnLogInfo(XN_MASK_DEVICE_MANAGER, "device '%s' loaded.", acsFileList[nIndex]);
			g_pDeviceManager->nDevicesCount++;
		}
	}

	return (XN_STATUS_OK);
}
Exemplo n.º 27
0
void xnDumpCreate(XnDump* pDump, const XnChar* csHeader, const XnChar* csFileNameFormat, va_list args)
{
	XnChar strFileName[XN_FILE_MAX_PATH];
	xnDumpCreateFileNameImpl(strFileName, csFileNameFormat, args);

	if (XN_STATUS_OK != xnLogCreateFile(strFileName, &pDump->hFile))
	{
		// we don't have much to do if files can't be open. Dump will not be written
		xnLogWarning(XN_MASK_LOG, "Couldn't create dump file %s! Dump will not be written", strFileName);
	}

	if (csHeader != NULL)
	{
		xnDumpWriteStringImpl(*pDump, csHeader);
	}
}
Exemplo n.º 28
0
void XN_CALLBACK_TYPE DepthWatcher::HandleFieldOfViewChange(ProductionNode& /*node*/, void* pCookie)
{
	DepthWatcher *pThis = (DepthWatcher*)pCookie;
	if (pThis == NULL)
	{
		XN_ASSERT(FALSE);
		return;
	}

	XnStatus nRetVal = pThis->NotifyFieldOfView();
	if (nRetVal != XN_STATUS_OK)
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Failed to notify field of view: %s", xnGetStatusString(nRetVal));
		XN_ASSERT(FALSE);
	}
}
Exemplo n.º 29
0
void XN_CALLBACK_TYPE DepthWatcher::HandleUserPositionChange(ProductionNode& /*node*/, void* pCookie)
{
	DepthWatcher *pThis = (DepthWatcher*)pCookie;
	if (pThis == NULL)
	{
		XN_ASSERT(FALSE);
		return;
	}

	XnStatus nRetVal = pThis->NotifyUserPositions();
	if ((nRetVal != XN_STATUS_OK) && (nRetVal != XN_STATUS_NOT_IMPLEMENTED))
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Failed to notify user positions: %s", xnGetStatusString(nRetVal));
		XN_ASSERT(FALSE);
	}
}
Exemplo n.º 30
0
XnStatus PlayerImpl::OpenFileImpl()
{
	if (m_pInFile != NULL)
	{
		//Already open
		return XN_STATUS_OK;
	}
	
	m_pInFile = fopen(m_strSource, "rb");
	if (m_pInFile == NULL)
	{
		xnLogWarning(XN_MASK_OPEN_NI, "Failed to open file '%s' for reading", m_strSource);
		return XN_STATUS_OS_FILE_NOT_FOUND;
	}

	return XN_STATUS_OK;
}