Android 人脸地标裁剪
Posted
技术标签:
【中文标题】Android 人脸地标裁剪【英文标题】:Face landmark cropping by Android 【发布时间】:2018-05-08 18:07:46 【问题描述】:我正在尝试检测面部特征并裁剪面部特征区域。我已经使用 dlib 成功检测了界标区域,下一步是裁剪检测区域,我已经阅读了很多博客,OpenCv 的官方文档,但我无法理解裁剪区域需要做什么。
我已经在每张脸的 arrayList 中获得了地标点。但我不知道如何使用这些点裁剪图像。
我正在使用 android。
【问题讨论】:
这是我得到的:List我相信这就是我用箭头指出的你要找的东西。
//This function extract data from the image and return FaceLandmarks Object
private ArrayList<FaceLandmarks> faceLandmarkDetection(Bitmap bitmap)
ArrayList<Point> singleFaceLandmarks = new ArrayList<>();
ArrayList<FaceLandmarks> multipleFacesLandmarks = new ArrayList<>();
//Calling FaceDet class loading landmarks file.
FaceDet faceDet = new FaceDet(mTargetPath);
//This array contain multiple faces landmarks
//extracting the results from the image
Bitmap rotateBitmap = rotateImage(bitmap);
List<VisionDetRet> results = faceDet.detect(rotateBitmap);
//Running on the image faces extracting information.
for (VisionDetRet ret : results)
int rectLeft = ret.getLeft();
int rectTop = ret.getTop();
int rectRight = ret.getRight();
int rectBottom = ret.getBottom();
int imageWidth = rotateBitmap.getWidth();
int imageHeight = rotateBitmap.getHeight();
//We do image correction, if the face is out of the entire image frame
if(rectRight > imageWidth)
rectRight = imageWidth;
//We do image correction, if the face is out of the entire image frame
if(rectBottom > imageHeight)
rectBottom = imageHeight;
==> int faceWidth = rectRight - rectLeft;
==> int faceHeight = rectBottom - rectTop;
==> Bitmap croppedBmp = Bitmap.createBitmap(rotateBitmap, rectLeft, rectTop, faceWidth, faceHeight);
List<VisionDetRet> improvedResults = faceDet.detect(croppedBmp);
//This array contain single face landmarks: Get 68 landmark points
for (VisionDetRet improvedRet : improvedResults)
singleFaceLandmarks = improvedRet.getFaceLandmarks();
multipleFacesLandmarks.add(new FaceLandmarks(singleFaceLandmarks));
return multipleFacesLandmarks;
【讨论】:
以上是关于Android 人脸地标裁剪的主要内容,如果未能解决你的问题,请参考以下文章