| | | 1 | | using System; |
| | | 2 | | using MathNet.Numerics.LinearAlgebra; |
| | | 3 | | |
| | | 4 | | namespace ReFlex.Core.Calibration.Components |
| | | 5 | | { |
| | | 6 | | public abstract class DepthProcessorBase |
| | | 7 | | { |
| | | 8 | | #region Properties |
| | | 9 | | |
| | | 10 | | public const double MaxDepthValue = 2048.0; |
| | | 11 | | |
| | | 12 | | protected int Width; |
| | | 13 | | protected int Height; |
| | | 14 | | |
| | | 15 | | #endregion |
| | | 16 | | |
| | | 17 | | #region Constructor |
| | | 18 | | |
| | 0 | 19 | | protected DepthProcessorBase(int width, int height) |
| | 0 | 20 | | { |
| | 0 | 21 | | Width = width; |
| | 0 | 22 | | Height = height; |
| | 0 | 23 | | } |
| | | 24 | | |
| | | 25 | | #endregion |
| | | 26 | | |
| | | 27 | | #region Methods |
| | | 28 | | |
| | | 29 | | protected int ConvertDim21(int x, int y) => |
| | 0 | 30 | | x + (Width * y); |
| | | 31 | | |
| | | 32 | | protected double[] ConvertDim12(int i) => |
| | 0 | 33 | | new[] { i % Width, Math.Floor((i / (double)Width)) }; |
| | | 34 | | |
| | | 35 | | protected Vector<double> InterpolateVector(Vector<double> src, Vector<double> target, double weight) |
| | 0 | 36 | | { |
| | 0 | 37 | | var result = new[] |
| | 0 | 38 | | { |
| | 0 | 39 | | src[0] + (target[0] - src[0]) * weight, |
| | 0 | 40 | | src[1] + (target[1] - src[1]) * weight, |
| | 0 | 41 | | src[2] + (target[2] - src[2]) * weight |
| | 0 | 42 | | }; |
| | | 43 | | |
| | 0 | 44 | | return Vector<double>.Build.DenseOfArray(result); |
| | 0 | 45 | | } |
| | | 46 | | |
| | | 47 | | public abstract Vector<double>[,] Process(double[] depthValues); |
| | | 48 | | |
| | | 49 | | #endregion |
| | | 50 | | } |
| | | 51 | | |
| | | 52 | | } |