コード例 #1
0
        private void TestConvert2DTo2D(DepthMode depthMode, ColorResolution colorResolution)
        {
            Calibration.CreateDummy(depthMode, colorResolution, out var calibration);

            var point2d = calibration.Convert2DTo2D(new Float2(100f, 10f), 2000f, CalibrationGeometry.Depth, CalibrationGeometry.Depth);

            Assert.IsNotNull(point2d);
            Assert.AreEqual(100f, point2d.Value.X);
            Assert.AreEqual(10f, point2d.Value.Y);

            point2d = calibration.Convert2DTo2D(new Float2(10f, 100f), 3000f, CalibrationGeometry.Color, CalibrationGeometry.Color);
            Assert.IsNotNull(point2d);
            Assert.AreEqual(10f, point2d.Value.X);
            Assert.AreEqual(100f, point2d.Value.Y);

            var depthCenter = new Float2(calibration.DepthCameraCalibration.Intrinsics.Parameters.Cx, calibration.DepthCameraCalibration.Intrinsics.Parameters.Cy);
            var colorCenter = new Float2(calibration.ColorCameraCalibration.Intrinsics.Parameters.Cx, calibration.ColorCameraCalibration.Intrinsics.Parameters.Cy);

            point2d = calibration.Convert2DTo2D(depthCenter, 1000f, CalibrationGeometry.Depth, CalibrationGeometry.Color);
            Assert.IsNotNull(point2d);
            Assert.AreEqual(colorCenter, point2d);

            point2d = calibration.Convert2DTo2D(colorCenter, 2000f, CalibrationGeometry.Color, CalibrationGeometry.Depth);
            Assert.IsNotNull(point2d);
            Assert.AreEqual(depthCenter, point2d);

            point2d = calibration.Convert2DTo2D(depthCenter, 0f, CalibrationGeometry.Depth, CalibrationGeometry.Color);
            Assert.IsNull(point2d);

            point2d = calibration.Convert2DTo2D(colorCenter, -10f, CalibrationGeometry.Color, CalibrationGeometry.Depth);
            Assert.IsNull(point2d);
        }
コード例 #2
0
        private void TestDummyCalibration(DepthMode depthMode, ColorResolution colorResolution)
        {
            Calibration.CreateDummy(depthMode, colorResolution, out var calibration);

            Assert.IsTrue(calibration.IsValid);

            Assert.AreEqual(depthMode, calibration.DepthMode);
            Assert.AreEqual(colorResolution, calibration.ColorResolution);
        }
コード例 #3
0
        private void TestConvert3DTo3D(DepthMode depthMode, ColorResolution colorResolution)
        {
            Calibration.CreateDummy(depthMode, colorResolution, out var calibration);

            var testPoint = new Float3(10f, 10f, 1000f);

            var point3d = calibration.Convert3DTo3D(testPoint, CalibrationGeometry.Gyro, CalibrationGeometry.Accel);

            Assert.AreEqual(testPoint, point3d);
        }
コード例 #4
0
        /// <summary>Call this method to initialization of Body Tracking runtime.</summary>
        /// <param name="message">
        /// If Body Tracking runtime was initialized successfully, this parameter is <see langword="null"/>,
        /// otherwise it contains user-friendly description of failure reason.
        /// </param>
        /// <returns>
        /// <see langword="true"/> - if Body Tracking runtime was initialized successfully (in this case <paramref name="message"/> is <see langword="null"/>),
        /// <see langword="false"/> - otherwise and in this case <paramref name="message"/> contains user-friendly description of failure.
        /// </returns>
        /// <remarks><para>
        /// It is rather time consuming operation: initialization of ONNX runtime, loading and parsing of neural network model, etc.
        /// For this reason, it is recommended to initialize Body Tracking runtime in advance and show some progress window for user.
        /// But this initialization is optional. If it wasn't called explicitly, it will be called implicitly during first construction of
        /// <see cref="BodyTracking.Tracker"/> object.
        /// </para><para>
        /// This method tries to find Body Tracking runtime in one of the following locations:
        /// directory with executable file,
        /// directory with <c>K4AdotNet</c> assembly,
        /// installation directory of Body Tracking SDK under <c>Program Files</c>.
        /// </para></remarks>
        /// <seealso cref="IsBodyTrackingRuntimeAvailable(out string)"/>
        /// <seealso cref="BodyTracking.Tracker.Tracker(ref Calibration)"/>
        public static bool TryInitializeBodyTrackingRuntime(out string message)
        {
            Calibration.CreateDummy(DepthMode.NarrowView2x2Binned, ColorResolution.Off, out var calibration);
            if (!TryCreateTrackerHandle(ref calibration, out var trackerHandle, out message))
            {
                return(false);
            }

            trackerHandle.Dispose();
            message = null;
            return(true);
        }
コード例 #5
0
        private void TestConvertColor2DToDepth2D(DepthMode depthMode, ColorResolution colorResolution)
        {
            Calibration.CreateDummy(depthMode, colorResolution, 30, out var calibration);

            var depth2d = new Float2(calibration.DepthCameraCalibration.Intrinsics.Parameters.Cx, calibration.DepthCameraCalibration.Intrinsics.Parameters.Cy);
            var depthMm = (short)1800;
            var color2d = calibration.Convert2DTo2D(depth2d, depthMm, CalibrationGeometry.Depth, CalibrationGeometry.Color).Value;

            var depthImageBuffer = new short[depthMode.WidthPixels() * depthMode.HeightPixels()];

            for (var i = 0; i < depthImageBuffer.Length; i++)
            {
                depthImageBuffer[i] = depthMm;
            }
            var depthImage = Image.CreateFromArray(depthImageBuffer, ImageFormat.Depth16, depthMode.WidthPixels(), depthMode.HeightPixels());

            var point2d = calibration.ConvertColor2DToDepth2D(color2d, depthImage);

            Assert.IsNotNull(point2d);
            Assert.IsTrue(Math.Abs(depth2d.X - point2d.Value.X) < 1f);
            Assert.IsTrue(Math.Abs(depth2d.Y - point2d.Value.Y) < 1f);

            depthImage.Dispose();
        }