Ejemplo n.º 1
0
        public RunningStats()
        {
            if (!SupportTypes.TryGetValue(typeof(TKernel), out var type))
            {
                throw new NotSupportedException($"{typeof(TKernel).Name} does not support");
            }

            this._RunningStatsType = type.ToRunningStatsType();

            this.NativePtr = Dlib.Native.running_stats_new(this._RunningStatsType);
            if (this.NativePtr == IntPtr.Zero)
            {
                throw new ArgumentException($"{type} is not supported.");
            }

            this._Type = type;

            switch (this._Type)
            {
            case RunningStatsTypes.Float:
                this._Imp = new RunningStatsFloatImp(this, this._RunningStatsType) as RunningStatsImp <TKernel>;
                break;

            case RunningStatsTypes.Double:
                this._Imp = new RunningStatsDoubleImp(this, this._RunningStatsType) as RunningStatsImp <TKernel>;
                break;
            }
        }
Ejemplo n.º 2
0
        internal static Dlib.Native.RunningStatsType ToRunningStatsType(this RunningStatsTypes types)
        {
            switch (types)
            {
            case RunningStatsTypes.Float:
                return(Dlib.Native.RunningStatsType.Float);

            case RunningStatsTypes.Double:
                return(Dlib.Native.RunningStatsType.Double);

            default:
                throw new ArgumentOutOfRangeException(nameof(types), types, null);
            }
        }