コード例 #1
0
        public static IEnumerable <SurfPoint> GetSurfPoints(Array2DBase image, long maxPoints = 10000, double detectionThreshold = 30.0)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed();

            if (maxPoints <= 0)
            {
                throw  new ArgumentOutOfRangeException();
            }
            if (detectionThreshold < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            using (var points = new StdVector <SurfPoint>())
            {
                var array2DType = image.ImageType.ToNativeArray2DType();
                var ret         = Native.get_surf_points(array2DType, image.NativePtr, maxPoints, detectionThreshold, points.NativePtr);
                if (ret == Native.ErrorType.ArrayTypeNotSupport)
                {
                    throw new ArgumentException($"{image.ImageType} is not supported.");
                }

                return(points.ToArray());
            }
        }
コード例 #2
0
ファイル: Draw.cs プロジェクト: mannu598/DlibDotNet
        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.");
            }
        }
コード例 #3
0
        /// <summary>
        /// This function saves image to disk as PNG (Portable Network Graphics) file.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="path">A string that contains the name of the file to which to save image.</param>
        /// <exception cref="ArgumentException">The specified type of image is not supported.</exception>
        /// <exception cref="ArgumentException"><see cref="TwoDimensionObjectBase.Rows"/> or <see cref="TwoDimensionObjectBase.Columns"/> are less than or equal to zero.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="image"/> or <paramref name="path"/> is null.</exception>
        /// <exception cref="ObjectDisposedException"><paramref name="image"/> is disposed.</exception>
        public static void SavePng(Array2DBase image, string path)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed();

            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (image.Rows <= 0 || image.Columns <= 0)
            {
                throw new ArgumentException($"{nameof(image.Columns)} and {nameof(image.Rows)} is less than or equal to zero.", nameof(image));
            }

            var str = Encoding.GetBytes(path);

            var array2DType = image.ImageType.ToNativeArray2DType();
            var ret         = NativeMethods.save_png(array2DType, image.NativePtr, str);

            if (ret == NativeMethods.ErrorType.Array2DTypeTypeNotSupport)
            {
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }
        }
コード例 #4
0
        /// <summary>
        /// This function saves image to disk as DNG (Digital Negative) file.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="path">A string that contains the name of the file to which to save image.</param>
        /// <exception cref="ArgumentException">The specified type of image is not supported.</exception>
        /// <exception cref="ArgumentException"><see cref="TwoDimensionObjectBase.Rows"/> or <see cref="TwoDimensionObjectBase.Columns"/> are less than or equal to zero.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="image"/> or <paramref name="path"/> is null.</exception>
        /// <exception cref="ObjectDisposedException"><paramref name="image"/> is disposed.</exception>
        public static void SaveDng(Array2DBase image, string path)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed();

            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            // NOTE: save_dng does not throw exception but it does NOT output any file.
            //       So it should throw exception in this timing!!
            if (image.Rows <= 0 || image.Columns <= 0)
            {
                throw new ArgumentException($"{nameof(image.Columns)} and {nameof(image.Rows)} is less than or equal to zero.", nameof(image));
            }

            var str = Encoding.GetBytes(path);

            var array2DType = image.ImageType.ToNativeArray2DType();
            var ret         = NativeMethods.save_dng(array2DType, image.NativePtr, str);

            if (ret == NativeMethods.ErrorType.Array2DTypeTypeNotSupport)
            {
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }
        }
コード例 #5
0
        public static void AssignImage(Array2DBase src, Array2DBase dest)
        {
            if (src == null)
            {
                throw new ArgumentNullException(nameof(src));
            }
            if (dest == null)
            {
                throw new ArgumentNullException(nameof(dest));
            }

            src.ThrowIfDisposed(nameof(src));
            dest.ThrowIfDisposed(nameof(dest));

            var inType  = src.ImageType.ToNativeArray2DType();
            var outType = dest.ImageType.ToNativeArray2DType();
            var ret     = Native.assign_image(outType, dest.NativePtr, inType, src.NativePtr);

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

            case Native.ErrorType.InputArrayTypeNotSupport:
                throw new ArgumentException($"Input {inType} is not supported.");
            }
        }
コード例 #6
0
ファイル: Draw.cs プロジェクト: wenguoxing/DlibDotNet
        public static void DrawLine(Array2DBase image, Point p1, Point p2, ushort 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.UInt16,
                                                      image.NativePtr,
                                                      np1.NativePtr,
                                                      np2.NativePtr,
                                                      ref color);
                    switch (ret)
                    {
                    case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                        throw new ArgumentException($"{color} is not supported.");
                    }
                }
        }
コード例 #7
0
        public double Update(Array2DBase image, DRectangle guess)
        {
            this.ThrowIfDisposed();

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

            image.ThrowIfDisposed();

            if (guess.IsEmpty)
            {
                throw new ArgumentException($"{nameof(guess)} must not be empty");
            }

            var inType = image.ImageType.ToNativeArray2DType();

            using (var native = guess.ToNative())
            {
                var ret = Native.correlation_tracker_update(this.NativePtr, inType, image.NativePtr, native.NativePtr, out var confident);
                switch (ret)
                {
                case Dlib.Native.ErrorType.InputArrayTypeNotSupport:
                    throw new ArgumentException($"Input {inType} is not supported.");
                }

                return(confident);
            }
        }
コード例 #8
0
        public void StartTrack(Array2DBase image, DRectangle rect)
        {
            this.ThrowIfDisposed();

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

            image.ThrowIfDisposed();

            if (rect.IsEmpty)
            {
                throw new ArgumentException($"{nameof(rect)} must not be empty");
            }

            var inType = image.ImageType.ToNativeArray2DType();

            using (var native = rect.ToNative())
            {
                var ret = Native.correlation_tracker_start_track(this.NativePtr, inType, image.NativePtr, native.NativePtr);
                switch (ret)
                {
                case Dlib.Native.ErrorType.InputArrayTypeNotSupport:
                    throw new ArgumentException($"Input {inType} is not supported.");
                }
            }
        }
コード例 #9
0
        public static void EqualizeHistogram <T>(Array2DBase image, out Array2D <T> outImage)
            where T : struct
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed();

            if (!Array2D <T> .TryParse <T>(out _))
            {
                throw new NotSupportedException();
            }

            outImage = new Array2D <T>();

            var inType  = image.ImageType.ToNativeArray2DType();
            var outType = outImage.ImageType.ToNativeArray2DType();
            var ret     = NativeMethods.equalize_histogram_array2d_2(inType,
                                                                     image.NativePtr,
                                                                     outType,
                                                                     outImage.NativePtr);

            switch (ret)
            {
            case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException($"Input {inType} or Output {outType} is not supported.");
            }
        }
コード例 #10
0
ファイル: Draw.cs プロジェクト: mannu598/DlibDotNet
        public static void DrawLine(Array2DBase image, Point p1, Point p2, float 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.Float,
                image.NativePtr,
                p1.NativePtr,
                p2.NativePtr,
                ref color);

            switch (ret)
            {
            case Native.ErrorType.ArrayTypeNotSupport:
                throw new ArgumentException($"{color} is not supported.");
            }
        }
コード例 #11
0
        public static IEnumerable <Rectangle> FindCandidateObjectLocations(
            Array2DBase image,
            MatrixRangeExp <double> kvals,
            uint minSize = 20,
            uint maxMergingIterations = 50)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (kvals == null)
            {
                throw new ArgumentNullException(nameof(kvals));
            }

            var array2DType = image.ImageType.ToNativeArray2DType();

            using (var dets = new StdVector <Rectangle>())
            {
                var ret = Native.find_candidate_object_locations(array2DType, image.NativePtr, dets.NativePtr, IntPtr.Zero, minSize, maxMergingIterations);
                if (ret == Native.ErrorType.ArrayTypeNotSupport)
                {
                    throw new ArgumentException($"{image.ImageType} is not supported.");
                }
                return(dets.ToArray());
            }
        }
コード例 #12
0
ファイル: Interpolation.cs プロジェクト: TrojanOlx/AI
        public static void RotateImage(Array2DBase inputImage, Array2DBase outputImage, double angle, InterpolationTypes interpolationTypes = InterpolationTypes.Quadratic)
        {
            if (inputImage == null)
            {
                throw new ArgumentNullException(nameof(inputImage));
            }
            if (outputImage == null)
            {
                throw new ArgumentNullException(nameof(outputImage));
            }
            if (inputImage == outputImage)
            {
                throw new ArgumentException();
            }

            inputImage.ThrowIfDisposed(nameof(inputImage));
            outputImage.ThrowIfDisposed(nameof(outputImage));

            var inType  = inputImage.ImageType.ToNativeArray2DType();
            var outType = outputImage.ImageType.ToNativeArray2DType();
            var ret     = NativeMethods.rotate_image2(inType, inputImage.NativePtr, outType, outputImage.NativePtr, angle, interpolationTypes.ToNativeInterpolationTypes());

            switch (ret)
            {
            case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException("Output or input type is not supported.");
            }
        }
コード例 #13
0
        public static void GaussianBlur(Array2DBase inImage, Array2DBase outImage, double sigma = 1, int maxSize = 1001)
        {
            if (inImage == null)
            {
                throw new ArgumentNullException(nameof(inImage));
            }
            if (outImage == null)
            {
                throw new ArgumentNullException(nameof(outImage));
            }
            if (!(sigma > 0))
            {
                throw new ArgumentOutOfRangeException(nameof(sigma));
            }
            if (!(0 < maxSize && maxSize % 2 != 0))
            {
                throw new ArgumentOutOfRangeException(nameof(maxSize));
            }

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

            var inType  = inImage.ImageType.ToNativeArray2DType();
            var outType = outImage.ImageType.ToNativeArray2DType();
            var ret     = Native.gaussian_blur(inType, inImage.NativePtr, outType, outImage.NativePtr, sigma, maxSize);

            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.");
            }
        }
コード例 #14
0
        public void Operator(Array2DBase inImage, Rectangle rect, Array2DBase outImage)
        {
            this.ThrowIfDisposed();

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

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

            var inType  = inImage.ImageType.ToNativeArray2DType();
            var outType = outImage.ImageType.ToNativeArray2DType();

            using (var native = rect.ToNative())
            {
                var ret = Native.hough_transform_operator(
                    this.NativePtr,
                    inType,
                    inImage.NativePtr,
                    outType,
                    outImage.NativePtr,
                    native.NativePtr);
                switch (ret)
                {
                case Dlib.Native.ErrorType.Array2DTypeTypeNotSupport:
                    throw new ArgumentException("Output or input type is not supported.");
                }
            }
        }
コード例 #15
0
ファイル: Interpolation.cs プロジェクト: TrojanOlx/AI
        public static void FlipImageUpDown(Array2DBase inputImage, Array2DBase outputImage)
        {
            if (inputImage == null)
            {
                throw new ArgumentNullException(nameof(inputImage));
            }
            if (outputImage == null)
            {
                throw new ArgumentNullException(nameof(outputImage));
            }
            if (inputImage == outputImage)
            {
                throw new ArgumentException();
            }

            inputImage.ThrowIfDisposed(nameof(inputImage));
            outputImage.ThrowIfDisposed(nameof(outputImage));

            var inType  = inputImage.ImageType.ToNativeArray2DType();
            var outType = outputImage.ImageType.ToNativeArray2DType();
            var ret     = NativeMethods.flip_image_up_down(inType, inputImage.NativePtr, outType, outputImage.NativePtr);

            switch (ret)
            {
            case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException("Output or input type is not supported.");
            }
        }
コード例 #16
0
ファイル: Interpolation.cs プロジェクト: tnw513/DlibDotNet
        public static void TransformImage(Array2DBase inputImage, Array2DBase outputImage, PointTransformBase pointTransform, InterpolationTypes interpolationTypes = InterpolationTypes.Quadratic)
        {
            if (inputImage == null)
            {
                throw new ArgumentNullException(nameof(inputImage));
            }
            if (outputImage == null)
            {
                throw new ArgumentNullException(nameof(outputImage));
            }
            if (pointTransform == null)
            {
                throw new ArgumentNullException(nameof(pointTransform));
            }
            if (inputImage == outputImage)
            {
                throw new ArgumentException();
            }

            inputImage.ThrowIfDisposed(nameof(inputImage));
            outputImage.ThrowIfDisposed(nameof(outputImage));

            var inType  = inputImage.ImageType.ToNativeArray2DType();
            var outType = outputImage.ImageType.ToNativeArray2DType();
            var ret     = Native.transform_image(inType, inputImage.NativePtr, outType, outputImage.NativePtr, pointTransform.GetNativePointMappingTypes(), pointTransform.NativePtr, interpolationTypes.ToNativeInterpolationTypes());

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

            case Native.ErrorType.OutputArrayTypeNotSupport:
                throw new ArgumentException($"Output {outputImage.ImageType} is not supported.");
            }
        }
コード例 #17
0
ファイル: Interpolation.cs プロジェクト: tnw513/DlibDotNet
        public static void FlipImageLeftRight(Array2DBase inputImage, Array2DBase outputImage)
        {
            if (inputImage == null)
            {
                throw new ArgumentNullException(nameof(inputImage));
            }
            if (outputImage == null)
            {
                throw new ArgumentNullException(nameof(outputImage));
            }
            if (inputImage == outputImage)
            {
                throw new ArgumentException();
            }

            inputImage.ThrowIfDisposed(nameof(inputImage));
            outputImage.ThrowIfDisposed(nameof(outputImage));

            var inType  = inputImage.ImageType.ToNativeArray2DType();
            var outType = outputImage.ImageType.ToNativeArray2DType();
            var ret     = Native.flip_image_left_right2(inType, inputImage.NativePtr, outType, outputImage.NativePtr);

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

            case Native.ErrorType.OutputArrayTypeNotSupport:
                throw new ArgumentException($"Output {outputImage.ImageType} is not supported.");
            }
        }
コード例 #18
0
ファイル: Interpolation.cs プロジェクト: tnw513/DlibDotNet
        public static void ResizeImage(Array2DBase inputImage, Array2DBase outputImage, InterpolationTypes interpolationTypes = InterpolationTypes.Bilinear)
        {
            if (inputImage == null)
            {
                throw new ArgumentNullException(nameof(inputImage));
            }
            if (outputImage == null)
            {
                throw new ArgumentNullException(nameof(outputImage));
            }
            if (inputImage == outputImage)
            {
                throw new ArgumentException();
            }

            inputImage.ThrowIfDisposed(nameof(inputImage));
            outputImage.ThrowIfDisposed(nameof(outputImage));

            var inType  = inputImage.ImageType.ToNativeArray2DType();
            var outType = outputImage.ImageType.ToNativeArray2DType();
            var ret     = Native.resize_image2(inType, inputImage.NativePtr, outType, outputImage.NativePtr, interpolationTypes.ToNativeInterpolationTypes());

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

            case Native.ErrorType.OutputArrayTypeNotSupport:
                throw new ArgumentException($"Output {outputImage.ImageType} is not supported.");
            }
        }
コード例 #19
0
ファイル: Matrix.cs プロジェクト: wenguoxing/DlibDotNet
        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 = NativeMethods.mat_matrix(array.ImageType.ToNativeArray2DType(),
                                               array.NativePtr,
                                               0,
                                               0,
                                               this._ElementType,
                                               out var ptr);

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

            this.NativePtr = ptr;
            this._Indexer  = this.CreateIndexer(type);
        }
コード例 #20
0
ファイル: Dlib.cs プロジェクト: mannu598/DlibDotNet
        public static void SaveJpeg(Array2DBase image, string path, int quality = 75)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (image.Rows <= 0 || image.Columns <= 0)
            {
                throw new ArgumentException($"{nameof(image.Columns)} and {nameof(image.Rows)} is less than or equal to zero.", nameof(image));
            }
            if (quality < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(quality), $"{nameof(quality)} is less than zero.");
            }
            if (quality > 100)
            {
                throw new ArgumentOutOfRangeException(nameof(quality), $"{nameof(quality)} is greater than 100.");
            }

            var str = Encoding.UTF8.GetBytes(path);

            var array2DType = image.ImageType.ToNativeArray2DType();
            var ret         = Native.save_jpeg(array2DType, image.NativePtr, str, quality);

            if (ret == Native.ErrorType.ArrayTypeNotSupport)
            {
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }
        }
コード例 #21
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));
            }

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

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

            var inType  = inImage.ImageType.ToNativeArray2DType();
            var outType = outImage.ImageType.ToNativeArray2DType();

            using (var native = rect.ToNative())
            {
                var ret = NativeMethods.sum_filter(inType, inImage.NativePtr, outType, outImage.NativePtr, native.NativePtr);
                switch (ret)
                {
                case ErrorType.Array2DTypeTypeNotSupport:
                    throw new ArgumentException("Output or input type is not supported.");
                }
            }
        }
コード例 #22
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));
        }
コード例 #23
0
        public Point GetBestHoughPoint(Array2DBase image, Point point)
        {
            this.ThrowIfDisposed();

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

            image.ThrowIfDisposed();

            var inType = image.ImageType.ToNativeArray2DType();

            using (var native = point.ToNative())
            {
                var ret = Native.hough_transform_get_best_hough_point(
                    this.NativePtr,
                    native.NativePtr,
                    inType,
                    image.NativePtr,
                    out var resultPoint);
                switch (ret)
                {
                case Dlib.Native.ErrorType.ArrayTypeNotSupport:
                    throw new ArgumentException($"Input {image.ImageType} is not supported.");
                }

                return(new Point(resultPoint));
            }
        }
コード例 #24
0
            internal Row(IntPtr ptr, ImageTypes type, Array2DBase 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;
            }
コード例 #25
0
        public ImageWindow(Array2DBase image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed(nameof(image));

            this.NativePtr = NativeMethods.image_window_new_array2d1(image.ImageType.ToNativeArray2DType(), image.NativePtr);
        }
コード例 #26
0
ファイル: ImageWindow.cs プロジェクト: xiongge0704/DlibDotNet
        public ImageWindow(Array2DBase image, string title)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (title == null)
            {
                throw new ArgumentNullException(nameof(title));
            }

            image.ThrowIfDisposed(nameof(image));

            var str = Dlib.Encoding.GetBytes(title);

            this.NativePtr = NativeMethods.image_window_new_array2d2(image.ImageType.ToNativeArray2DType(), image.NativePtr, str, str.Length);
        }
コード例 #27
0
ファイル: Interpolation.cs プロジェクト: TrojanOlx/AI
        public static void PyramidUp(Array2DBase image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed(nameof(image));

            var array2DType = image.ImageType.ToNativeArray2DType();
            var ret         = NativeMethods.pyramid_up(array2DType, image.NativePtr);

            if (ret == NativeMethods.ErrorType.Array2DTypeTypeNotSupport)
            {
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }
        }
コード例 #28
0
ファイル: Interpolation.cs プロジェクト: TrojanOlx/AI
        public static void FlipImageLeftRight(Array2DBase image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed(nameof(image));

            var array2DType = image.ImageType.ToNativeArray2DType();
            var ret         = NativeMethods.flip_image_left_right(array2DType, image.NativePtr);

            switch (ret)
            {
            case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }
        }
コード例 #29
0
        public static MatrixOp Heatmap(Array2DBase image, double maxValue, double minValue = 0)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            var array2DType = image.ImageType.ToNativeArray2DType();

            var ret = Native.heatmap2(array2DType, image.NativePtr, maxValue, minValue, out var matrix);

            if (ret == Native.ErrorType.ArrayTypeNotSupport)
            {
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }

            return(new MatrixOp(Native.ElementType.OpHeatmap, image.ImageType, matrix));
        }
コード例 #30
0
        public static MatrixOp Jet(Array2DBase image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            var array2DType = image.ImageType.ToNativeArray2DType();

            var ret = Native.jet(array2DType, image.NativePtr, out var matrix);

            if (ret == Native.ErrorType.ArrayTypeNotSupport)
            {
                throw new ArgumentException($"{image.ImageType} is not supported.");
            }

            return(new MatrixOp(Native.ElementType.OpJet, image.ImageType, matrix));
        }