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 VectorOfRectangle()) { 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()); } }
public void CreateWithSize() { const int size = 10; var vector = new VectorOfRectangle(size); this.DisposeAndCheckDisposedState(vector); }
public void AddOverlay(IEnumerable <Rectangle> rects, HsiPixel color) { this.ThrowIfDisposed(); if (rects == null) { throw new ArgumentNullException(nameof(rects)); } using (var vector = new VectorOfRectangle(rects)) Native.image_window_add_overlay2(this.NativePtr, vector.NativePtr, Dlib.Native.Array2DType.HsiPixel, ref color); }
public void CreateWithCollection() { const int size = 10; var source = Enumerable.Range(0, size).Select(i => new Rectangle(i, i, i, i)); var vector = new VectorOfRectangle(source); Assert.AreEqual(vector.Size, size); var ret = vector.ToArray(); for (var i = 0; i < size; i++) { Assert.AreEqual(ret[i].Left, i); Assert.AreEqual(ret[i].Top, i); Assert.AreEqual(ret[i].Right, i); Assert.AreEqual(ret[i].Bottom, i); } this.DisposeAndCheckDisposedState(vector); }
public Rectangle[] Detect(Array2DBase image, double threshold = 0d) { this.ThrowIfDisposed(); if (image == null) { throw new ArgumentNullException(nameof(image)); } image.ThrowIfDisposed(); using (var dets = new VectorOfRectangle()) { var inType = image.ImageType.ToNativeArray2DType(); var ret = Native.frontal_face_detector_operator(this.NativePtr, inType, image.NativePtr, threshold, dets.NativePtr); switch (ret) { case Dlib.Native.ErrorType.InputArrayTypeNotSupport: throw new ArgumentException($"Input {inType} is not supported."); } return(dets.ToArray()); } }
public void Create() { var vector = new VectorOfRectangle(); this.DisposeAndCheckDisposedState(vector); }