Exemplo n.º 1
0
        public FullObjectDetection Detect(Array2DBase image, Rectangle rect)
        {
            this.ThrowIfDisposed();

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

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

            var inType = image.ImageType.ToNativeArray2DType();
            var ret    = Native.shape_predictor_operator(this.NativePtr, inType, image.NativePtr, rect.NativePtr, out var fullObjDetect);

            switch (ret)
            {
            case Dlib.Native.ErrorType.InputArrayTypeNotSupport:
                throw new ArgumentException($"Input {inType} is not supported.");
            }

            return(new FullObjectDetection(fullObjDetect));
        }
Exemplo n.º 2
0
        public static void DrawRectangle(Array2DBase image, Rectangle rect, HsiPixel 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.HsiPixel,
                image.NativePtr,
                rect.NativePtr,
                ref color,
                thickness);

            switch (ret)
            {
            case Native.ErrorType.ArrayTypeNotSupport:
                throw new ArgumentException($"{color} is not supported.");
            }
        }
Exemplo n.º 3
0
        public Rectangle Operator(Rectangle rectangle)
        {
            if (rectangle == null)
            {
                throw new ArgumentNullException(nameof(rectangle));
            }

            rectangle.ThrowIfDisposed();

            var ptr = Native.rectangle_transform_operator(this.NativePtr, rectangle.NativePtr);

            return(new Rectangle(ptr));
        }
Exemplo n.º 4
0
        public void AddOverlay(Rectangle rect, HsiPixel color)
        {
            this.ThrowIfDisposed();

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

            rect.ThrowIfDisposed();

            Native.image_window_add_overlay(this.NativePtr, rect.NativePtr, Dlib.Native.Array2DType.HsiPixel, ref color);
        }
Exemplo n.º 5
0
        public static Rectangle Translate(Rectangle rect, int x, int y)
        {
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            rect.ThrowIfDisposed();

            var result = Native.rectangle_translate_rect_xy(rect.NativePtr, x, y);

            return(new Rectangle(result));
        }
Exemplo n.º 6
0
        public Rectangle Intersect(Rectangle rect)
        {
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            rect.ThrowIfDisposed();

            var result = Native.rectangle_intersect(this.NativePtr, rect.NativePtr);

            return(new Rectangle(result));
        }
Exemplo n.º 7
0
        public static Rectangle CenteredRect(Rectangle rect, uint width, uint height)
        {
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            rect.ThrowIfDisposed();

            var result = Native.rectangle_centered_rect2(rect.NativePtr, width, height);

            return(new Rectangle(result));
        }
Exemplo n.º 8
0
        public static Rectangle Translate(Rectangle rect, Point point)
        {
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }
            if (point == null)
            {
                throw new ArgumentNullException(nameof(point));
            }

            rect.ThrowIfDisposed();
            point.ThrowIfDisposed();

            var result = Native.rectangle_translate_rect(rect.NativePtr, point.NativePtr);

            return(new Rectangle(result));
        }
Exemplo n.º 9
0
        public void Operator(Array2DBase inImage, Rectangle rect, Array2DBase outImage)
        {
            this.ThrowIfDisposed();

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

            inImage.ThrowIfDisposed();
            rect.ThrowIfDisposed();
            outImage.ThrowIfDisposed();

            var inType  = inImage.ImageType.ToNativeArray2DType();
            var outType = outImage.ImageType.ToNativeArray2DType();
            var ret     = Native.hough_transform_operator(
                this.NativePtr,
                inType,
                inImage.NativePtr,
                outType,
                outImage.NativePtr,
                rect.NativePtr);

            switch (ret)
            {
            case Dlib.Native.ErrorType.OutputArrayTypeNotSupport:
                throw new ArgumentException($"Output {outImage.ImageType} is not supported.");

            case Dlib.Native.ErrorType.InputArrayTypeNotSupport:
                throw new ArgumentException($"Input {inImage.ImageType} is not supported.");
            }
        }
Exemplo n.º 10
0
        public static void SumFilter(Array2DBase inImage, Array2DBase outImage, Rectangle rect)
        {
            if (inImage == null)
            {
                throw new ArgumentNullException(nameof(inImage));
            }
            if (outImage == null)
            {
                throw new ArgumentNullException(nameof(outImage));
            }
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            inImage.ThrowIfDisposed(nameof(inImage));
            outImage.ThrowIfDisposed(nameof(outImage));
            rect.ThrowIfDisposed(nameof(rect));

            if (inImage.Rows != outImage.Rows || inImage.Columns != outImage.Columns)
            {
                throw new ArgumentException();
            }

            var inType  = inImage.ImageType.ToNativeArray2DType();
            var outType = outImage.ImageType.ToNativeArray2DType();
            var ret     = Native.sum_filter(inType, inImage.NativePtr, outType, outImage.NativePtr, rect.NativePtr);

            switch (ret)
            {
            case Native.ErrorType.OutputArrayTypeNotSupport:
                throw new ArgumentException($"Output {outImage.ImageType} is not supported.");

            case Native.ErrorType.InputArrayTypeNotSupport:
                throw new ArgumentException($"Input {inImage.ImageType} is not supported.");
            }
        }