|
@@ -12,6 +12,7 @@ import android.os.Build;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Looper;
|
|
|
import android.util.AttributeSet;
|
|
|
+import android.util.Log;
|
|
|
import android.view.TextureView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
|
@@ -22,6 +23,10 @@ import com.example.datalibrary.utils.FaceOnDrawTexturViewUtil;
|
|
|
import com.example.datalibrary.utils.ImageUtils;
|
|
|
|
|
|
public class GlMantleSurfacView extends RelativeLayout {
|
|
|
+
|
|
|
+
|
|
|
+ String TAG = "GlMantleSurfacView";
|
|
|
+
|
|
|
private boolean isDraw = false;
|
|
|
|
|
|
private int drawLength = 200;
|
|
@@ -80,7 +85,7 @@ public class GlMantleSurfacView extends RelativeLayout {
|
|
|
glFaceSurfaceView.onGlDraw();
|
|
|
}
|
|
|
}
|
|
|
- public void onGlDraw(FaceInfo[] faceInfos , BDFaceImageInstance image , FaceColor colors ) {
|
|
|
+ public void onGlDraw(FaceInfo[] faceInfos , BDFaceImageInstance image , FaceColor colors) {
|
|
|
if (glFaceSurfaceView != null){
|
|
|
glFaceSurfaceView.onGlDraw(faceInfos , image , colors.getColors() , rgbRevert , isDraw || mIsRegister);
|
|
|
} else {
|
|
@@ -104,11 +109,51 @@ public class GlMantleSurfacView extends RelativeLayout {
|
|
|
// 检测图片的坐标和显示的坐标不一样,需要转换。
|
|
|
FaceOnDrawTexturViewUtil.mapFromOriginalRect(rectF,
|
|
|
faceTexture, image);
|
|
|
- // 人脸框颜色
|
|
|
- paint.setColor(colors.getColor());
|
|
|
- // 绘制人脸框
|
|
|
- FaceOnDrawTexturViewUtil.drawRect(canvas,
|
|
|
- rectF, paint, 5f, 50f , 25f);
|
|
|
+
|
|
|
+ // 人脸框颜色
|
|
|
+ paint.setColor(colors.getColor());
|
|
|
+ // 绘制人脸框
|
|
|
+ FaceOnDrawTexturViewUtil.drawRect(canvas,
|
|
|
+ rectF, paint, 5f, 50f , 25f);
|
|
|
+
|
|
|
+
|
|
|
+ // 清空canvas
|
|
|
+ faceTexture.unlockCanvasAndPost(canvas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void onGlDraw(FaceInfo[] faceInfos , BDFaceImageInstance image , FaceColor colors ,boolean isShowFrame) {
|
|
|
+ if (glFaceSurfaceView != null){
|
|
|
+ glFaceSurfaceView.onGlDraw(faceInfos , image , colors.getColors() , rgbRevert , isDraw || mIsRegister);
|
|
|
+ } else {
|
|
|
+ Canvas canvas = faceTexture.lockCanvas();
|
|
|
+ if (canvas == null) {
|
|
|
+ faceTexture.unlockCanvasAndPost(canvas);
|
|
|
+ return;
|
|
|
+ };
|
|
|
+ if (faceInfos == null || faceInfos.length == 0 || !isShowFrame) {
|
|
|
+ // 清空canvas
|
|
|
+ canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
|
|
+ faceTexture.unlockCanvasAndPost(canvas);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
|
|
+ FaceInfo faceInfo = faceInfos[0];
|
|
|
+
|
|
|
+ RectF rectF = new RectF();
|
|
|
+ rectF.set(FaceOnDrawTexturViewUtil.getFaceRectTwo(faceInfo));
|
|
|
+ // 检测图片的坐标和显示的坐标不一样,需要转换。
|
|
|
+ FaceOnDrawTexturViewUtil.mapFromOriginalRect(rectF,
|
|
|
+ faceTexture, image);
|
|
|
+
|
|
|
+ // 人脸框颜色
|
|
|
+ paint.setColor(colors.getColor());
|
|
|
+ // 绘制人脸框
|
|
|
+ FaceOnDrawTexturViewUtil.drawRect(canvas,
|
|
|
+ rectF, paint, 5f, 50f , 25f);
|
|
|
+
|
|
|
+
|
|
|
// 清空canvas
|
|
|
faceTexture.unlockCanvasAndPost(canvas);
|
|
|
}
|