Exemple #1
0
        internal static NativeMethods.VectorElementType ToNativeVectorElementType(this VectorElementTypes types)
        {
            switch (types)
            {
            case VectorElementTypes.UInt8:
                return(NativeMethods.VectorElementType.UInt8);

            case VectorElementTypes.UInt16:
                return(NativeMethods.VectorElementType.UInt16);

            case VectorElementTypes.UInt32:
                return(NativeMethods.VectorElementType.UInt32);

            case VectorElementTypes.Int8:
                return(NativeMethods.VectorElementType.Int8);

            case VectorElementTypes.Int16:
                return(NativeMethods.VectorElementType.Int16);

            case VectorElementTypes.Int32:
                return(NativeMethods.VectorElementType.Int32);

            case VectorElementTypes.Float:
                return(NativeMethods.VectorElementType.Float);

            case VectorElementTypes.Double:
                return(NativeMethods.VectorElementType.Double);

            default:
                throw new ArgumentOutOfRangeException(nameof(types), types, null);
            }
        }
Exemple #2
0
        public Vector()
        {
            if (!SupportTypes.TryGetValue(typeof(TType), out var type))
            {
                throw new NotSupportedException($"{typeof(TType).Name} does not support");
            }

            this._VectorElementTypes = type;
            this._ElementType        = type.ToNativeVectorElementType();

            this._Imp = this.CreateVectorImp(this._ElementType);

            this.NativePtr = Dlib.Native.vector_new(this._ElementType);
        }
Exemple #3
0
        internal Vector(IntPtr ptr, bool isEnabledDispose = true)
            : base(isEnabledDispose)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr));
            }

            if (!SupportTypes.TryGetValue(typeof(TType), out var type))
            {
                throw new NotSupportedException($"{typeof(TType).Name} does not support");
            }

            this.NativePtr = ptr;

            this._VectorElementTypes = type;
            this._ElementType        = type.ToNativeVectorElementType();

            this._Imp = this.CreateVectorImp(this._ElementType);

            this.NativePtr = ptr;
        }