コード例 #1
0
        public static void WriteDeviceConfig <T>(this PXCMCapture.Device device, T metaData, CaptureMode captureMode) where T : DS4Meta
        {
            int backLightCompensation = device.QueryColorBackLightCompensation();
            int brightness            = device.QueryColorBrightness();
            int contrast = device.QueryColorContrast();

            PXCMRangeF32 depthRange    = device.QueryDepthSensorRange();
            float        minDepthRange = depthRange.min;
            float        maxDepthRange = depthRange.max;

            ushort confidenceThreshold = device.QueryDepthConfidenceThreshold();

            bool autoExposure  = device.QueryColorAutoExposure();
            bool autoPowerline = device.QueryColorAutoPowerLineFrequency();

            int colorExposure = device.QueryColorExposure();
            int colorGain     = device.QueryColorGain();

            float depthExposure = device.QueryDSLeftRightExposure();
            int   depthGain     = device.QueryDSLeftRightGain();

            var  depthExposureInfo = device.QueryDSLeftRightExposureInfo();
            bool depthAutoExposure = depthExposureInfo.automatic;

            metaData.DeviceConfig.BackLightCompensation = backLightCompensation;
            metaData.DeviceConfig.minDepthRange         = minDepthRange;
            metaData.DeviceConfig.maxDepthRange         = maxDepthRange;
            metaData.DeviceConfig.colorAutoExposure     = autoExposure;
            metaData.DeviceConfig.depthAutoExposure     = depthAutoExposure;

            metaData.DeviceConfig.ColorExposure = (float)colorExposure;
            metaData.DeviceConfig.ColorGain     = colorGain;

            if (metaData.DeviceConfig.DepthExposure == 0)
            {
                metaData.DeviceConfig.DepthExposure = 33.3f;
                metaData.DeviceConfig.DepthGain     = 1;
            }
            //{
            //    BackLightCompensation = backLightCompensation,
            //    Brightness = brightness,
            //    Contrast = contrast,
            //    minDepthRange = minDepthRange,
            //    maxDepthRange = maxDepthRange,
            //    confidenceThreshold = confidenceThreshold,
            //    autoPowerline = autoPowerline,

            //    colorAutoExposure = autoExposure,
            //    depthAutoExposure = depthAutoExposure,

            //    ColorExposure = (float)colorExposure,
            //    ColorGain = colorGain,
            //    DepthExposure = depthExposure,
            //    DepthGain = depthGain
            //};

            metaData.CaptureMode = captureMode.ToString().ToLower();
        }