public FrameReader(ObjectPool <MemoryFrame> pool, SmithersLogger logger) { #if DSAPI _dsAPI = new DSAPIManaged(); _dsAPI.initializeDevice(); #else _pool = pool; _logger = logger; //Directory.SetCurrentDirectory("") // TODO Inject this instead of creating it _session = PXCMSession.CreateInstance(); if (_session == null) { throw new Smithers.Reading.FrameData.ScannerNotFoundException("No valid plugged-in DS4 sensor found."); } _senseManager = PXCMSenseManager.CreateInstance(); if (_senseManager == null) { throw new Smithers.Reading.FrameData.ScannerNotFoundException("Failed to create an SDK pipeline object"); } _session.SetCoordinateSystem(PXCMSession.CoordinateSystem.COORDINATE_SYSTEM_REAR_OPENCV); #endif this.Synced = true; this.Mirrored = false; this.Record = false; this.Playback = false; this.RealTime = true; }
public FrameReader(ObjectPool<MemoryFrame> pool, SmithersLogger logger) { #if DSAPI _dsAPI = new DSAPIManaged(); _dsAPI.initializeDevice(); #else _pool = pool; _logger = logger; //Directory.SetCurrentDirectory("") // TODO Inject this instead of creating it _session = PXCMSession.CreateInstance(); if (_session == null) { throw new Smithers.Reading.FrameData.ScannerNotFoundException("No valid plugged-in DS4 sensor found."); } _senseManager = PXCMSenseManager.CreateInstance(); if (_senseManager == null) { throw new Smithers.Reading.FrameData.ScannerNotFoundException("Failed to create an SDK pipeline object"); } _session.SetCoordinateSystem(PXCMSession.CoordinateSystem.COORDINATE_SYSTEM_REAR_OPENCV); #endif this.Synced = true; this.Mirrored = false; this.Record = false; this.Playback = false; this.RealTime = true; }
private static DS4CalibrationRecord Calibrate(DSAPIManaged dsAPI) { DS4Calibration calibration; int iSize = Marshal.SizeOf(typeof(DS4Calibration)); // Allocate memory (in the Global Heap) for the unmanaged // representation of a TestStruct struct. IntPtr calibrationPtr = Marshal.AllocHGlobal(iSize); // Call the IntPtr version API. unsafe { dsAPI.loadCalibartionInfo(calibrationPtr.ToPointer()); } // Copy the modified contents of the unmanaged representation // of test_struct back to the members of the managed test_struct. calibration = (DS4Calibration)(Marshal.PtrToStructure(calibrationPtr, typeof(DS4Calibration))); // Free the unmanaged representation of test_struct. Marshal.FreeHGlobal(calibrationPtr); DS4Calibration.DSCalibIntrinsicsRectified calibRectDepth = calibration.calib_rect_lr; DS4Calibration.DSCalibIntrinsicsRectified calibRectColor = calibration.calib_rect_color; DS4CalibrationRecord record = new DS4CalibrationRecord { DeviceCapture = new DS4CalibrationRecordInternal { ColorFocalLength = new float[] { calibRectColor.rfx, calibRectColor.rfy }, DepthFocalLength = new float[] { calibRectDepth.rfx, calibRectDepth.rfy }, ColorPrincipalPoint = new float[] { calibRectColor.rpx, calibRectColor.rpy }, DepthPrincipalPoint = new float[] { calibRectDepth.rpx, calibRectDepth.rpy }, ColorWidth = Frame.COLOR_WIDTH, ColorHeight = Frame.COLOR_HEIGHT, DepthWidth = Frame.DEPTH_WIDTH, DepthHeight = Frame.DEPTH_HEIGHT, DepthStride = Frame.DEPTH_STRIDE, //LowConfValue = device.QueryDepthLowConfidenceValue(), Extrinsics = new float[] { 1.0f, 0.0f, 0.0f, (float)calibration.color_translation[0], 0.0f, 1.0f, 0.0f, (float)calibration.color_translation[1], 0.0f, 0.0f, 1.0f, (float)calibration.color_translation[2], 0.0f, 0.0f, 0.0f, 1.0f } }, API = "DSAPI" }; return(record); }
private static DS4CalibrationRecord Calibrate(DSAPIManaged dsAPI) { DS4Calibration calibration; int iSize = Marshal.SizeOf(typeof(DS4Calibration)); // Allocate memory (in the Global Heap) for the unmanaged // representation of a TestStruct struct. IntPtr calibrationPtr = Marshal.AllocHGlobal(iSize); // Call the IntPtr version API. unsafe { dsAPI.loadCalibartionInfo(calibrationPtr.ToPointer()); } // Copy the modified contents of the unmanaged representation // of test_struct back to the members of the managed test_struct. calibration = (DS4Calibration)(Marshal.PtrToStructure(calibrationPtr, typeof(DS4Calibration))); // Free the unmanaged representation of test_struct. Marshal.FreeHGlobal(calibrationPtr); DS4Calibration.DSCalibIntrinsicsRectified calibRectDepth = calibration.calib_rect_lr; DS4Calibration.DSCalibIntrinsicsRectified calibRectColor = calibration.calib_rect_color; DS4CalibrationRecord record = new DS4CalibrationRecord { DeviceCapture = new DS4CalibrationRecordInternal { ColorFocalLength = new float[] { calibRectColor.rfx, calibRectColor.rfy }, DepthFocalLength = new float[] { calibRectDepth.rfx, calibRectDepth.rfy }, ColorPrincipalPoint = new float[] { calibRectColor.rpx, calibRectColor.rpy }, DepthPrincipalPoint = new float[] { calibRectDepth.rpx, calibRectDepth.rpy }, ColorWidth = Frame.COLOR_WIDTH, ColorHeight = Frame.COLOR_HEIGHT, DepthWidth = Frame.DEPTH_WIDTH, DepthHeight = Frame.DEPTH_HEIGHT, DepthStride = Frame.DEPTH_STRIDE, //LowConfValue = device.QueryDepthLowConfidenceValue(), Extrinsics = new float[] { 1.0f, 0.0f, 0.0f, (float)calibration.color_translation[0], 0.0f, 1.0f, 0.0f, (float)calibration.color_translation[1], 0.0f, 0.0f, 1.0f, (float)calibration.color_translation[2], 0.0f, 0.0f, 0.0f, 1.0f} }, API = "DSAPI" }; return record; }