public PoseFinder(Engine e) { this.volume = e.FusionVolume; this.engine = e; // Create a camera pose finder with default parameters CameraPoseFinderParameters cameraPoseFinderParams = CameraPoseFinderParameters.Defaults; finder = CameraPoseFinder.FusionCreateCameraPoseFinder(cameraPoseFinderParams); resampledColorImagePixels = new int[KinectSettings.DEPTH_PIXEL_COUNT]; }
public VolumeBuilder(Scanner source, Dispatcher dispatcher) { if (source == null) { throw new ArgumentNullException("source"); } this.source = source; this.dispatcher = dispatcher; // Set the world-view transform to identity, so the world origin is the initial camera location. this.worldToCameraTransform = Matrix4.Identity; // Map world X axis to blue channel, Y axis to green channel and Z axis to red channel, // normalizing each to the range [0, 1]. We also add a shift of 0.5 to both X,Y channels // as the world origin starts located at the center of the front face of the volume, // hence we need to map negative x,y world vertex locations to positive color values. this.worldToBGRTransform = Matrix4.Identity; this.worldToBGRTransform.M11 = settings.VoxelsPerMeter / settings.VoxelsX; this.worldToBGRTransform.M22 = settings.VoxelsPerMeter / settings.VoxelsY; this.worldToBGRTransform.M33 = settings.VoxelsPerMeter / settings.VoxelsZ; this.worldToBGRTransform.M41 = 0.5f; this.worldToBGRTransform.M42 = 0.5f; this.worldToBGRTransform.M44 = 1.0f; var volumeParameters = new ReconstructionParameters(settings.VoxelsPerMeter, settings.VoxelsX, settings.VoxelsY, settings.VoxelsZ); this.volume = ColorReconstruction.FusionCreateReconstruction(volumeParameters, ReconstructionProcessor.Amp, -1, this.worldToCameraTransform); var depthWidth = this.source.Frame.DepthWidth; var depthHeight = this.source.Frame.DepthHeight; var depthSize = depthWidth * depthHeight; this.depthFloatFrame = new FusionFloatImageFrame(depthWidth, depthHeight); this.smoothDepthFloatFrame = new FusionFloatImageFrame(depthWidth, depthHeight); this.resampledColorFrame = new FusionColorImageFrame(depthWidth, depthHeight); this.resampledColorFrameDepthAligned = new FusionColorImageFrame(depthWidth, depthHeight); this.deltaFromReferenceFrame = new FusionFloatImageFrame(depthWidth, depthHeight); this.shadedSurfaceFrame = new FusionColorImageFrame(depthWidth, depthHeight); this.raycastPointCloudFrame = new FusionPointCloudImageFrame(depthWidth, depthHeight); this.depthPointCloudFrame = new FusionPointCloudImageFrame(depthWidth, depthHeight); var downsampledDepthWidth = depthWidth / settings.DownsampleFactor; var downsampledDepthHeight = depthHeight / settings.DownsampleFactor; var downsampledDepthSize = downsampledDepthWidth * downsampledDepthHeight; this.downsampledDepthFloatFrame = new FusionFloatImageFrame(downsampledDepthWidth, downsampledDepthHeight); this.downsampledSmoothDepthFloatFrame = new FusionFloatImageFrame(downsampledDepthWidth, downsampledDepthHeight); this.downsampledRaycastPointCloudFrame = new FusionPointCloudImageFrame(downsampledDepthWidth, downsampledDepthHeight); this.downsampledDepthPointCloudFrame = new FusionPointCloudImageFrame(downsampledDepthWidth, downsampledDepthHeight); this.downsampledDeltaFromReferenceFrameColorFrame = new FusionColorImageFrame(downsampledDepthWidth, downsampledDepthHeight); this.resampledColorData = new int[depthSize]; this.downsampledDepthData = new float[downsampledDepthSize]; this.downsampledDeltaFromReferenceColorPixels = new int[downsampledDepthSize]; this.deltaFromReferenceFramePixelsArgb = new int[depthSize]; this.shadedSurfaceFramePixelsArgb = new int[this.shadedSurfaceFrame.PixelDataLength]; this.defaultWorldToVolumeTransform = this.volume.GetCurrentWorldToVolumeTransform(); this.volumeBitmap = new WriteableBitmap(depthWidth, depthHeight, settings.DefaultSystemDPI, settings.DefaultSystemDPI, PixelFormats.Bgr32, null); // Create a camera pose finder with default parameters this.cameraPoseFinder = CameraPoseFinder.FusionCreateCameraPoseFinder(CameraPoseFinderParameters.Defaults); this.workerThread = new Thread(WorkerThreadProc); this.workerThread.Start(); this.source.Frame.OnDataUpdate += OnFrameDataUpdate; }