void TextureMapInit(XnTextureMap* pTex, int nSizeX, int nSizeY, unsigned int nBytesPerPixel, int nCurX, int nCurY) { // check if something changed if (pTex->bInitialized && pTex->OrigSize.X == nSizeX && pTex->OrigSize.Y == nSizeY) { if (pTex->CurSize.X != nCurX || pTex->CurSize.Y != nCurY) { // clear map xnOSMemSet(pTex->pMap, 0, pTex->Size.X * pTex->Size.Y * pTex->nBytesPerPixel); // update pTex->CurSize.X = nCurX; pTex->CurSize.Y = nCurY; return; } } // free memory if it was allocated if (pTex->pMap != NULL) { delete[] pTex->pMap; pTex->pMap = NULL; } // update it all pTex->OrigSize.X = nSizeX; pTex->OrigSize.Y = nSizeY; pTex->Size.X = GetPowerOfTwo(nSizeX); pTex->Size.Y = GetPowerOfTwo(nSizeY); pTex->nBytesPerPixel = nBytesPerPixel; pTex->CurSize.X = nCurX; pTex->CurSize.Y = nCurY; pTex->pMap = new unsigned char[pTex->Size.X * pTex->Size.Y * nBytesPerPixel]; xnOSMemSet(pTex->pMap, 0, pTex->Size.X * pTex->Size.Y * nBytesPerPixel); if (!pTex->bInitialized) { glGenTextures(1, &pTex->nID); glBindTexture(GL_TEXTURE_2D, pTex->nID); switch (pTex->nBytesPerPixel) { case 3: pTex->nFormat = GL_RGB; break; case 4: pTex->nFormat = GL_RGBA; break; } glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); pTex->bInitialized = TRUE; } }
MockMapGenerator::MockMapGenerator(const XnChar* strName) : MockGenerator(strName), m_nSupportedMapOutputModesCount(0), m_bSupportedMapOutputModesCountReceived(0), m_pSupportedMapOutputModes(NULL) { xnOSMemSet(&m_mapOutputMode, 0, sizeof(m_mapOutputMode)); xnOSMemSet(&m_cropping, 0, sizeof(m_cropping)); }
XnStatus XnSensorDepthStream::PopulateSensorCalibrationInfo() { XnDouble dPlanePixelSize; GetProperty(XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, &dPlanePixelSize); XnUInt64 nPlaneDsr; GetProperty(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, &nPlaneDsr); XnDouble dDCRCDist; GetProperty(XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE, &dDCRCDist); m_calibrationInfo.magic = ONI_DEPTH_UTILS_CALIBRATION_INFO_MAGIC; m_calibrationInfo.version = 1; m_calibrationInfo.params1080.zpd = (int)nPlaneDsr; m_calibrationInfo.params1080.zpps = dPlanePixelSize; m_calibrationInfo.params1080.dcrcdist = dDCRCDist; xnOSStrCopy(m_calibrationInfo.deviceName, "PS1080", 80); xnOSMemSet(m_calibrationInfo.serial, 0, 80); m_calibrationInfo.params1080.rgbRegXRes = RGB_REG_X_RES; m_calibrationInfo.params1080.rgbRegYRes = RGB_REG_Y_RES; m_calibrationInfo.params1080.cmosVGAOutputXRes = XN_CMOS_VGAOUTPUT_XRES; m_calibrationInfo.params1080.sensorWinOffsetX = XN_SENSOR_WIN_OFFET_X; m_calibrationInfo.params1080.sensorWinOffsetY = XN_SENSOR_WIN_OFFET_Y; m_calibrationInfo.params1080.rgbRegXValScale = RGB_REG_X_VAL_SCALE; m_calibrationInfo.params1080.s2dPelConst = S2D_PEL_CONST; m_calibrationInfo.params1080.s2dConstOffset = S2D_CONST_OFFSET; XnStatus nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &m_calibrationInfo.params1080.registrationInfo_QQVGA, sizeof(m_calibrationInfo.params1080.registrationInfo_QQVGA), XN_RESOLUTION_QQVGA, 30); if (nRetVal != XN_STATUS_OK) { xnOSMemSet(&m_calibrationInfo.params1080.registrationInfo_QQVGA, 0, sizeof(m_calibrationInfo.params1080.registrationInfo_QQVGA)); } nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &m_calibrationInfo.params1080.registrationInfo_QVGA, sizeof(m_calibrationInfo.params1080.registrationInfo_QVGA), XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &m_calibrationInfo.params1080.registrationInfo_VGA, sizeof(m_calibrationInfo.params1080.registrationInfo_VGA), XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_calibrationInfo.params1080.padInfo_QQVGA, sizeof(m_calibrationInfo.params1080.padInfo_QQVGA), XN_RESOLUTION_QQVGA, 30); if (nRetVal != XN_STATUS_OK) { xnOSMemSet(&m_calibrationInfo.params1080.padInfo_QQVGA, 0, sizeof(m_calibrationInfo.params1080.padInfo_QQVGA)); } xnOSMemSet(&m_calibrationInfo.params1080.padInfo_QVGA, 0, sizeof(m_calibrationInfo.params1080.padInfo_QVGA)); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_calibrationInfo.params1080.padInfo_QVGA, sizeof(m_calibrationInfo.params1080.padInfo_QVGA), XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); xnOSMemSet(&m_calibrationInfo.params1080.padInfo_VGA, 0, sizeof(m_calibrationInfo.params1080.padInfo_VGA)); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_calibrationInfo.params1080.padInfo_VGA, sizeof(m_calibrationInfo.params1080.padInfo_VGA), XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
void SceneDrawer::DrawLabels(XnUserID nUserId) { #ifndef USE_GLES char strUserLabel[MAX_USER_LABEL_LEN] = ""; char strOutputLabel[MAX_ID_LABEL_LEN] = ""; XnFloat color[3]; XnPoint3D com; xnOSMemSet(strOutputLabel, 0, sizeof(strOutputLabel)); XnStatus res=m_pUserTrackerObj->GetUserColor(nUserId,color); XnFloat userExitPose=m_pUserTrackerObj->GetExitPoseState(nUserId)*100.0f; if(res!=XN_STATUS_OK) return; // bad user! xnOSMemSet(strUserLabel, 0, sizeof(strUserLabel)); res=m_pUserTrackerObj->GetUserStringPos(nUserId,com,strUserLabel,MAX_USER_LABEL_LEN-1); if(res!=XN_STATUS_OK) return; // bad user! if (!g_bPrintState) { if(userExitPose>0) { sprintf(strOutputLabel, "%d - Exit wait %3.0f%% done.", nUserId,userExitPose); } else { sprintf(strOutputLabel, "%d", nUserId); } } else { if(userExitPose>0) { sprintf(strOutputLabel, "%d - %s - Exit wait %3.0f%% done.", nUserId,strUserLabel,userExitPose); } else { sprintf(strOutputLabel, "%d - %s", nUserId,strUserLabel); } } glColor4f(1-color[0], 1-color[1], 1-color[2], 1); glRasterPos2i(com.X, com.Y); int len = (int)strlen(strOutputLabel); for(int c=0; c<len; c++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,strOutputLabel[c]); } #endif }
static void GetCPUName(XnChar* csName) { int CPUInfo[4] = {-1}; xnOSMemSet(csName, 0, XN_MAX_OS_NAME_LENGTH); // calling cpuid with 0x80000000 retrives the number of extended properties __cpuid(CPUInfo, 0x80000000); unsigned int nExIds = CPUInfo[0]; if (nExIds >= 0x80000002) { __cpuid(CPUInfo, 0x80000002); xnOSMemCopy(csName, CPUInfo, sizeof(CPUInfo)); } if (nExIds >= 0x80000003) { __cpuid(CPUInfo, 0x80000003); xnOSMemCopy(csName + 16, CPUInfo, sizeof(CPUInfo)); } if (nExIds >= 0x80000004) { __cpuid(CPUInfo, 0x80000004); xnOSMemCopy(csName + 32, CPUInfo, sizeof(CPUInfo)); } if (nExIds > 0x80000002) return; // else, we need to build the name ourselves xnOSMemSet(CPUInfo, 0xFF, sizeof(CPUInfo)); __cpuid(CPUInfo, 0); int nIds = CPUInfo[0]; *((int*)csName) = CPUInfo[1]; *((int*)(csName+4)) = CPUInfo[3]; *((int*)(csName+8)) = CPUInfo[2]; if (nIds >= 1) { __cpuid(CPUInfo, 1); int nSteppingID = CPUInfo[0] & 0xf; int nModel = (CPUInfo[0] >> 4) & 0xf; int nFamily = (CPUInfo[0] >> 8) & 0xf; //int nProcessorType = (CPUInfo[0] >> 12) & 0x3; //int nExtendedmodel = (CPUInfo[0] >> 16) & 0xf; //int nExtendedfamily = (CPUInfo[0] >> 20) & 0xff; //int nBrandIndex = CPUInfo[1] & 0xff; sprintf(csName+strlen(csName), " Model: %d Family: %d Stepping: %d", nModel, nFamily, nSteppingID); }
void Mainloop() { int frameId = 1; int xdir = 1; int ydir = 1; struct {int x, y;} center = {0,0}; while (m_running) { // printf("Tick"); OniFrame* pFrame = getServices().acquireFrame(); if (pFrame == NULL) {printf("Didn't get frame...\n"); continue;} // Fill frame xnOSMemSet(pFrame->data, 0, pFrame->dataSize); OniDepthPixel* pDepth = (OniDepthPixel*)pFrame->data; for (int y1 = XN_MAX(center.y-10, 0); y1 < XN_MIN(center.y+10, OZ_RESOLUTION_Y); ++y1) for (int x1 = XN_MAX(center.x-10, 0); x1 < XN_MIN(center.x+10, OZ_RESOLUTION_X); ++x1) if ((x1-center.x)*(x1-center.x)+(y1-center.y)*(y1-center.y) < 70) pDepth[singleRes(x1, y1)] = OniDepthPixel(1000+(x1-y1)*3); // pDepth[singleRes(center.x, center.y)] = 1000; center.x += xdir; center.y += ydir; if (center.x < abs(xdir) || center.x > OZ_RESOLUTION_X-1-abs(xdir)) xdir*=-1; if (center.y < abs(ydir) || center.y > OZ_RESOLUTION_Y-1-abs(ydir)) ydir*=-1; for (int i = 0; i < OZ_RESOLUTION_X; ++i) pDepth[i] = 2000; pDepth[0] = 2000; // Fill metadata pFrame->frameIndex = frameId; pFrame->videoMode.pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; pFrame->videoMode.resolutionX = OZ_RESOLUTION_X; pFrame->videoMode.resolutionY = OZ_RESOLUTION_Y; pFrame->videoMode.fps = 30; pFrame->width = OZ_RESOLUTION_X; pFrame->height = OZ_RESOLUTION_Y; pFrame->cropOriginX = pFrame->cropOriginY = 0; pFrame->croppingEnabled = FALSE; pFrame->sensorType = ONI_SENSOR_DEPTH; pFrame->stride = OZ_RESOLUTION_X*sizeof(OniDepthPixel); pFrame->timestamp = frameId*33000; raiseNewFrame(pFrame); getServices().releaseFrame(pFrame); frameId++; xnOSSleep(33); } }
// record 8 joint angles and one head-neck orientation void RecordAngle(XnUserID player, FILE *fp) { XnBool current; float angleHeadNeckTorse, angleHeadNeckLeftShoulder, angleHeadNeckRightShoulder, angleNeckHipLeftKnee, angleNeckHipRightKnee, angleNeckLeftShoulderLeftArm, angleNeckRightShoulderRightArm; angleHeadNeckTorse = CalculateJointAngle(player, XN_SKEL_HEAD, XN_SKEL_NECK, XN_SKEL_TORSO); angleHeadNeckLeftShoulder = CalculateJointAngle(player, XN_SKEL_HEAD, XN_SKEL_NECK, XN_SKEL_LEFT_SHOULDER); angleHeadNeckRightShoulder = CalculateJointAngle(player, XN_SKEL_HEAD, XN_SKEL_NECK, XN_SKEL_RIGHT_SHOULDER); angleNeckHipLeftKnee = CalculateJointAngle(player, XN_SKEL_NECK, XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE); angleNeckHipRightKnee = CalculateJointAngle(player, XN_SKEL_NECK, XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE); angleNeckLeftShoulderLeftArm = CalculateJointAngle(player, XN_SKEL_NECK, XN_SKEL_LEFT_SHOULDER, XN_SKEL_LEFT_ELBOW); angleNeckRightShoulderRightArm = CalculateJointAngle(player, XN_SKEL_NECK, XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW); float angleHeadNeck = CalculateHeadNeckAngle(player); char output[100] = ""; xnOSMemSet(output, 0, sizeof(output)); sprintf(output, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n", angleHeadNeckTorse, angleHeadNeckLeftShoulder, angleHeadNeckRightShoulder, angleNeckHipLeftKnee, angleNeckHipRightKnee, angleNeckLeftShoulderLeftArm, angleNeckRightShoulderRightArm, angleHeadNeck); fprintf(fp, output); }
XN_DDK_API XnStatus XnStreamDataUpdateSize(XnStreamData* pStreamOutput, XnUInt32 nAllocSize) { XN_VALIDATE_INPUT_PTR(pStreamOutput); // allocate new memory void* pNew = xnOSMallocAligned(nAllocSize, XN_DEFAULT_MEM_ALIGN); if (pNew == NULL) return (XN_STATUS_ALLOC_FAILED); // zero it xnOSMemSet(pNew, 0, nAllocSize); // free the buffer if it is allocated XN_ALIGNED_FREE_AND_NULL(pStreamOutput->pData); // and now set new buffer pStreamOutput->pData = pNew; // and size pStreamOutput->pInternal->nAllocSize = nAllocSize; pStreamOutput->pInternal->bAllocated = TRUE; return XN_STATUS_OK; }
XN_C_API XnStatus XN_C_DECL xnOSDeleteDirectoryTree(const XnChar* strDirName) { XnStatus nRetVal = XN_STATUS_OK; XN_VALIDATE_INPUT_PTR(strDirName); // file name must be double-null terminated XnChar strDirNameDoubleNull[MAX_PATH+1]; xnOSMemSet(strDirNameDoubleNull, 0, sizeof(strDirNameDoubleNull)); nRetVal = xnOSStrCopy(strDirNameDoubleNull, strDirName, MAX_PATH); XN_IS_STATUS_OK(nRetVal); SHFILEOPSTRUCT shOp; shOp.hwnd = NULL; shOp.wFunc = FO_DELETE; shOp.pFrom = strDirNameDoubleNull; shOp.pTo = NULL; shOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT; shOp.fAnyOperationsAborted = 0; shOp.hNameMappings = NULL; shOp.lpszProgressTitle = NULL; int ret = SHFileOperation(&shOp); if (ret != 0) { return XN_STATUS_OS_FAILED_TO_DELETE_DIR; } return (XN_STATUS_OK); }
//--------------------------------------------------------------------------- // Helper Functions //--------------------------------------------------------------------------- XnStatus xnUSBInitOvlp(XN_USB_EP_HANDLE pEPHandle) { XnStatus nRetVal = XN_STATUS_OK; if (pEPHandle->hEPHandleOvlp != NULL) { CloseHandle(pEPHandle->hEPHandleOvlp); } if (pEPHandle->ovlpIO.hEvent != NULL) { xnOSCloseEvent(&pEPHandle->ovlpIO.hEvent); } // Open the overlapped pipe handle pEPHandle->hEPHandleOvlp = CreateFile(pEPHandle->cpPipeName, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); if (pEPHandle->hEPHandleOvlp == INVALID_HANDLE_VALUE) { return (XN_STATUS_ERROR); } // Init the overlapped variables xnOSMemSet(&pEPHandle->ovlpIO, 0, sizeof(OVERLAPPED)); nRetVal = xnOSCreateEvent(&pEPHandle->ovlpIO.hEvent, FALSE); if (nRetVal != XN_STATUS_OK) { return (XN_STATUS_ERROR); } return (XN_STATUS_OK); }
OniStatus PlayerDriver::tryDevice(const char* strUri) { static XnPlayerInputStreamInterface inputInterface = { FileOpen, FileRead, NULL, NULL, FileClose, NULL, NULL, }; // Store the file path. m_filePath = strUri; XnStatus rc = PlayerNode::ValidateStream(this, &inputInterface); if (rc == XN_STATUS_OK) { OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSMemSet(pInfo, 0, sizeof(*pInfo)); xnOSStrCopy(pInfo->uri, strUri, ONI_MAX_STR); xnOSStrCopy(pInfo->vendor, kVendorString.Data(), ONI_MAX_STR); xnOSStrCopy(pInfo->name, kDeviceName.Data(), ONI_MAX_STR); deviceConnected(pInfo); return ONI_STATUS_OK; } return DriverBase::tryDevice(strUri); }
// WAVEの初期化 void initWave() { // WAVEデータの設定 WAVEFORMATEX wf; wf.wFormatTag = 0x0001; // PCM wf.nChannels = waveMode.nChannels; wf.nSamplesPerSec = waveMode.nSampleRate; wf.wBitsPerSample = waveMode.nBitsPerSample; wf.nBlockAlign = wf.wBitsPerSample * wf.nChannels / 8; wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec; MMRESULT mmRes = waveOutOpen(&hWaveOut, WAVE_MAPPER, &wf, NULL, NULL, CALLBACK_NULL); if (mmRes != MMSYSERR_NOERROR) { throw std::runtime_error( "Warning: Failed opening wave out device. Audio will not be played!\n" ); } // 音声データ用のバッファの作成と初期化 AudioBuffers.resize( NUMBER_OF_AUDIO_BUFFERS ); xnOSMemSet(&AudioBuffers[0], 0, sizeof(WAVEHDR)*AudioBuffers.size()); const XnUInt32 nMaxBufferSize = 2 * 1024 * 1024; for (int i = 0; i < NUMBER_OF_AUDIO_BUFFERS; ++i) { AudioBuffers[i].lpData = new XnChar[nMaxBufferSize]; AudioBuffers[i].dwUser = i; AudioBuffers[i].dwFlags = WHDR_DONE; // mark this buffer as empty (already played) } }
//--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- XnSensor::XnSensor() : XnDeviceBase(XN_DEVICE_NAME, TRUE), m_ErrorState(XN_MODULE_PROPERTY_ERROR_STATE, XN_STATUS_OK), m_ResetSensorOnStartup(XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP, TRUE), m_Interface(XN_MODULE_PROPERTY_USB_INTERFACE, XN_SENSOR_USB_INTERFACE_DEFAULT), m_NumberOfBuffers(XN_MODULE_PROPERTY_NUMBER_OF_BUFFERS, 6), m_ReadFromEP1(XN_MODULE_PROPERTY_READ_ENDPOINT_1, TRUE), m_ReadFromEP2(XN_MODULE_PROPERTY_READ_ENDPOINT_2, TRUE), m_ReadFromEP3(XN_MODULE_PROPERTY_READ_ENDPOINT_3, TRUE), m_ReadData("ReadData", FALSE), m_FrameSync(XN_MODULE_PROPERTY_FRAME_SYNC, FALSE), m_FirmwareParam(XN_MODULE_PROPERTY_FIRMWARE_PARAM, NULL), m_CmosBlankingUnits(XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS, NULL), m_CmosBlankingTime(XN_MODULE_PROPERTY_CMOS_BLANKING_TIME, NULL), m_Reset(XN_MODULE_PROPERTY_RESET), m_FirmwareMode(XN_MODULE_PROPERTY_FIRMWARE_MODE), m_Version(XN_MODULE_PROPERTY_VERSION, &m_DevicePrivateData.Version, sizeof(m_DevicePrivateData.Version), NULL), m_FixedParam(XN_MODULE_PROPERTY_FIXED_PARAMS, NULL), m_CloseStreamsOnShutdown(XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN, XN_SENSOR_DEFAULT_CLOSE_STREAMS_ON_SHUTDOWN), m_ID(XN_MODULE_PROPERTY_ID), m_pThis(this), m_InstancePointer(XN_SENSOR_PROPERTY_INSTANCE_POINTER, &m_pThis, sizeof(m_pThis), NULL), m_USBPath(XN_MODULE_PROPERTY_USB_PATH), m_DeviceName(XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME), m_VendorSpecificData(XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA), m_Firmware(&m_DevicePrivateData), m_FixedParams(&m_Firmware, &m_DevicePrivateData), m_SensorIO(&m_DevicePrivateData.SensorHandle), m_FPS(), m_CmosInfo(&m_Firmware, &m_DevicePrivateData), m_Objects(&m_Firmware, &m_DevicePrivateData, &m_FixedParams, &m_FPS, &m_CmosInfo), m_FrameSyncDump(XN_DUMP_CLOSED), m_bInitialized(FALSE) { // reset all data xnOSMemSet(&m_DevicePrivateData, 0, sizeof(XnDevicePrivateData)); m_strGlobalConfigFile[0] = '\0'; m_ResetSensorOnStartup.UpdateSetCallbackToDefault(); m_Interface.UpdateSetCallback(SetInterfaceCallback, this); m_NumberOfBuffers.UpdateSetCallback(SetNumberOfBuffersCallback, this); m_ReadFromEP1.UpdateSetCallback(SetReadEndpoint1Callback, this); m_ReadFromEP2.UpdateSetCallback(SetReadEndpoint2Callback, this); m_ReadFromEP3.UpdateSetCallback(SetReadEndpoint3Callback, this); m_ReadData.UpdateSetCallback(SetReadDataCallback, this); m_FrameSync.UpdateSetCallbackToDefault(); m_FirmwareParam.UpdateSetCallback(SetFirmwareParamCallback, this); m_FirmwareParam.UpdateGetCallback(GetFirmwareParamCallback, this); m_CmosBlankingUnits.UpdateSetCallback(SetCmosBlankingUnitsCallback, this); m_CmosBlankingUnits.UpdateGetCallback(GetCmosBlankingUnitsCallback, this); m_CmosBlankingTime.UpdateSetCallback(SetCmosBlankingTimeCallback, this); m_CmosBlankingTime.UpdateGetCallback(GetCmosBlankingTimeCallback, this); m_Reset.UpdateSetCallback(ResetCallback, this); m_FirmwareMode.UpdateSetCallback(SetFirmwareModeCallback, this); m_FirmwareMode.UpdateGetCallback(GetFirmwareModeCallback, this); m_FixedParam.UpdateGetCallback(GetFixedParamsCallback, this); m_CloseStreamsOnShutdown.UpdateSetCallbackToDefault(); }
PlayerImpl::PlayerImpl() : m_hPlayer(NULL), m_pInFile(NULL), m_bHasTimeReference(FALSE), m_dPlaybackSpeed(1.0) { xnOSMemSet(m_strSource, 0, sizeof(m_strSource)); }
SyncSocketConnection::SyncSocketConnection() { m_hSocket = NULL; xnOSMemSet(m_strIP, 0, sizeof(m_strIP)); m_nPort = 0; m_nMaxPacketSize = 0; m_bInitialized = FALSE; }
MockDepthGenerator::MockDepthGenerator(const XnChar* strName) : MockMapGenerator(strName), m_nDeviceMaxDepth(0), m_nSupportedUserPositionsCount(0), m_bSupportedUserPositionsCountReceived(FALSE), m_pUserPositions(NULL) { xnOSMemSet(&m_FOV, 0, sizeof(m_FOV)); }
XN_C_API XnStatus xnOSOpenFile(const XnChar* cpFileName, const XnUInt32 nFlags, XN_FILE_HANDLE* pFile) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); XN_VALIDATE_OUTPUT_PTR(pFile); XnChar csFlags[10]; xnOSMemSet(csFlags, 0, 10); XnUInt32 nFlagsCount = 0; // Update the OS Create and Open flags according the user request if (nFlags & XN_OS_FILE_READ) { csFlags[nFlagsCount++] = 'r'; } if (nFlags & XN_OS_FILE_WRITE) { if (nFlags & XN_OS_FILE_TRUNCATE) { csFlags[nFlagsCount++] = 'w'; } else { csFlags[nFlagsCount++] = 'a'; } } // make the file binary csFlags[nFlagsCount++] = 'b'; *pFile = fopen(cpFileName, csFlags); // handle failure... if (*pFile == NULL) { if ((nFlags & XN_OS_FILE_WRITE) && (nFlags & XN_OS_FILE_CREATE_NEW_ONLY)) { // If the file was opened for write and a create new only flag was specified, this probably means the file already exist return (XN_STATUS_OS_FILE_ALREDY_EXISTS); } else if (nFlags & XN_OS_FILE_WRITE) { // If the file was opened for write but without the create only flag, return a generic file open failure return (XN_STATUS_OS_FILE_OPEN_FAILED); } else if (nFlags & XN_OS_FILE_READ) { // If the file was opened for read, this probably means the file doesn't exist return (XN_STATUS_OS_FILE_NOT_FOUND); } } // All is good... return (XN_STATUS_OK); }
void XnStreamReaderStream::Reset() { m_nLastFrameIDFromStream = 0; xnOSMemSet(m_pLastData->pData, 0, m_pLastData->pInternal->nAllocSize); m_pLastData->nDataSize = 0; m_pLastData->nFrameID = 0; m_pLastData->nTimestamp = 0; m_pLastData->bIsNew = FALSE; XnDeviceStream::ResetLastTimestampAndFrameID(); }
XnShiftToDepthStreamHelper::XnShiftToDepthStreamHelper() : m_ShiftToDepthTable(XN_STREAM_PROPERTY_S2D_TABLE, "S2D", NULL, 0, NULL), m_DepthToShiftTable(XN_STREAM_PROPERTY_D2S_TABLE, "D2S", NULL, 0, NULL), m_pModule(NULL), m_bPropertiesAdded(FALSE) { m_ShiftToDepthTable.UpdateGetCallback(GetShiftToDepthTableCallback, this); m_DepthToShiftTable.UpdateGetCallback(GetDepthToShiftTableCallback, this); xnOSMemSet(&m_ShiftToDepthTables, 0, sizeof(XnShiftToDepthTables)); }
ONI_NAMESPACE_IMPLEMENTATION_BEGIN DriverHandler::DriverHandler(const char* library, xnl::ErrorLogger& errorLogger) { m_valid = false; xnOSMemSet(&funcs, 0, sizeof(funcs)); XnStatus rc = xnOSLoadLibrary(library, &m_libHandle); if (rc != XN_STATUS_OK) { return; } OniGetProcAddress(oniDriverCreate); OniGetProcAddress(oniDriverDestroy); OniGetProcAddress(oniDriverInitialize); OniGetProcAddress(oniDriverTryDevice); OniGetProcAddress(oniDriverDeviceOpen); OniGetProcAddress(oniDriverDeviceClose); OniGetProcAddress(oniDriverDeviceGetSensorInfoList); OniGetProcAddress(oniDriverDeviceCreateStream); OniGetProcAddress(oniDriverDeviceDestroyStream); OniGetProcAddress(oniDriverDeviceSetProperty); OniGetProcAddress(oniDriverDeviceGetProperty); OniGetProcAddress(oniDriverDeviceIsPropertySupported); OniGetProcAddress(oniDriverDeviceSetPropertyChangedCallback); OniGetProcAddress(oniDriverDeviceNotifyAllProperties); OniGetProcAddress(oniDriverDeviceInvoke); OniGetProcAddress(oniDriverDeviceIsCommandSupported); OniGetProcAddress(oniDriverDeviceIsImageRegistrationModeSupported); OniGetProcAddress(oniDriverDeviceTryManualTrigger); OniGetProcAddress(oniDriverStreamSetProperty); OniGetProcAddress(oniDriverStreamGetProperty); OniGetProcAddress(oniDriverStreamIsPropertySupported); OniGetProcAddress(oniDriverStreamSetPropertyChangedCallback); OniGetProcAddress(oniDriverStreamNotifyAllProperties); OniGetProcAddress(oniDriverStreamInvoke); OniGetProcAddress(oniDriverStreamIsCommandSupported); OniGetProcAddress(oniDriverStreamStart); OniGetProcAddress(oniDriverStreamStop); OniGetProcAddress(oniDriverStreamSetNewFrameCallback); OniGetProcAddress(oniDriverStreamAddRefToFrame); OniGetProcAddress(oniDriverStreamReleaseFrame); OniGetProcAddress(oniDriverStreamConvertDepthToColorCoordinates); OniGetProcAddress(oniDriverEnableFrameSync); OniGetProcAddress(oniDriverDisableFrameSync); m_valid = true; }
void XN_CALLBACK_TYPE PlayerDriver::EOFReached(void* pCookie, const char *strUri) { PlayerDriver* pThis = (PlayerDriver*)pCookie; OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSMemSet(pInfo, 0, sizeof(*pInfo)); xnOSStrCopy(pInfo->uri, strUri, ONI_MAX_STR); xnOSStrCopy(pInfo->vendor, kVendorString.Data(), ONI_MAX_STR); xnOSStrCopy(pInfo->name, kDeviceName.Data(), ONI_MAX_STR); pThis->deviceStateChanged(pInfo, ONI_DEVICE_STATE_EOF); }
void fillXnSupportedPixelFormats(XnSupportedPixelFormats &xnSPF, OniPixelFormat oniFormat) { xnOSMemSet(&xnSPF, 0, sizeof(xnSPF)); switch(toXnPixelFormat(oniFormat)) { case XN_PIXEL_FORMAT_RGB24: xnSPF.m_bRGB24 = 1; break; case XN_PIXEL_FORMAT_YUV422: xnSPF.m_bYUV422 = 1; break; case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: xnSPF.m_bGrayscale8Bit = 1; break; case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT: xnSPF.m_bGrayscale16Bit = 1; break; case XN_PIXEL_FORMAT_MJPEG: xnSPF.m_bMJPEG = 1; break; } }
LinkContInputStream::LinkContInputStream() { m_bInitialized = FALSE; m_bStreaming = FALSE; m_bNewDataAvailable = FALSE; m_hCriticalSection = NULL; m_nUserBufferMaxSize = 0; m_pUserBuffer = NULL; m_nUserBufferCurrentSize = 0; xnOSCreateCriticalSection(&m_hCriticalSection); m_pDumpFile = NULL; xnOSMemSet(m_strDumpName, 0, sizeof(m_strDumpName)); }
SocketInConnection::SocketInConnection() { xnOSMemSet(m_strIP, 0, sizeof(m_strIP)); m_nPort = 0; m_hReadThread = NULL; m_hConnectEvent = NULL; m_bStopReadThread = FALSE; m_pDataDestination = NULL; m_nBufferSize = 0; m_nMaxPacketSize = 0; m_nConnectionStatus = XN_STATUS_OS_NETWORK_CONNECTION_CLOSED; m_pBuffer = NULL; }
void PlayerNode::PlayerNodeInfo::Reset() { xnOSMemSet(strName, 0, sizeof(strName)); nLastDataPos = 0; compression = XN_CODEC_NULL; nFrames = 0; nCurFrame = 0; nMaxTimeStamp = 0; bStateReady = FALSE; bIsGenerator = FALSE; recordUndoInfoMap.Clear(); newDataUndoInfo.Reset(); bValid = FALSE; }
void RecordAssembler::emitCommonHeader(XnUInt32 recordType, XnUInt32 nodeId, XnUInt64 undoRecordPos) { MUST_BE_INITIALIZED() xnOSMemSet(m_header, 0, sizeof(*m_header)); // Reads as: "NIR\0" m_header->magic = 0x0052494E; m_header->recordType = recordType; m_header->nodeId = nodeId; m_header->fieldsSize = sizeof(*m_header); m_header->payloadSize = XN_UINT32_C(0); m_header->undoRecordPos = undoRecordPos; // Reset emit pointer. m_pEmitPtr = m_pBuffer + sizeof(*m_header); }
XnStatus ImageWatcher::NotifySupportedPixelFormats() { XnSupportedPixelFormats supportedPixelFormats; xnOSMemSet(&supportedPixelFormats, 0, sizeof(supportedPixelFormats)); supportedPixelFormats.m_bRGB24 = m_imageGenerator.IsPixelFormatSupported(XN_PIXEL_FORMAT_RGB24); supportedPixelFormats.m_bYUV422 = m_imageGenerator.IsPixelFormatSupported(XN_PIXEL_FORMAT_YUV422); supportedPixelFormats.m_bGrayscale8Bit = m_imageGenerator.IsPixelFormatSupported(XN_PIXEL_FORMAT_GRAYSCALE_8_BIT); supportedPixelFormats.m_bGrayscale16Bit = m_imageGenerator.IsPixelFormatSupported(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT); supportedPixelFormats.m_bMJPEG = m_imageGenerator.IsPixelFormatSupported(XN_PIXEL_FORMAT_MJPEG); XnStatus nRetVal = NotifyGeneralPropChanged(XN_PROP_SUPPORTED_PIXEL_FORMATS, sizeof(supportedPixelFormats), &supportedPixelFormats); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
void calculateHistogram() { DepthGenerator* pDepthGen = getDepthGenerator(); if (pDepthGen == NULL) return; XnUInt32 nZRes = pDepthGen->GetDeviceMaxDepth() + 1; if (g_pDepthHist == NULL) { g_pDepthHist = new float[nZRes]; } xnOSMemSet(g_pDepthHist, 0, nZRes*sizeof(float)); int nNumberOfPoints = 0; XnDepthPixel nValue; const XnDepthPixel* pDepth = pDepthGen->GetDepthMap(); const XnDepthPixel* pDepthEnd = pDepth + (pDepthGen->GetDataSize() / sizeof(XnDepthPixel)); while (pDepth != pDepthEnd) { nValue = *pDepth; XN_ASSERT(nValue <= nZRes); if (nValue != 0) { g_pDepthHist[nValue]++; nNumberOfPoints++; } pDepth++; } XnUInt32 nIndex; for (nIndex = 1; nIndex < nZRes; nIndex++) { g_pDepthHist[nIndex] += g_pDepthHist[nIndex-1]; } for (nIndex = 1; nIndex < nZRes; nIndex++) { if (g_pDepthHist[nIndex] != 0) { g_pDepthHist[nIndex] = (nNumberOfPoints-g_pDepthHist[nIndex]) / nNumberOfPoints; } } }
LinkMsgEncoder::LinkMsgEncoder() { m_nMaxMsgSize = 0; m_nMaxPacketSize = 0; m_nMaxNumPackets = 0; m_nBufferSize = 0; m_pCurrPacket = NULL; m_nEncodedSize = 0; m_pOutputBuffer = NULL; xnOSMemSet(&m_packetHeader, 0, sizeof(m_packetHeader)); //Set constant packet header values - for all messages m_packetHeader.SetMagic(); m_packetHeader.SetSize(sizeof(m_packetHeader)); //this is the minimum size, we'll add to this. }
XN_C_API XnStatus xnOSStopTimer(XnOSTimer* pTimer) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(pTimer); if (pTimer->dTicksPerTimeUnit == 0) { return (XN_STATUS_OS_INVALID_TIMER); } xnOSMemSet(pTimer, 0, sizeof(XnOSTimer)); // All is good... return (XN_STATUS_OK); }