コード例 #1
0
        public static void DrawLine(Array2D <RgbPixel> image, Point p1, Point p2, RgbPixel color)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (p1 == null)
            {
                throw new ArgumentNullException(nameof(p1));
            }
            if (p2 == null)
            {
                throw new ArgumentNullException(nameof(p2));
            }

            image.ThrowIfDisposed();

            using (var np1 = p1.ToNative())
                using (var np2 = p2.ToNative())
                {
                    var ret = NativeMethods.draw_line(NativeMethods.Array2DType.RgbPixel,
                                                      image.NativePtr,
                                                      np1.NativePtr,
                                                      np2.NativePtr,
                                                      ref color);
                    switch (ret)
                    {
                    case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                        throw new ArgumentException($"{color} is not supported.");
                    }
                }
        }
コード例 #2
0
        /// <summary>
        /// Adds the given overlay rectangle into this object such that it will be displayed.
        /// </summary>
        /// <param name="rect">A <see cref="DRectangle"/> structure that represents the rectangle to be displayed.</param>
        /// <param name="color">A <see cref="RgbPixel"/> value that represents a color.</param>
        /// <exception cref="ObjectDisposedException"><see cref="ImageWindow"/> is disposed.</exception>
        public void AddOverlay(DRectangle rect, RgbPixel color)
        {
            this.ThrowIfDisposed();

            using (var native = rect.ToNative())
                NativeMethods.image_window_add_overlay3(this.NativePtr, native.NativePtr, NativeMethods.Array2DType.RgbPixel, ref color);
        }
コード例 #3
0
        public static RgbPixel ColormapJet(double value, double minVal, double maxVal)
        {
            var pixel = new RgbPixel();

            Native.colormap_jet(value, minVal, maxVal, ref pixel);
            return(pixel);
        }
コード例 #4
0
ファイル: Draw.cs プロジェクト: mannu598/DlibDotNet
        public static void DrawRectangle(Array2DBase image, Rectangle rect, RgbPixel color, uint thickness = 1)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            image.ThrowIfDisposed();
            rect.ThrowIfDisposed();

            var ret = Native.draw_rectangle(
                Native.Array2DType.RgbPixel,
                image.NativePtr,
                rect.NativePtr,
                ref color,
                thickness);

            switch (ret)
            {
            case Native.ErrorType.ArrayTypeNotSupport:
                throw new ArgumentException($"{color} is not supported.");
            }
        }
コード例 #5
0
ファイル: Draw.cs プロジェクト: mannu598/DlibDotNet
        public static void DrawLine(Array2DBase image, Point p1, Point p2, RgbPixel color)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (p1 == null)
            {
                throw new ArgumentNullException(nameof(p1));
            }
            if (p2 == null)
            {
                throw new ArgumentNullException(nameof(p2));
            }

            image.ThrowIfDisposed();
            p1.ThrowIfDisposed();
            p2.ThrowIfDisposed();

            var ret = Native.draw_line(
                Native.Array2DType.RgbPixel,
                image.NativePtr,
                p1.NativePtr,
                p2.NativePtr,
                ref color);

            switch (ret)
            {
            case Native.ErrorType.ArrayTypeNotSupport:
                throw new ArgumentException($"{color} is not supported.");
            }
        }
コード例 #6
0
ファイル: Colormaps.cs プロジェクト: zhuxb711/DlibDotNet
        public static RgbPixel ColormapHeat(double value, double minVal, double maxVal)
        {
            var pixel = new RgbPixel();

            NativeMethods.colormap_heat(value, minVal, maxVal, ref pixel);
            return(pixel);
        }
コード例 #7
0
        public void AddOverlay(IEnumerable <Rectangle> rects, RgbPixel color)
        {
            this.ThrowIfDisposed();

            if (rects == null)
            {
                throw new ArgumentNullException(nameof(rects));
            }

            using (var vector = new StdVector <Rectangle>(rects))
                NativeMethods.image_window_add_overlay2(this.NativePtr, vector.NativePtr, NativeMethods.Array2DType.RgbPixel, ref color);
        }
コード例 #8
0
        public void AddOverlay(Rectangle rect, RgbPixel color, string str)
        {
            if (str == null)
            {
                throw new ArgumentNullException(nameof(str));
            }

            this.ThrowIfDisposed();

            using (var native = rect.ToNative())
                using (var pStr = new StdString(str))
                    NativeMethods.image_window_add_overlay6(this.NativePtr, native.NativePtr, NativeMethods.Array2DType.RgbPixel, ref color, pStr.NativePtr);
        }
コード例 #9
0
        public void AddOverlay(DRectangle rect, RgbPixel color)
        {
            this.ThrowIfDisposed();

            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            rect.ThrowIfDisposed();

            Native.image_window_add_overlay3(this.NativePtr, rect.NativePtr, Dlib.Native.Array2DType.RgbPixel, ref color);
        }
コード例 #10
0
        public void AddOverlay(IEnumerable <Vector <double> > points, RgbPixel color)
        {
            this.ThrowIfDisposed();

            if (points == null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            points.ThrowIfDisposed();

            using (var vector = new StdVector <Vector <double> >(points))
                NativeMethods.perspective_window_add_overlay3(this.NativePtr, vector.NativePtr, NativeMethods.Array2DType.RgbPixel, ref color);
        }
コード例 #11
0
        public static void AssignAllPpixels(Array2D <RgbPixel> dest, RgbPixel pixel)
        {
            if (dest == null)
            {
                throw new ArgumentNullException(nameof(dest));
            }

            dest.ThrowIfDisposed(nameof(dest));

            var outType = dest.ImageType.ToNativeArray2DType();
            var ret     = Native.assign_all_pixels(outType, dest.NativePtr, Native.Array2DType.RgbPixel, ref pixel);

            switch (ret)
            {
            case Native.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException("Output or input type is not supported.");
            }
        }
コード例 #12
0
        public void AddOverlay(Vector <double> p1, Vector <double> p2, RgbPixel color)
        {
            this.ThrowIfDisposed();

            if (p1 == null)
            {
                throw new ArgumentNullException(nameof(p1));
            }
            if (p2 == null)
            {
                throw new ArgumentNullException(nameof(p2));
            }

            p1.ThrowIfDisposed();
            p2.ThrowIfDisposed();

            NativeMethods.perspective_window_add_overlay(this.NativePtr, p1.NativePtr, p2.NativePtr, NativeMethods.Array2DType.RgbPixel, ref color);
        }
コード例 #13
0
        public static void FillRect(Array2D <RgbPixel> image, Rectangle rect, RgbPixel color)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed();

            using (var native = rect.ToNative())
            {
                var ret = NativeMethods.fill_rect(NativeMethods.Array2DType.RgbPixel,
                                                  image.NativePtr,
                                                  native.NativePtr,
                                                  ref color);
                switch (ret)
                {
                case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                    throw new ArgumentException($"{color} is not supported.");
                }
            }
        }
コード例 #14
0
 public OverlayLine(Point p1, Point p2, RgbPixel pixel)
 {
     using (var native1 = p1.ToNative())
         using (var native2 = p2.ToNative())
             this.NativePtr = Native.image_window_overlay_line_new_rgb(native1.NativePtr, native2.NativePtr, pixel);
 }
コード例 #15
0
 public static extern IntPtr image_window_overlay_line_new_rgb(IntPtr p1, IntPtr p2, RgbPixel pixel);
コード例 #16
0
ファイル: ImageWindow.cs プロジェクト: wenguoxing/DlibDotNet
 public static extern NativeMethods.ErrorType image_window_add_overlay2(IntPtr window, IntPtr vectorOfRect, NativeMethods.Array2DType type, ref RgbPixel color);
コード例 #17
0
ファイル: CanvasDrawing.cs プロジェクト: TrojanOlx/AI
 public static extern ErrorType draw_rectangle_canvas(IntPtr canvas, IntPtr rect, IntPtr area, Array2DType pixelType, ref RgbPixel color);
コード例 #18
0
ファイル: CanvasDrawing.cs プロジェクト: TrojanOlx/AI
 public static extern ErrorType draw_line_canvas_infinity(IntPtr canvas, IntPtr p1, IntPtr p2, Array2DType pixelType, ref RgbPixel color);
コード例 #19
0
 public static extern void assign_pixel_rgb_hsi(ref RgbPixel dest, ref HsiPixel src);
コード例 #20
0
 public static extern void render_face_detections2(IntPtr dets,
                                                   ref RgbPixel color,
                                                   IntPtr vectorOfLine);
コード例 #21
0
ファイル: Dlib.cs プロジェクト: mannu598/DlibDotNet
 public static extern void array2d_set_row_column_rgb_pixel(IntPtr row, int column, RgbPixel value);
コード例 #22
0
 public static extern void colormap_jet(double value, double min_val, double max_val, ref RgbPixel pixel);
コード例 #23
0
ファイル: OverlayDot.cs プロジェクト: wenguoxing/DlibDotNet
 public static extern bool perspective_window_overlay_dot_color(IntPtr dot, ref RgbPixel color);
コード例 #24
0
 public static extern void assign_pixel_rgb_lab(ref RgbPixel dest, ref LabPixel src);
コード例 #25
0
        public static ImageWindow.OverlayLine[] RenderFaceDetections(FullObjectDetection detection, RgbPixel color)
        {
            if (detection == null)
            {
                throw new ArgumentNullException(nameof(detection));
            }

            detection.ThrowIfDisposed(nameof(detection));

            using (var vector = new StdVector <ImageWindow.OverlayLine>())
            {
                Native.render_face_detections(detection.NativePtr, ref color, vector.NativePtr);
                return(vector.ToArray());
            }
        }
コード例 #26
0
ファイル: Dlib.cs プロジェクト: mannu598/DlibDotNet
 public static extern void matrix_operator_get_row_column_rgb_pixel(IntPtr matrix, int row, int column, out RgbPixel ret);
コード例 #27
0
        public static ImageWindow.OverlayLine[] RenderFaceDetections(IEnumerable <FullObjectDetection> detection, RgbPixel color)
        {
            if (detection == null)
            {
                throw new ArgumentNullException(nameof(detection));
            }

            using (var vectorIn = new StdVector <FullObjectDetection>(detection))
                using (var vectorOut = new StdVector <ImageWindow.OverlayLine>())
                {
                    Native.render_face_detections(vectorIn.NativePtr, ref color, vectorOut.NativePtr);
                    return(vectorOut.ToArray());
                }
        }
コード例 #28
0
ファイル: Dlib.cs プロジェクト: mannu598/DlibDotNet
 public static extern void matrix_operator_set_row_column_rgb_pixel(IntPtr matrix, int row, int column, RgbPixel value);
コード例 #29
0
ファイル: Matrix.cs プロジェクト: xiongge0704/DlibDotNet
        public TElement[] ToArray()
        {
            this.ThrowIfDisposed();

            TElement[] result;
            NativeMethods.ErrorType err;

            var templateRows    = this.TemplateRows;
            var templateColumns = this.TemplateColumns;

            switch (this._MatrixElementTypes)
            {
            case MatrixElementTypes.UInt8:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new byte[row * column];
                    fixed(byte *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.UInt16:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new ushort[row * column];
                    fixed(ushort *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.UInt32:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new uint[row * column];
                    fixed(uint *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Int8:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new sbyte[row * column];
                    fixed(sbyte *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Int16:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new short[row * column];
                    fixed(short *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Int32:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new int[row * column];
                    fixed(int *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Float:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new float[row * column];
                    fixed(float *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Double:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new double[row * column];
                    fixed(double *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.RgbPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new RgbPixel[row * column];
                    fixed(RgbPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.BgrPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new BgrPixel[row * column];
                    fixed(BgrPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.RgbAlphaPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new RgbAlphaPixel[row * column];
                    fixed(RgbAlphaPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.HsiPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new HsiPixel[row * column];
                    fixed(HsiPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.LabPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new LabPixel[row * column];
                    fixed(LabPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (err)
            {
            case NativeMethods.ErrorType.MatrixElementTypeNotSupport:
                throw new ArgumentException($"{this._ElementType} is not supported.");

            case NativeMethods.ErrorType.MatrixElementTemplateSizeNotSupport:
                throw new ArgumentException($"{nameof(this.TemplateColumns)} or {nameof(this.TemplateRows)} is not supported.");
            }

            return(result);
        }
コード例 #30
0
 public static extern void assign_pixel_rgbalpha_rgb(ref RgbAlphaPixel dest, ref RgbPixel src);