Example #1
0
        public Matrix(Array2DBase array)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            array.ThrowIfDisposed();

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

            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();
            var ret = Dlib.Native.mat_matrix(array.ImageType.ToNativeArray2DType(),
                                             array.NativePtr,
                                             0,
                                             0,
                                             this._ElementType,
                                             out var ptr);

            switch (ret)
            {
            case Dlib.Native.ErrorType.MatrixElementTypeNotSupport:
                throw new ArgumentException($"{array.ImageType} can not convert to {type}.");
            }

            this.NativePtr = ptr;
            this._Indexer  = this.CreateIndexer(type);
        }
Example #2
0
            public StdVectorMatrixImp()
            {
                Matrix <TElement> .TryParse <TElement>(out var type);

                this._Type       = type;
                this._NativeType = this._Type.ToNativeMatrixElementType();
            }
Example #3
0
 public static extern Dlib.Native.ErrorType loss_mmod_operator_matrixs(IntPtr obj,
                                                                       int type,
                                                                       Dlib.Native.MatrixElementType element_type,
                                                                       IntPtr matrixs,
                                                                       int templateRows,
                                                                       int templateColumns,
                                                                       ulong batchSize,
                                                                       out IntPtr ret);
Example #4
0
 public static extern Dlib.Native.ErrorType random_cropper_operator(
     IntPtr cropper,
     uint numCrops,
     Dlib.Native.MatrixElementType type,
     IntPtr images,
     IntPtr rects,
     IntPtr crops,
     IntPtr cropRects);
        internal MatrixOp(Dlib.Native.ElementType elementType, MatrixElementTypes type, IntPtr ptr, int templateRows = 0, int temlateColumns = 0)
        {
            this._ElementType       = elementType;
            this._MatrixElementType = type.ToNativeMatrixElementType();
            this.NativePtr          = ptr;

            this.TemplateRows    = templateRows;
            this.TemplateColumns = temlateColumns;
        }
Example #6
0
            public StdVectorMatrixImp(int templateRows, int templateColumns)
            {
                Matrix <TElement> .TryParse <TElement>(out var type);

                this._Type       = type;
                this._NativeType = this._Type.ToNativeMatrixElementType();

                this._TemplateRows    = templateRows;
                this._TemplateColumns = templateColumns;
            }
Example #7
0
        internal MatrixRangeExp(IntPtr ptr)
        {
            if (!SupportTypes.TryGetValue(typeof(T), out var type))
            {
                throw new NotSupportedException($"{typeof(T).Name} does not support");
            }

            this._NativeMatrixElementType = type.ToNativeMatrixElementType();
            this._MatrixElementType       = type;
            this.NativePtr = ptr;
        }
Example #8
0
        public Matrix()
        {
            if (!SupportTypes.TryGetValue(typeof(T), out var type))
            {
                throw new NotSupportedException($"{typeof(T).Name} does not support");
            }

            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();
            this.NativePtr           = Dlib.Native.matrix_new(this._ElementType);
        }
Example #9
0
            internal Row(IntPtr ptr, Dlib.Native.MatrixElementType type, Array2DMatrixBase parent)
            {
                if (ptr == IntPtr.Zero)
                {
                    throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr));
                }

                this._Parent   = parent ?? throw new ArgumentNullException(nameof(parent));
                this.NativePtr = ptr;
                this._Type     = type;
            }
Example #10
0
        public Matrix()
        {
            if (!MatrixBase.TryParse(typeof(TElement), out var type))
            {
                throw new NotSupportedException($"{typeof(TElement).Name} does not support");
            }

            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();
            this.NativePtr           = Dlib.Native.matrix_new(this._ElementType);

            this._Indexer = this.CreateIndexer(type);
        }
Example #11
0
            internal SurfPointMatrix(IntPtr ptr, bool isEnableDispose)
                : base(ptr, 0, 0, isEnableDispose)
            {
                if (!SupportMatrixTypes.TryGetValue(typeof(T), out var matrixType))
                {
                    throw new NotSupportedException($"{typeof(T).Name} does not support");
                }

                this._MatrixElementType = matrixType.ToNativeMatrixElementType();

                this.NativePtr         = ptr;
                this.MatrixElementType = matrixType;
            }
Example #12
0
        internal Matrix(IntPtr ptr, MatrixElementTypes type)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr));
            }

            this.NativePtr           = ptr;
            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();

            this._Indexer = this.CreateIndexer(type);
        }
        public LinearKernel(int templateRow = 0, int templateColumn = 0)
        {
            using (var tmp = new T())
            {
                this._MatrixElementTypes = tmp.MatrixElementType;
                this._ElementType        = this._MatrixElementTypes.ToNativeMatrixElementType();

                this.TemplateRows    = templateRow;
                this.TemplateColumns = templateColumn;

                this.NativePtr = Dlib.Native.linear_kernel_new(this._ElementType, templateRow, templateColumn);
            }
        }
Example #14
0
        public MatrixRangeExp(T start, T end, uint num)
        {
            if (!SupportTypes.TryGetValue(typeof(T), out var type))
            {
                throw new NotSupportedException($"{typeof(T).Name} does not support");
            }

            this._NativeMatrixElementType = type.ToNativeMatrixElementType();
            this._MatrixElementType       = type;

            var param = this.CreataParam(start, end, false, default(T), true, num);

            this.NativePtr = Dlib.Native.matrix_range_exp_create(this._NativeMatrixElementType, ref param);
        }
Example #15
0
        public Array2DMatrix(int rows, int columns)
        {
            if (!SupportMatrixTypes.TryGetValue(typeof(T), out var matrixType))
            {
                throw new NotSupportedException($"{typeof(T).Name} does not support");
            }

            this._MatrixElementType = matrixType.ToNativeMatrixElementType();

            this.NativePtr = Dlib.Native.array2d_matrix_new1(this._MatrixElementType, rows, columns);
            if (this.NativePtr == IntPtr.Zero)
            {
                throw new ArgumentException($"{matrixType} is not supported.");
            }

            this.MatrixElementType = matrixType;
        }
Example #16
0
        public Matrix(byte[] array, int row, int column, int elementSize)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }
            if (row < 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(row)}", $"{nameof(row)} should be positive value.");
            }
            if (column < 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(column)}", $"{nameof(column)} should be positive value.");
            }
            if (column < 1)
            {
                throw new ArgumentOutOfRangeException($"{nameof(elementSize)} should be more than 1");
            }
            if (array.Length != row * column * elementSize)
            {
                throw new ArgumentOutOfRangeException($"{nameof(array)}.Length should equalt to {nameof(column)}x{nameof(column)}*{nameof(elementSize)}.");
            }

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

            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();

            var size = ElementSizeDictionary[this._ElementType];

            if (size != elementSize)
            {
                throw new ArgumentOutOfRangeException($"The size of {typeof(TElement).Name} does not equalt to {nameof(elementSize)}.");
            }

            unsafe
            {
                fixed(byte *src = &array[0])
                this.NativePtr = Dlib.Native.matrix_new3(this._ElementType, row, column, src);
            }

            this._Indexer = this.CreateIndexer(type);
        }
Example #17
0
        public Matrix(int row, int column)
        {
            if (!SupportTypes.TryGetValue(typeof(T), out var type))
            {
                throw new NotSupportedException($"{typeof(T).Name} does not support");
            }
            if (row < 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(row)}", $"{nameof(row)} should be positive value.");
            }
            if (column < 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(column)}", $"{nameof(column)} should be positive value.");
            }

            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();
            this.NativePtr           = Dlib.Native.matrix_new1(this._ElementType, row, column);
        }
Example #18
0
        internal Matrix(IntPtr ptr, bool isEnabledDispose = true)
            : base(isEnabledDispose)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr));
            }

            if (!MatrixBase.TryParse(typeof(TElement), out var type))
            {
                throw new NotSupportedException($"{typeof(TElement).Name} does not support");
            }

            this.NativePtr           = ptr;
            this._MatrixElementTypes = type;
            this._ElementType        = type.ToNativeMatrixElementType();

            this._Indexer = this.CreateIndexer(type);
        }
 public static extern void matrix_op_op_join_rows_delete(Dlib.Native.MatrixElementType type, IntPtr obj, int templateRows, int templateColumns);
Example #20
0
 public static extern Dlib.Native.ErrorType shape_predictor_matrix_operator_mmod_rect(IntPtr detector,
                                                                                      Dlib.Native.MatrixElementType imgType,
                                                                                      IntPtr img,
                                                                                      IntPtr rect,
                                                                                      out IntPtr fullObjDetect);
 public static extern Dlib.Native.ErrorType loss_multiclass_log_per_pixel_operator_matrixs(IntPtr obj, int type, Dlib.Native.MatrixElementType element_type, IntPtr matrixs, int templateRows, int templateColumns, out IntPtr ret);
 public static extern Dlib.Native.ErrorType matrix_op_op_join_rows_nr(Dlib.Native.MatrixElementType type, IntPtr obj, int templateRows, int templateColumns, out int ret);
Example #23
0
 public static extern Dlib.Native.ErrorType image_window_set_image_matrix(IntPtr window, Dlib.Native.MatrixElementType type, IntPtr matrix);
Example #24
0
 public static extern IntPtr image_window_new_matrix1(Dlib.Native.MatrixElementType type, IntPtr image);
 public static extern Dlib.Native.ErrorType matrix_op_op_trans_operator_left_shift(Dlib.Native.MatrixElementType type, IntPtr obj, int templateRows, int templateColumns, IntPtr stream);
Example #26
0
 public static extern Dlib.Native.ErrorType dnn_trainer_loss_multiclass_log_train(IntPtr trainer,
                                                                                  int type,
                                                                                  Dlib.Native.MatrixElementType dataElementType,
                                                                                  IntPtr data,
                                                                                  Dlib.Native.MatrixElementType labelElementType,
                                                                                  IntPtr label);
Example #27
0
 public static extern IntPtr image_window_new_matrix2(Dlib.Native.MatrixElementType type, IntPtr image, byte[] title);
 public static extern Dlib.Native.ErrorType matrix_op_op_std_vect_to_mat_nc(Dlib.Native.MatrixElementType type, IntPtr obj, int templateRows, int templateColumns, out int ret);
Example #29
0
 public static extern Dlib.Native.ErrorType frontal_face_detector_matrix_operator(
     IntPtr detector,
     Dlib.Native.MatrixElementType imgType,
     IntPtr img,
     double adjustThreshold,
     IntPtr dets);
Example #30
0
 internal RowHsiPixel(IntPtr ptr, Dlib.Native.MatrixElementType type, Array2DMatrixBase parent)
     : base(ptr, type, parent)
 {
 }