public static ChipDetails[] GetFaceChipDetails(IEnumerable <FullObjectDetection> dets, uint size = 200, double padding = 0.2d) { if (dets == null) { throw new ArgumentNullException(nameof(dets)); } if (size <= 0) { throw new ArgumentException(); } if (padding < 0) { throw new ArgumentException(); } if (dets.Any(detection => detection == null || detection.IsDisposed || detection.Parts != 68)) { throw new ArgumentException($"{nameof(dets)} includes invalid item."); } using (var vector = new VectorOfFullObjectDetection(dets)) using (var vectorOfChips = new VectorOfChipDetails()) { Native.get_face_chip_details(vector.NativePtr, size, padding, vectorOfChips.NativePtr); return(vectorOfChips.ToArray()); } }
public static Array <Array2D <T> > ExtractImageChips <T>(Array2DBase image, IEnumerable <ChipDetails> chipLocations) where T : struct { if (image == null) { throw new ArgumentNullException(nameof(image)); } if (chipLocations == null) { throw new ArgumentNullException(nameof(chipLocations)); } if (chipLocations.Any(chip => chip == null || chip.IsDisposed || !chip.IsValid())) { throw new ArgumentException($"{nameof(chipLocations)} includes invalid item."); } image.ThrowIfDisposed(); using (var vectorOfChips = new VectorOfChipDetails(chipLocations)) { var array = new Array <Array2D <T> >(); var array2DType = image.ImageType.ToNativeArray2DType(); var ret = Native.extract_image_chips(array2DType, image.NativePtr, vectorOfChips.NativePtr, array.ImageType.ToNativeArray2DType(), array.NativePtr); switch (ret) { case Native.ErrorType.InputArrayTypeNotSupport: throw new ArgumentException($"{image.ImageType} is not supported."); case Native.ErrorType.OutputArrayTypeNotSupport: throw new ArgumentException($"{array.ImageType} is not supported."); } return(array); } }