调整了人脸识别界面

This commit is contained in:
zxj
2025-07-24 18:02:42 +08:00
parent 082011a939
commit 5b3773d277
34 changed files with 203 additions and 137 deletions
+8 -4
View File
@@ -33,17 +33,21 @@
android:name=".activity.LoginByPwdActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".activity.LoginByFaceActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.MainActivity"
@@ -54,6 +54,9 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
// 确保内容延伸到导航栏区域
// WindowCompat.setDecorFitsSystemWindows(window, false)
//保持亮屏
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
binding = inflateViewBinding()
headerBinding = inflateTitleBinding()
setContentView(binding.root)
@@ -60,8 +60,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
}
override fun initialize() {
// viewModel.activeEngine()
viewModel.activeEngine()
initArcViewModel()
initArcView()
openRectInfoDraw = true
@@ -156,6 +155,10 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
Timber.i("recognizeUserId observe userId = $userId")
viewModel.getUserInfoById(memberId = userId?.toInt() ?: 0)
})
recognizeViewModel.drawRectInfoText.observe(this, Observer { info ->
Timber.i("drawRectInfoText observe info = $info")
})
}
private fun initArcView() {
@@ -250,8 +253,10 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
val layoutParams = adjustPreviewViewSize(
binding.dualCameraTexturePreviewRgb,
binding.dualCameraTexturePreviewRgb, binding.dualCameraFaceRectView,
previewSizeRgb, displayOrientation, 1.0f
previewSizeRgb, displayOrientation, 1f
)
Timber.d("initRgbCamera previewSizeRgb = ${previewSizeRgb.width}-${previewSizeRgb.height}")
Timber.d("initRgbCamera layoutParams = ${layoutParams.width}-${layoutParams.height}")
rgbFaceRectTransformer = FaceRectTransformer(
previewSizeRgb.width,
previewSizeRgb.height,
@@ -269,7 +274,6 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
})
}
@RequiresApi(api = Build.VERSION_CODES.Q)
override fun onPreview(nv21: ByteArray?, camera: Camera?) {
if (!isRecognition) {
@@ -322,7 +326,6 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
rgbCameraHelper!!.start()
}
/**
* 绘制RGB、IR画面的实时人脸信息
*
@@ -337,7 +340,6 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
)
// 识别成功
binding.dualCameraFaceRectView.drawRealtimeFaceInfo(rgbDrawInfoList)
}
}
@@ -4,6 +4,7 @@ import android.content.Intent
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import com.sw.plate.utils.ToastUtils
import com.sw.plate.utils.arcface.face.Test
import com.sw.platecabinet.databinding.ActivityLoginByPwdBinding
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
import com.sw.platecabinet.viewmodel.UserViewModel
@@ -28,6 +29,11 @@ class LoginByPwdActivity : BaseActivity<ActivityLoginByPwdBinding>() {
val pwd = binding.etPwd.text.toString()
if (phone.isEmpty() || pwd.isEmpty()) {
ToastUtils.showToast("手机或校验码不能为空")
val test = Test()
for (i in 1..1000) {
test.test1()
}
return@setOnClickListener
}
viewModel.loginWithPwd(phone = phone, password = pwd)
@@ -14,8 +14,10 @@ import com.sw.platecabinet.model.request.LoginParam
import com.sw.platecabinet.model.response.EquipmentUserInfo
import com.sw.platecabinet.model.response.UserFaceModel
import com.sw.platecabinet.utils.ThreadUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.withContext
import timber.log.Timber
class UserViewModel : BaseViewModel() {
@@ -55,8 +57,10 @@ class UserViewModel : BaseViewModel() {
val faceEntity = list.map {
FaceEntity(it.userId, null, Base64.decode(it.faceFeatureString))
}
faceApi.updateFaceData(index, faceEntity)
activeEngine()
withContext(Dispatchers.Default) {
faceApi.updateFaceData(index, faceEntity)
activeEngine()
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#14141E"
android:background="@drawable/bg"
android:orientation="vertical">
<include
@@ -33,11 +33,11 @@
android:gravity="center_vertical">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="55dp"
android:src="@mipmap/ic_phone" />
android:src="@drawable/ic_phone" />
<EditText
android:id="@+id/et_phone"
@@ -73,11 +73,11 @@
android:gravity="center_vertical">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="55dp"
android:src="@mipmap/ic_password" />
android:src="@drawable/ic_pwd" />
<EditText
android:id="@+id/et_pwd"
+46 -45
View File
@@ -4,9 +4,9 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#14141E"
android:fitsSystemWindows="false"
android:orientation="vertical"
android:background="@drawable/bg"
tools:context=".activity.LoginByFaceActivity">
<include
@@ -28,59 +28,60 @@
android:textColor="#fff0c8b4"
android:textSize="36sp" />
<FrameLayout
android:layout_width="380dp"
android:layout_height="380dp"
android:layout_marginTop="119dp"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="129dp"
android:gravity="center_vertical"
android:visibility="visible">
<!-- <androidx.camera.view.PreviewView-->
<!-- android:id="@+id/previewView"-->
<!-- android:layout_margin="10dp"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent" />-->
<FrameLayout
android:layout_width="380dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="1dp">
<TextureView
android:id="@+id/dual_camera_texture_preview_rgb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
<TextureView
android:id="@+id/dual_camera_texture_preview_rgb"
android:layout_width="380dp"
android:visibility="visible"
android:layout_height="wrap_content" />
<com.sw.plate.utils.arcface.FaceRectView
android:id="@+id/dual_camera_face_rect_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="@drawable/circle_dashed_border" />
<com.sw.plate.utils.arcface.FaceRectView
android:id="@+id/dual_camera_face_rect_view"
android:layout_width="match_parent"
android:layout_height="380dp" />
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg_face" />
</FrameLayout>
<LinearLayout
android:id="@+id/ll_to_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:background="@drawable/btn_outline_887872"
android:gravity="center"
android:paddingHorizontal="45dp"
android:paddingVertical="18dp">
<TextView
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码登录"
android:textColor="#ff887872"
android:textSize="24sp" />
</LinearLayout>
android:background="@drawable/bg_face" />
<LinearLayout
android:id="@+id/ll_to_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="208dp"
android:layout_marginTop="500dp"
android:background="@drawable/btn_outline_887872"
android:gravity="center"
android:paddingHorizontal="45dp"
android:paddingVertical="18dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码登录"
android:textColor="#ff887872"
android:textSize="24sp" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
+1 -1
View File
@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#14141E"
android:background="@drawable/bg"
tools:context=".activity.MainActivity">
<include
@@ -28,10 +28,10 @@
tools:text="1-12" />
<ImageView
android:layout_width="280dp"
android:layout_height="24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:src="@mipmap/ic_bind_img" />
android:src="@drawable/ic_bind_img" />
<LinearLayout
android:layout_width="match_parent"
@@ -9,9 +9,9 @@
tools:context=".fragment.PlateCabinetFullFragment">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@mipmap/ic_full" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_full" />
<TextView
android:layout_width="wrap_content"
@@ -28,9 +28,9 @@
android:orientation="vertical">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@mipmap/ic_plate_open" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_plate_open" />
<TextView
android:layout_width="wrap_content"
@@ -10,10 +10,10 @@
<ImageView
android:layout_width="280dp"
android:layout_height="24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:src="@mipmap/ic_unbind_img" />
android:src="@drawable/ic_unbind_img" />
<TextView
android:layout_width="wrap_content"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

+2
View File
@@ -10,4 +10,6 @@
<color name="bind_F0C8B4">#F0C8B4</color>
<color name="unbind_F0C8B4">#F0C8B4</color>
<color name="unbind_32283C">#32283C</color>
<color name="divColor">#4c91ceff</color>
</resources>
+1
View File
@@ -4,4 +4,5 @@
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="specific_engine_init_failed">%s 初始化失败,错误码:%d\n错误码常量名:%s</string>
<string name="permission_denied">权限被拒绝!</string>
</resources>