优化人脸识别区域
This commit is contained in:
@@ -952,8 +952,8 @@ class MainScreenPresentation(
|
||||
// val h = 900.dp //684.dp
|
||||
// val w = 500.dp
|
||||
// val h = 850.dp
|
||||
val w = 720.dp
|
||||
val h = 1280.dp
|
||||
val w = 600.dp
|
||||
val h = 1068.dp
|
||||
//(1024*scale).toInt()
|
||||
val layoutParams = FrameLayout.LayoutParams(w, h);
|
||||
// val layoutParams = FrameLayout.LayoutParams(480, 320);
|
||||
|
||||
@@ -325,8 +325,12 @@ class FacePayPresentation(
|
||||
// layoutParams.height = (456.dp * 1.5).roundToInt()
|
||||
// layoutParams.width = 1024
|
||||
// layoutParams.height = 768
|
||||
val w = 500.dp
|
||||
val h = 850.dp
|
||||
// val w = 500.dp
|
||||
// val h = 850.dp
|
||||
val w = 600.dp
|
||||
val h = 1068.dp
|
||||
// val w = 720.dp
|
||||
// val h = 1280.dp
|
||||
val layoutParams = FrameLayout.LayoutParams(w, h);
|
||||
|
||||
previewView.setLayoutParams(layoutParams)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sw.dualscreen.view
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.toColorInt
|
||||
@@ -38,7 +39,10 @@ class HollowCircleRectView @JvmOverloads constructor(
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
// 强制View尺寸为精准px值,避免父布局干扰
|
||||
setMeasuredDimension(rectWidthPx.toInt(), rectHeightPx.toInt())
|
||||
val rectWidthPxInt = rectWidthPx.toInt()
|
||||
val rectHeightPxInt = rectHeightPx.toInt()
|
||||
Log.d("HollowCircleRectView", "onMeasure: $rectWidthPxInt,$rectHeightPxInt")
|
||||
setMeasuredDimension(rectWidthPxInt, rectHeightPxInt)
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
@@ -52,6 +56,7 @@ class HollowCircleRectView @JvmOverloads constructor(
|
||||
val circleX = rectWidthPx / 2 // 水平居中:200dp转px
|
||||
val circleY = rectHeightPx / 2 // 垂直居中:340dp转px
|
||||
// 核心修复:用固定半径circleRadiusPx,而非直径/2(避免浮点运算偏差)
|
||||
Log.d("HollowCircleRectView", "onDraw: $circleX,$circleY,$circleRadiusPx")
|
||||
path.addCircle(circleX, circleY, circleRadiusPx, Path.Direction.CW)
|
||||
|
||||
// 3. 填充规则+绘制
|
||||
|
||||
@@ -402,6 +402,9 @@ class UserViewModel : BaseViewModel() {
|
||||
block(response.data.toString())
|
||||
} else {
|
||||
block("")
|
||||
// // TODO: 临时测试----------------
|
||||
// block("${System.currentTimeMillis()}")
|
||||
// // TODO: 临时测试----------------
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,17 @@
|
||||
|
||||
<!-- android:layout_width="300dp"-->
|
||||
<!-- android:layout_height="510dp"-->
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/flFace"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="510dp"
|
||||
android:layout_marginHorizontal="28dp"
|
||||
android:layout_marginTop="56dp">
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="680dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="-85dp">
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/dual_camera_texture_preview_rgb"
|
||||
@@ -84,29 +89,29 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/ivPreviewImage"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent" />-->
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/ivFaceRecMask"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_gravity="bottom"-->
|
||||
<!-- android:adjustViewBounds="true"-->
|
||||
<!-- android:src="@drawable/face_mask"-->
|
||||
<!-- android:visibility="visible" />-->
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/ivPreviewImage"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent" />-->
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/ivFaceRecMask"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_gravity="bottom"-->
|
||||
<!-- android:adjustViewBounds="true"-->
|
||||
<!-- android:src="@drawable/face_mask"-->
|
||||
<!-- android:visibility="visible" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tvFaceTip"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_gravity="bottom|center"-->
|
||||
<!-- android:layout_marginBottom="56dp"-->
|
||||
<!-- android:text="请正视屏幕进行面部识别..."-->
|
||||
<!-- android:textColor="@color/white"-->
|
||||
<!-- android:textSize="24sp"-->
|
||||
<!-- android:visibility="v" />-->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tvFaceTip"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_gravity="bottom|center"-->
|
||||
<!-- android:layout_marginBottom="56dp"-->
|
||||
<!-- android:text="请正视屏幕进行面部识别..."-->
|
||||
<!-- android:textColor="@color/white"-->
|
||||
<!-- android:textSize="24sp"-->
|
||||
<!-- android:visibility="v" />-->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_recognize_ir"
|
||||
@@ -128,6 +133,35 @@
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/llCircleArea"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="#FFF4FAFF" />
|
||||
|
||||
<com.sw.dualscreen.view.HollowCircleRectView
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="510dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="#FFF4FAFF" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -136,7 +170,24 @@
|
||||
android:textColor="#ff5e7585"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
tools:ignore="HardcodedText" />
|
||||
</FrameLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="85dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="#FFF4FAFF"/>
|
||||
</FrameLayout>
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginTop="55dp"-->
|
||||
<!-- android:text="请正视屏幕进行面部识别..."-->
|
||||
<!-- android:textColor="#ff5e7585"-->
|
||||
<!-- android:textSize="22sp"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- tools:ignore="HardcodedText" />-->
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -109,8 +109,8 @@
|
||||
android:background="#FFF4FAFF" />
|
||||
|
||||
<com.sw.dualscreen.view.HollowCircleRectView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="510dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<View
|
||||
@@ -121,6 +121,12 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- <View-->
|
||||
<!-- android:layout_width="400dp"-->
|
||||
<!-- android:layout_height="400dp"-->
|
||||
<!-- android:layout_gravity="center"-->
|
||||
<!-- android:background="#80ff0000"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFaceTip"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user