XnStatus XnSensorDepthStream::SetFPS(XnUInt32 nFPS) { XnStatus nRetVal = XN_STATUS_OK; nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), (XnUInt16)nFPS); XN_IS_STATUS_OK(nRetVal); nRetVal = XnDepthStream::SetFPS(nFPS); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.AfterSettingFirmwareParam(FPSProperty()); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorDepthStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_DepthFormat, FALSE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_DepthResolution, FALSE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_DepthFPS, FALSE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_HoleFilter, GetFirmwareParams()->m_DepthHoleFilter, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_Gain, GetFirmwareParams()->m_DepthGain, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_WhiteBalance, GetFirmwareParams()->m_DepthWhiteBalance, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_DepthMirror, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareRegistration, GetFirmwareParams()->m_RegistrationEnabled, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_DepthCropSizeX, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_DepthCropSizeY, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_DepthCropOffsetX, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_DepthCropOffsetY, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_DepthCropEnabled, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_GMCMode, GetFirmwareParams()->m_GMCMode, TRUE); XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); }
XnStatus XnSensorIRStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificImageUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.ConfigureFirmware(FPSProperty()); XN_IS_STATUS_OK(nRetVal);; // IR mirror is always off in firmware nRetVal = GetFirmwareParams()->m_IRMirror.SetValue(FALSE); XN_IS_STATUS_OK(nRetVal); // CMOS if (GetResolution() != XN_RESOLUTION_SXGA) { nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }
XnStatus XnSensorImageStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificImageUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); nRetVal = ValidateMode(); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_AntiFlicker)); // image quality is only relevant for JPEG if (m_InputFormat.GetValue() == XN_IO_IMAGE_FORMAT_JPEG) { XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_ImageQuality)); } XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); if (GetResolution() != XN_RESOLUTION_UXGA && GetResolution() != XN_RESOLUTION_SXGA) { nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_IMAGE, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }
XnStatus XnSensorDepthStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificDepthUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_HoleFilter)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_Gain)); // we need to turn decimation on when resolution is QVGA, and FPS is different than 60 // NOTE: this is ugly as hell. This logic should be moved to firmware. XnBool bDecimation = (GetResolution() == XN_RESOLUTION_QVGA && GetFPS() != 60); nRetVal = GetFirmwareParams()->m_DepthDecimation.SetValue(bDecimation); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareRegistration)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_GMCMode)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_WhiteBalance)); nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
XnStatus XnSensorImageStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificImageUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); nRetVal = ValidateMode(); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_InputFormat); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.ConfigureFirmware(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.ConfigureFirmware(FPSProperty()); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.ConfigureFirmware(m_AntiFlicker); XN_IS_STATUS_OK(nRetVal);; // image quality is only relevant for JPEG if (m_InputFormat.GetValue() == XN_IO_IMAGE_FORMAT_JPEG) { nRetVal = m_Helper.ConfigureFirmware(m_ImageQuality); XN_IS_STATUS_OK(nRetVal);; } nRetVal = m_Helper.ConfigureFirmware(m_FirmwareMirror); XN_IS_STATUS_OK(nRetVal);; if (GetResolution() != XN_RESOLUTION_UXGA && GetResolution() != XN_RESOLUTION_SXGA) { nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_IMAGE, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); } if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_4) { nRetVal = m_Helper.ConfigureFirmware(m_Sharpness); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_FirmwareColorTemperature); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_FirmwareAutoWhiteBalance); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_FirmwareExposure); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_FirmwareAutoExposure); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_BackLightCompensation); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_Gain); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.ConfigureFirmware(m_LowLightCompensation); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }
XnStatus XnSensorIRStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_IRResolution, FALSE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_IRFPS, FALSE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_IRCropSizeX, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_IRCropSizeY, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_IRCropOffsetX, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_IRCropOffsetY, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_IRCropEnabled, TRUE)); return (XN_STATUS_OK); }
XnStatus XnSensorIRStream::Init() { XnStatus nRetVal = XN_STATUS_OK; // nRetVal = SetBufferPool(&m_BufferPool); // XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnIRStream::Init(); XN_IS_STATUS_OK(nRetVal); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_ActualRead, &m_CroppingMode); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_RESOLUTION); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); // register supported modes XnCmosPreset* pSupportedModes = m_Helper.GetPrivateData()->FWInfo.irModes.GetData(); XnUInt32 nSupportedModes = m_Helper.GetPrivateData()->FWInfo.irModes.GetSize(); nRetVal = AddSupportedModes(pSupportedModes, nSupportedModes); XN_IS_STATUS_OK(nRetVal); // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // register for mirror XnCallbackHandle hCallbackDummy; nRetVal = IsMirroredProperty().OnChangeEvent().Register(IsMirroredChangedCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorImageStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_ImageFormat, FALSE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_ImageResolution, FALSE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_ImageFPS, FALSE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_AntiFlicker, GetFirmwareParams()->m_ImageFlickerDetection, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_ImageQuality, GetFirmwareParams()->m_ImageQuality, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_ImageMirror, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_ImageCropSizeX, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_ImageCropSizeY, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_ImageCropOffsetX, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_ImageCropOffsetY, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_ImageCropEnabled, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_Sharpness, GetFirmwareParams()->m_ImageSharpness, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareAutoWhiteBalance, GetFirmwareParams()->m_ImageAutoWhiteBalance, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareColorTemperature, GetFirmwareParams()->m_ImageColorTemperature, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_BackLightCompensation, GetFirmwareParams()->m_ImageBacklightCompensation, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_Gain, GetFirmwareParams()->m_ImageGain, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareExposure, GetFirmwareParams()->m_ImageExposureBar, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareAutoExposure, GetFirmwareParams()->m_ImageAutoExposure, TRUE); XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_LowLightCompensation, GetFirmwareParams()->m_ImageLowLightCompensation, TRUE); XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); }
XnStatus XnSensorImageStream::Init() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = SetBufferPool(&m_BufferPool); XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnImageStream::Init(); XN_IS_STATUS_OK(nRetVal); m_InputFormat.UpdateSetCallback(SetInputFormatCallback, this); m_AntiFlicker.UpdateSetCallback(SetAntiFlickerCallback, this); m_ImageQuality.UpdateSetCallback(SetImageQualityCallback, this); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_AntiFlicker, &m_ImageQuality, &m_SharedBufferName, &m_ActualRead); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_RESOLUTION); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(m_InputFormat); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorImageStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_ImageFormat, FALSE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_ImageResolution, FALSE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_ImageFPS, FALSE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_AntiFlicker, GetFirmwareParams()->m_ImageFlickerDetection, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_ImageQuality, GetFirmwareParams()->m_ImageQuality, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_ImageMirror, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_ImageCropSizeX, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_ImageCropSizeY, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_ImageCropOffsetX, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_ImageCropOffsetY, TRUE)); XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_ImageCropEnabled, TRUE)); return (XN_STATUS_OK); }
XnStatus XnSensorIRStream::Init() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = SetBufferPool(&m_BufferPool); XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnIRStream::Init(); XN_IS_STATUS_OK(nRetVal); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_SharedBufferName, &m_ActualRead); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_RESOLUTION); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // register for mirror XnCallbackHandle hCallbackDummy; nRetVal = IsMirroredProperty().OnChangeEvent().Register(IsMirroredChangedCallback, this, &hCallbackDummy); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorDepthStream::ConfigureStreamImpl() { XnStatus nRetVal = XN_STATUS_OK; xnUSBShutdownReadThread(GetHelper()->GetPrivateData()->pSpecificDepthUsb->pUsbConnection->UsbEp); nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_HoleFilter)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_Gain)); // we need to turn decimation on when resolution is QVGA, and FPS is different than 60 // NOTE: this is ugly as hell. This logic should be moved to firmware. XnBool bDecimation = (GetResolution() == XN_RESOLUTION_QVGA && GetFPS() != 60); nRetVal = GetFirmwareParams()->m_DepthDecimation.SetValue(bDecimation); XN_IS_STATUS_OK(nRetVal); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareRegistration)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_GMCMode)); XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_WhiteBalance)); nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); // --avin mod-- //Turn off the IR projector anti-cover thingy. I find it annoying and It's off on the XBox360 so it must be safe :-) //This is probably not the best way to do it, but adding it as a real param is too much work for me at the moment... XnHostProtocolSetParam(GetHelper()->GetPrivateData(), 0x105, 0); return XN_STATUS_OK; }
XnStatus XnSensorIRStream::Init() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = SetBufferPool(&m_BufferPool); XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnIRStream::Init(); XN_IS_STATUS_OK(nRetVal); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_SharedBufferName, &m_ActualRead); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_RESOLUTION); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); // register supported modes XnCmosPreset aSupportedModes[] = { { 0, XN_RESOLUTION_QVGA, 30 }, { 0, XN_RESOLUTION_QVGA, 60 }, { 0, XN_RESOLUTION_VGA, 30 }, { 0, XN_RESOLUTION_SXGA, 30 }, }; nRetVal = AddSupportedModes(aSupportedModes, sizeof(aSupportedModes)/sizeof(aSupportedModes[0])); XN_IS_STATUS_OK(nRetVal); if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_1) { XnCmosPreset aSupportedModesSXGA[] = { { 0, XN_RESOLUTION_SXGA, 30 }, }; nRetVal = AddSupportedModes(aSupportedModesSXGA, sizeof(aSupportedModesSXGA)/sizeof(aSupportedModesSXGA[0])); XN_IS_STATUS_OK(nRetVal); } if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_2) { XnCmosPreset aSupportedModes25[] = { { 0, XN_RESOLUTION_QVGA, 25 }, { 0, XN_RESOLUTION_VGA, 25 }, }; nRetVal = AddSupportedModes(aSupportedModes25, sizeof(aSupportedModes25)/sizeof(aSupportedModes25[0])); XN_IS_STATUS_OK(nRetVal); } // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // register for mirror XnCallbackHandle hCallbackDummy; nRetVal = IsMirroredProperty().OnChangeEvent().Register(IsMirroredChangedCallback, this, &hCallbackDummy); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorImageStream::Init() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = SetBufferPool(&m_BufferPool); XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnImageStream::Init(); XN_IS_STATUS_OK(nRetVal); m_InputFormat.UpdateSetCallback(SetInputFormatCallback, this); m_AntiFlicker.UpdateSetCallback(SetAntiFlickerCallback, this); m_ImageQuality.UpdateSetCallback(SetImageQualityCallback, this); m_Brightness.UpdateSetCallbackToDefault(); m_Contrast.UpdateSetCallbackToDefault(); m_Saturation.UpdateSetCallbackToDefault(); m_Zoom.UpdateSetCallbackToDefault(); m_Pan.UpdateSetCallbackToDefault(); m_Tilt.UpdateSetCallbackToDefault(); m_Sharpness.UpdateSetCallback(SetSharpnessCallback, this); m_ColorTemperature.UpdateSetCallback(SetColorTemperatureCallback, this); m_BackLightCompensation.UpdateSetCallback(SetBacklightCompensationCallback, this); m_Gain.UpdateSetCallback(SetGainCallback, this); m_Exposure.UpdateSetCallback(SetExposureCallback, this); m_LowLightCompensation.UpdateSetCallback(SetLowLightCompensationCallback, this); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_AntiFlicker, &m_ImageQuality, &m_Brightness, &m_Contrast, &m_Saturation, &m_Sharpness, &m_ColorTemperature, &m_BackLightCompensation, &m_Gain, &m_Zoom, &m_Exposure, &m_Pan, &m_Tilt, &m_LowLightCompensation, &m_SharedBufferName, &m_ActualRead); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_RESOLUTION); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(m_InputFormat); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // register supported modes if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_4) { // ask the firmware const XnUInt32 nAllocSize = 100; XnUInt32 nCount = nAllocSize; XnCmosPreset aSupportedModes[nAllocSize]; nRetVal = XnHostProtocolGetCmosPresets(m_Helper.GetPrivateData(), XN_CMOS_TYPE_IMAGE, aSupportedModes, nCount); XN_IS_STATUS_OK(nRetVal); if (nCount == 0) { xnLogError(XN_MASK_DEVICE_SENSOR, "Device does not support any image mode!"); return XN_STATUS_DEVICE_UNSUPPORTED_PARAMETER; } // check if our current (default) configuration is valid XnUInt16 nValidInputFormat = XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT; XnBool bModeFound = FALSE; for (XnUInt32 i = 0; i < nCount; ++i) { if (aSupportedModes[i].nResolution == XN_IMAGE_STREAM_DEFAULT_RESOLUTION && aSupportedModes[i].nFPS == XN_IMAGE_STREAM_DEFAULT_FPS) { // found if (!bModeFound) { bModeFound = TRUE; nValidInputFormat = aSupportedModes[i].nFormat; } if (aSupportedModes[i].nFormat == XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT) { nValidInputFormat = XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT; break; } } } if (!bModeFound) { xnLogWarning(XN_MASK_DEVICE_SENSOR, "Default mode (res + FPS) is not supported by device. Changing defaults..."); nRetVal = ResolutionProperty().UnsafeUpdateValue(aSupportedModes[0].nResolution); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(aSupportedModes[0].nFPS); XN_IS_STATUS_OK(nRetVal); nRetVal = m_InputFormat.UnsafeUpdateValue(aSupportedModes[0].nFormat); XN_IS_STATUS_OK(nRetVal); } else { // just update input format nRetVal = m_InputFormat.UnsafeUpdateValue(nValidInputFormat); XN_IS_STATUS_OK(nRetVal); } nRetVal = AddSupportedModes(aSupportedModes, nCount); XN_IS_STATUS_OK(nRetVal); } else { XnArray<XnCmosPreset> supportedModes(30); // Uncompressed modes are only supported in ISO (not BULK) XnBool bUncompressedAllowed = m_Helper.GetPrivateData()->pSpecificImageUsb->pUsbConnection->bIsISO; // start with common modes supported by all nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_QVGA, 60); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); // --avin mod-- nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_SXGA, 15); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_QVGA, 60); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); // add uncompressed ones if (bUncompressedAllowed) { nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_QVGA, 60); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); } // starting with FW 5.2, 25 FPS is also supported if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_2) { nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_QVGA, 25); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_VGA, 25); XN_IS_STATUS_OK(nRetVal); if (bUncompressedAllowed) { nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_QVGA, 25); XN_IS_STATUS_OK(nRetVal); nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_VGA, 25); XN_IS_STATUS_OK(nRetVal); } } // high-res if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_3) { nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_BAYER, XN_RESOLUTION_SXGA, 30); XN_IS_STATUS_OK(nRetVal); // starting with 5.3.28, YUV is also supported in high-res if (m_Helper.GetPrivateData()->Version.nMajor > 5 || (m_Helper.GetPrivateData()->Version.nMajor == 5 && m_Helper.GetPrivateData()->Version.nMinor > 3) || (m_Helper.GetPrivateData()->Version.nMajor == 5 && m_Helper.GetPrivateData()->Version.nMinor == 3 && m_Helper.GetPrivateData()->Version.nBuild >= 28)) { nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_SXGA, 30); XN_IS_STATUS_OK(nRetVal); if (bUncompressedAllowed) { nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_SXGA, 30); XN_IS_STATUS_OK(nRetVal); } } } else if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_2) { // on 5.2, high-res was UXGA nRetVal = AddSupportedMode(supportedModes, XN_IO_IMAGE_FORMAT_BAYER, XN_RESOLUTION_UXGA, 30); XN_IS_STATUS_OK(nRetVal); } // Add all supported modes to the stream nRetVal = AddSupportedModes(supportedModes.GetData(), supportedModes.GetSize()); XN_IS_STATUS_OK(nRetVal); if (!bUncompressedAllowed) { // update default input format nRetVal = m_InputFormat.UnsafeUpdateValue(XN_IO_IMAGE_FORMAT_YUV422); XN_IS_STATUS_OK(nRetVal); } } return (XN_STATUS_OK); }
XnStatus XnSensorDepthStream::Init() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = SetBufferPool(&m_BufferPool); XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnDepthStream::Init(); XN_IS_STATUS_OK(nRetVal); m_InputFormat.UpdateSetCallback(SetInputFormatCallback, this); m_DepthRegistration.UpdateSetCallback(SetRegistrationCallback, this); m_HoleFilter.UpdateSetCallback(SetHoleFilterCallback, this); m_WhiteBalance.UpdateSetCallback(SetWhiteBalanceCallback, this); m_Gain.UpdateSetCallback(SetGainCallback, this); m_RegistrationType.UpdateSetCallback(SetRegistrationTypeCallback, this); m_AGCBin.UpdateSetCallback(SetAGCBinCallback, this); m_AGCBin.UpdateGetCallback(GetAGCBinCallback, this); m_GMCMode.UpdateSetCallback(SetGMCModeCallback, this); XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_DepthRegistration, &m_HoleFilter, &m_WhiteBalance, &m_Gain, &m_AGCBin, &m_SharedBufferName, &m_ActualRead, &m_GMCMode, &m_RegistrationType); if (m_Helper.GetPrivateData()->pSensor->IsLowBandwidth()) { nRetVal = m_InputFormat.UnsafeUpdateValue(XN_IO_DEPTH_FORMAT_COMPRESSED_PS); XN_IS_STATUS_OK(nRetVal); } // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_DEPTH_STREAM_DEFAULT_RESOLUTION); XN_IS_STATUS_OK(nRetVal); nRetVal = FPSProperty().UnsafeUpdateValue(XN_DEPTH_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_DEPTH_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); nRetVal = ParamCoefficientProperty().UnsafeUpdateValue(XN_SHIFTS_PARAM_COEFFICIENT); XN_IS_STATUS_OK(nRetVal); nRetVal = ShiftScaleProperty().UnsafeUpdateValue(XN_SHIFTS_SHIFT_SCALE); XN_IS_STATUS_OK(nRetVal); // read some data from firmware XnDepthInformation DepthInformation; nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_DEPTH_INFO, &DepthInformation, sizeof(XnDepthInformation), XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = ConstShiftProperty().UnsafeUpdateValue(DepthInformation.nConstShift); XN_IS_STATUS_OK(nRetVal); nRetVal = ZeroPlaneDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetZeroPlaneDistance()); XN_IS_STATUS_OK(nRetVal); nRetVal = ZeroPlanePixelSizeProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetZeroPlanePixelSize()); XN_IS_STATUS_OK(nRetVal); nRetVal = EmitterDCmosDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetEmitterDCmosDistance()); XN_IS_STATUS_OK(nRetVal); nRetVal = GetDCmosRCmosDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetDCmosRCmosDistance()); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_3_0) { nRetVal = m_GMCMode.UnsafeUpdateValue(FALSE); XN_IS_STATUS_OK(nRetVal); } if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_4_0) { nRetVal = m_WhiteBalance.UnsafeUpdateValue(FALSE); XN_IS_STATUS_OK(nRetVal); } // on old firmwares, the host decides on the default gain. On new firmwares, we read it from firmware if (m_Helper.GetFirmware()->GetInfo()->nFWVer > XN_SENSOR_FW_VER_1_2) { nRetVal = m_Gain.UnsafeUpdateValue(GetFirmwareParams()->m_DepthGain.GetValue()); XN_IS_STATUS_OK(nRetVal); } // registration XnCallbackHandle hCallbackDummy; nRetVal = ResolutionProperty().OnChangeEvent().Register(DecideFirmwareRegistrationCallback, this, &hCallbackDummy); XN_IS_STATUS_OK(nRetVal); nRetVal = DecideFirmwareRegistration((XnBool)m_DepthRegistration.GetValue(), (XnProcessingType)m_RegistrationType.GetValue(), GetResolution()); XN_IS_STATUS_OK(nRetVal); // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(m_InputFormat); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // pixel size factor nRetVal = GetFirmwareParams()->m_ReferenceResolution.OnChangeEvent().Register(DecidePixelSizeFactorCallback, this, &m_hReferenceSizeChangedCallback); XN_IS_STATUS_OK(nRetVal); nRetVal = DecidePixelSizeFactor(); XN_IS_STATUS_OK(nRetVal); // register supported modes XnCmosPreset aSupportedModes[] = { { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QVGA, 30 }, { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QVGA, 60 }, { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_VGA, 30 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QVGA, 30 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QVGA, 60 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_VGA, 30 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QVGA, 30 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QVGA, 60 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_VGA, 30 }, }; nRetVal = AddSupportedModes(aSupportedModes, sizeof(aSupportedModes)/sizeof(aSupportedModes[0])); XN_IS_STATUS_OK(nRetVal); if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_2) { XnCmosPreset aSupportedModes25[] = { { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QVGA, 25 }, { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_VGA, 25 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QVGA, 25 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_VGA, 25 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QVGA, 25 }, { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_VGA, 25 }, }; nRetVal = AddSupportedModes(aSupportedModes25, sizeof(aSupportedModes25)/sizeof(aSupportedModes25[0])); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }
XnStatus XnSensorDepthStream::Init() { XnStatus nRetVal = XN_STATUS_OK; // init base nRetVal = XnDepthStream::Init(); XN_IS_STATUS_OK(nRetVal); // start with no cut-off nRetVal = MaxDepthProperty().UnsafeUpdateValue(XN_DEVICE_SENSOR_MAX_DEPTH_100_UM); XN_IS_STATUS_OK(nRetVal); m_InputFormat.UpdateSetCallback(SetInputFormatCallback, this); m_DepthRegistration.UpdateSetCallback(SetRegistrationCallback, this); m_HoleFilter.UpdateSetCallback(SetHoleFilterCallback, this); m_WhiteBalance.UpdateSetCallback(SetWhiteBalanceCallback, this); m_Gain.UpdateSetCallback(SetGainCallback, this); m_RegistrationType.UpdateSetCallback(SetRegistrationTypeCallback, this); m_AGCBin.UpdateSetCallback(SetAGCBinCallback, this); m_AGCBin.UpdateGetCallback(GetAGCBinCallback, this); m_GMCMode.UpdateSetCallback(SetGMCModeCallback, this); m_CloseRange.UpdateSetCallback(SetCloseRangeCallback, this); m_CroppingMode.UpdateSetCallback(SetCroppingModeCallback, this); m_PixelRegistration.UpdateGetCallback(GetPixelRegistrationCallback, this); m_GMCDebug.UpdateSetCallback(SetGMCDebugCallback, this); m_WavelengthCorrection.UpdateSetCallback(SetWavelengthCorrectionCallback, this); m_WavelengthCorrectionDebug.UpdateSetCallback(SetWavelengthCorrectionDebugCallback, this); XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_DepthRegistration, &m_HoleFilter, &m_WhiteBalance, &m_Gain, &m_AGCBin, &m_ActualRead, &m_GMCMode, &m_CloseRange, &m_CroppingMode, &m_RegistrationType, &m_PixelRegistration, &m_HorizontalFOV, &m_VerticalFOV, &m_GMCDebug, &m_WavelengthCorrection, &m_WavelengthCorrectionDebug, ); // register supported modes XnCmosPreset* pSupportedModes = m_Helper.GetPrivateData()->FWInfo.depthModes.GetData(); XnUInt32 nSupportedModes = m_Helper.GetPrivateData()->FWInfo.depthModes.GetSize(); nRetVal = AddSupportedModes(pSupportedModes, nSupportedModes); XN_IS_STATUS_OK(nRetVal); if (m_Helper.GetPrivateData()->pSensor->IsLowBandwidth()) { nRetVal = m_InputFormat.UnsafeUpdateValue(XN_IO_DEPTH_FORMAT_COMPRESSED_PS); XN_IS_STATUS_OK(nRetVal); } // make sure default resolution is supported XnBool bResSupported = FALSE; for (XnUInt8 i = 0; i < nSupportedModes; ++i) { if (pSupportedModes[i].nResolution == XN_DEPTH_STREAM_DEFAULT_RESOLUTION) { bResSupported = TRUE; break; } } XnUInt64 nDefaultResolution = XN_DEPTH_STREAM_DEFAULT_RESOLUTION; if (!bResSupported) { // QVGA was always supported nDefaultResolution = XN_RESOLUTION_QVGA; } nRetVal = ResolutionProperty().UnsafeUpdateValue(nDefaultResolution); XN_IS_STATUS_OK(nRetVal); // set other properties default values nRetVal = FPSProperty().UnsafeUpdateValue(XN_DEPTH_STREAM_DEFAULT_FPS); XN_IS_STATUS_OK(nRetVal); nRetVal = OutputFormatProperty().UnsafeUpdateValue(XN_DEPTH_STREAM_DEFAULT_OUTPUT_FORMAT); XN_IS_STATUS_OK(nRetVal); nRetVal = ParamCoefficientProperty().UnsafeUpdateValue(XN_SHIFTS_PARAM_COEFFICIENT); XN_IS_STATUS_OK(nRetVal); nRetVal = ShiftScaleProperty().UnsafeUpdateValue(XN_SHIFTS_SHIFT_SCALE); XN_IS_STATUS_OK(nRetVal); // read some data from firmware XnDepthInformation DepthInformation; nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_DEPTH_INFO, &DepthInformation, sizeof(XnDepthInformation), XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = ConstShiftProperty().UnsafeUpdateValue(DepthInformation.nConstShift); XN_IS_STATUS_OK(nRetVal); nRetVal = ZeroPlaneDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetZeroPlaneDistance()); XN_IS_STATUS_OK(nRetVal); nRetVal = ZeroPlanePixelSizeProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetZeroPlanePixelSize()); XN_IS_STATUS_OK(nRetVal); nRetVal = EmitterDCmosDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetEmitterDCmosDistance()); XN_IS_STATUS_OK(nRetVal); nRetVal = GetDCmosRCmosDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetDCmosRCmosDistance()); XN_IS_STATUS_OK(nRetVal); XnDouble fZPPS = m_Helper.GetFixedParams()->GetZeroPlanePixelSize(); XnInt nZPD = m_Helper.GetFixedParams()->GetZeroPlaneDistance(); nRetVal = m_HorizontalFOV.UnsafeUpdateValue(2*atan(fZPPS*XN_SXGA_X_RES/2/nZPD)); XN_IS_STATUS_OK(nRetVal); nRetVal = m_VerticalFOV.UnsafeUpdateValue(2*atan(fZPPS*XN_VGA_Y_RES*2/2/nZPD)); XN_IS_STATUS_OK(nRetVal); // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_3_0) { nRetVal = m_GMCMode.UnsafeUpdateValue(FALSE); XN_IS_STATUS_OK(nRetVal); } if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_5_2) { nRetVal = m_WavelengthCorrection.UnsafeUpdateValue(FALSE); XN_IS_STATUS_OK(nRetVal); } if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_4_0) { nRetVal = m_WhiteBalance.UnsafeUpdateValue(FALSE); XN_IS_STATUS_OK(nRetVal); } // on old firmwares, the host decides on the default gain. On new firmwares, we read it from firmware if (m_Helper.GetFirmware()->GetInfo()->nFWVer > XN_SENSOR_FW_VER_1_2) { nRetVal = m_Gain.UnsafeUpdateValue(GetFirmwareParams()->m_DepthGain.GetValue()); XN_IS_STATUS_OK(nRetVal); } // registration XnCallbackHandle hCallbackDummy; nRetVal = ResolutionProperty().OnChangeEvent().Register(DecideFirmwareRegistrationCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); nRetVal = DecideFirmwareRegistration((XnBool)m_DepthRegistration.GetValue(), (XnProcessingType)m_RegistrationType.GetValue(), GetResolution()); XN_IS_STATUS_OK(nRetVal); // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(m_InputFormat); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // pixel size factor nRetVal = GetFirmwareParams()->m_ReferenceResolution.OnChangeEvent().Register(DecidePixelSizeFactorCallback, this, m_hReferenceSizeChangedCallback); XN_IS_STATUS_OK(nRetVal); nRetVal = DecidePixelSizeFactor(); XN_IS_STATUS_OK(nRetVal); // initialize registration if (m_Helper.GetFirmwareVersion() > XN_SENSOR_FW_VER_5_3) { nRetVal = PopulateSensorCalibrationInfo(); XN_IS_STATUS_OK(nRetVal); nRetVal = DepthUtilsInitialize(&m_calibrationInfo, &m_depthUtilsHandle); XN_IS_STATUS_OK(nRetVal); nRetVal = DepthUtilsSetDepthConfiguration(m_depthUtilsHandle, GetXRes(), GetYRes(), GetOutputFormat(), IsMirrored()); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }