我正在编写一个面部检测应用程序,我想使用该面部的边界框裁剪在屏幕上检测到的面部。
我一直进行搜索,但是只能使用宽度,高度和纵横比进行裁剪。
我不想像其他图像裁切插件那样裁切手册,因为它们也按宽度,高度和纵横比进行裁切。
您可以使用https://github.com/brendan-duncan/image。
对于您的情况,请尝试使用copyCrop
。
https://github.com/brendan-duncan/image/blob/master/lib/src/transform/copy_crop.dart
copy_crop.dart
import '../image.dart';
/// Returns a cropped copy of [src].
Image copyCrop(Image src, int x, int y, int w, int h) {
Image dst = Image(w, h, channels: src.channels, exif: src.exif,
iccp: src.iccProfile);
for (int yi = 0, sy = y; yi < h; ++yi, ++sy) {
for (int xi = 0, sx = x; xi < w; ++xi, ++sx) {
dst.setPixel(xi, yi, src.getPixel(sx, sy));
}
}
return dst;
}
用法
var croppedImage = Image copyCrop(Image sampleImageSrc, int pointX, int pointY, int desiredWidth, int desiredHeight);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句