public static Rect getFaceRect(int[] argb, FaceInfo faceInfo, int imageWidth) { int[] points = new int[8]; faceInfo.GetRectPoints(points); int left = points[2]; int top = points[3]; int right = points[6]; int bottom = points[7]; int width = right - left; int height = bottom - top; width = width * 3 / 2; height = height * 2; // left = (int)(faceInfo.MCenterX - width / 2); top = (int)(faceInfo.MCenterY - height / 2); height = height * 4 / 5; // left = Math.Max(left, 0); top = Math.Max(top, 0); Rect region = new Rect(left, top, left + width, top + height); FaceCropper.adjustRect(argb, imageWidth, region); return(region); }
public int[] cropFaceArgb() { return(FaceCropper.getCropFace(getFrame().getArgb(), info, getImageFrame().getWidth())); }
/** * 裁剪人脸图片。 * * @param rect 裁剪区域。如果区域超出人脸,区域会被调整。 * * @return 裁剪后的人脸图片。 */ // TODO public Bitmap cropFace(Rect rect) { return(FaceCropper.getFace(getFrame().getArgb(), info, getImageFrame().getWidth())); // int[] argb = FaceCropper.crop(getFrame().getArgb(), getFrame().getWidth(), rect); // return Bitmap.createBitmap(argb, rect.width(), rect.height(), Bitmap.Config.ARGB_8888); }