实现了双屏摄像头显示,添加了部分代码

This commit is contained in:
zxj
2025-07-31 11:40:56 +08:00
parent 56e0a85a4c
commit de4c5f1c75
86 changed files with 3446 additions and 809 deletions
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextureView
android:id="@+id/textureView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/switchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="切换摄像头"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.InitActivity">
<TextView
android:id="@+id/tv_deviceId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="1111" />
<Button
android:id="@+id/bt_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="获取" />
</LinearLayout>
+36 -14
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
@@ -9,31 +10,44 @@
android:orientation="vertical"
tools:context=".activity.MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="80dp"
android:layout_marginTop="40dp">
android:paddingTop="40dp"
android:paddingEnd="40dp">
<Spinner
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_gravity="end|center_vertical" />
android:layout_height="wrap_content"
android:layout_gravity="end"
android:padding="28dp"
android:background="@drawable/bg_detection_selector">
<com.sw.dualscreen.view.CustomSpinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:spinnerTextColor="#ffece7d0"
app:spinnerTextSize="26sp" />
</LinearLayout>
</FrameLayout>
<TextView
style="@style/text_title_60_blob"
android:id="@+id/tv_goods"
style="@style/text_title_blob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="130dp"
android:text="羊肉臊子荞面饸饹" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="630dp"
android:layout_marginStart="120dp"
android:layout_marginTop="60dp"
android:layout_marginEnd="120dp"
android:layout_marginBottom="60dp"
android:layout_height="531dp"
android:layout_marginHorizontal="60dp"
android:layout_marginTop="120dp"
android:layout_marginBottom="90dp"
android:visibility="visible">
<androidx.camera.view.PreviewView
@@ -49,13 +63,21 @@
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="0dp"
android:layout_marginHorizontal="60dp"
android:layout_weight="1" />
<TextView
style="@style/text_100"
android:id="@+id/tv_to_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="先识别 后取餐1" />
android:layout_marginTop="90dp"
android:layout_marginBottom="90dp"
android:padding="10dp"
android:text="以上都不是,手动搜索"
android:textColor="#ffff9900"
android:textSize="36sp" />
</LinearLayout>
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bottom_sheet_layout"
android:layout_width="match_parent"
android:layout_height="1000dp"
android:background="@drawable/bottom_sheet_background"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingHorizontal="60dp"
android:paddingTop="30dp"
android:paddingBottom="0dp">
<View
android:layout_width="90dp"
android:layout_height="10dp"
android:background="@drawable/view_shape_point" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="46dp"
android:text="菜品检索"
android:textColor="#ff333333"
android:textSize="36sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:background="@drawable/bg_search"
android:gravity="center_vertical"
android:orientation="horizontal">
<EditText
android:id="@+id/et_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_weight="1"
android:background="@null"
android:hint="输入菜品名称"
android:imeOptions="actionSearch"
android:maxLines="1"
android:textColor="#333333"
android:textColorHint="#ffc8c8c8"
android:textSize="36sp" />
<ImageView
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="30dp"
android:src="@drawable/ic_search" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="700dp"
android:layout_marginTop="50dp" />
</LinearLayout>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fl_preview"
android:layout_width="match_parent"
android:layout_height="531dp"
android:layout_marginHorizontal="60dp"
android:layout_marginTop="120dp"
android:layout_marginBottom="90dp"
android:visibility="visible">
<androidx.camera.view.PreviewView
android:id="@+id/previewView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:background="@drawable/preview_border" />
</FrameLayout>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/grid_item_checked"
android:gravity="center"
android:orientation="vertical"
android:paddingVertical="42dp">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="肉沫干拌面"
android:maxLines="1"
android:ellipsize="end"
android:textColor="#ff031127"
android:textSize="36sp"
android:textStyle="bold" />
</LinearLayout>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/grid_search_item_checked"
android:gravity="center"
android:orientation="vertical"
android:paddingVertical="42dp">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="肉沫干拌面"
android:maxLines="1"
android:ellipsize="end"
android:textColor="#FF9900"
android:textSize="30sp"
android:textStyle="bold" />
</LinearLayout>
+138
View File
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="540dp"
android:layout_height="487dp"
android:background="@drawable/rounded_border_transparent"
android:padding="28dp">
<TextView
android:id="@+id/tv_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="夏*秋"
android:textColor="#ffece7d0"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_heat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="推荐热量:680kcal"
android:textColor="#ffece7d0"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_user_name" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="40dp"
android:background="#19ECE7D0"
app:layout_constraintTop_toBottomOf="@id/tv_user_name" />
<androidx.constraintlayout.helper.widget.Flow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:paddingBottom="40dp"
app:constraint_referenced_ids="fl_heat, fl_staple_food, fl_fruits_vegetables, fl_meat_eggs"
app:flow_wrapMode="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<FrameLayout
android:id="@+id/fl_heat"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.sw.dualscreen.view.CustomImageView
android:id="@+id/iv_heat"
android:layout_width="87dp"
android:layout_height="0dp"
android:layout_gravity="bottom|center"
android:layout_marginBottom="33dp"
android:background="#DB0000" />
<ImageView
android:layout_width="87dp"
android:layout_height="wrap_content"
android:src="@drawable/ic_cylinder_red_small" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="33dp"
android:src="@drawable/ic_heat" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:text="热量"
android:textColor="#fff0e6dc"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_staple_food"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.sw.dualscreen.view.CustomImageView
android:id="@+id/iv_staple_food"
android:layout_width="87dp"
android:src="#99CC99"
android:layout_gravity="bottom|center"
android:layout_height="100dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:src="@drawable/ic_staple_food" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_fruits_vegetables"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.sw.dualscreen.view.CustomImageView
android:id="@+id/iv_fruits_vegetables"
android:layout_width="87dp"
android:layout_gravity="bottom|center"
android:layout_height="match_parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:src="@drawable/ic_fruits_vegetables" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_meat_eggs"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.sw.dualscreen.view.CustomImageView
android:id="@+id/iv_meat_eggs"
android:layout_width="87dp"
android:layout_gravity="bottom|center"
android:layout_height="match_parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:src="@drawable/ic_meat_eggs" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -11,69 +11,126 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginStart="120dp"
android:layout_marginTop="120dp"
android:layout_marginEnd="120dp"
android:background="@drawable/rounded_border_transparent"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
android:layout_height="wrap_content"
android:paddingHorizontal="80dp"
android:paddingTop="80dp">
<TextView
android:id="@+id/tv_goods"
style="@style/text_title_60_blob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="羊肉臊子荞面饸饹" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="133dp"
android:background="@drawable/rounded_border_transparent"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:id="@+id/tv_goods"
style="@style/text_title_blob_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="羊肉臊子荞面饸饹" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="560dp"
android:layout_marginTop="60dp"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:visibility="visible">
<FrameLayout
android:layout_width="560dp"
android:id="@+id/fl_face"
android:layout_width="376dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="1dp">
android:paddingTop="1dp"
android:visibility="gone">
<TextureView
android:id="@+id/dual_camera_texture_preview_rgb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible" />
<com.sw.plate.utils.arcface.FaceRectView
android:id="@+id/dual_camera_face_rect_view"
android:layout_width="match_parent"
android:layout_height="380dp" />
android:layout_height="match_parent" />
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iv_face_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/bg_face" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="730dp"
android:layout_marginStart="120dp"
android:layout_marginEnd="120dp"
android:layout_marginBottom="120dp"
android:background="@drawable/rounded_border_transparent"
android:gravity="center">
android:background="@drawable/bg_avatar"
android:visibility="gone" />
<TextView
style="@style/text_100"
android:id="@+id/tv_face_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="先识别 后取餐" />
</LinearLayout>
android:layout_gravity="center_horizontal"
android:layout_marginTop="376dp"
android:text="请正视屏幕"
android:textColor="#ffece7d0"
android:textSize="24sp"
android:visibility="gone" />
<FrameLayout
android:id="@+id/fl_preview"
android:layout_width="match_parent"
android:layout_height="420dp"
android:visibility="visible"
android:paddingHorizontal="80dp">
<androidx.camera.view.PreviewView
android:id="@+id/previewView"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/iv_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:contentDescription="img" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@drawable/preview_border" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingHorizontal="80dp"
android:paddingBottom="80dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="486dp"
android:background="@drawable/rounded_border_transparent"
android:gravity="center">
<TextView
android:id="@+id/tv_bottom_tip"
style="@style/text_100_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="先识别 后取餐"
android:visibility="gone" />
<include
android:id="@+id/include_user_heat"
layout="@layout/item_user_heat"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
+71
View File
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp"> <!-- 深蓝色背景 -->
<!-- 顶部文字:数值+单位 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/valueText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:textColor="@android:color/white"
android:textSize="20sp" />
<TextView
android:id="@+id/unitText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:textColor="@android:color/white"
android:textSize="10sp" />
</LinearLayout>
<!-- 圆柱容器 -->
<FrameLayout
android:id="@+id/cylinderContainer"
android:layout_width="87dp"
android:layout_height="wrap_content">
<!-- 圆柱绘制View -->
<com.sw.dualscreen.view.CylinderDrawView
android:id="@+id/cylinderDrawView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal" />
<ImageView
android:id="@+id/topImage"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="top|center_horizontal"
android:background="@drawable/ic_cylinder_red_small" />
<!-- 底部火焰图片(覆盖圆柱底部) -->
<ImageView
android:id="@+id/bottomImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:src="@drawable/ic_heat" /> <!-- 替换为你的火焰图片资源 -->
</FrameLayout>
<!-- 底部文字:热量 -->
<TextView
android:id="@+id/bottomText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="热量"
android:textColor="@android:color/white"
android:textSize="16sp" />
</LinearLayout>