人脸图像调整

This commit is contained in:
jjLv 2025-08-15 19:22:57 +08:00
parent 48b710d7cc
commit 65ab7ad7a3
3 changed files with 32 additions and 1 deletions

View File

@ -26,6 +26,8 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -187,6 +189,16 @@ public class FaceFragment extends BaseFragment<ActivityFaceBinding> {
protected void initViews() {
previewView = findViewById(R.id.texture_preview);
faceRectView = findViewById(R.id.face_rect_view);
FrameLayout faceRectContainer = findViewById(R.id.face_rect_view_container);
// 设置为圆形
faceRectContainer.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, android.graphics.Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), view.getWidth() / 2f);
}
});
faceRectContainer.setClipToOutline(true);
compareResultList = new ArrayList<>();
SIMILAR_THRESHOLD = Float.parseFloat(WorkConfig.getFacePassRate());
adapter = new FaceSearchResultAdapter(compareResultList, requireContext());

View File

@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/transparent"/>
<solid android:color="#00000000" /> <!-- 透明 -->
<stroke
android:width="3dp"
android:color="#4BCFCF" /> <!-- 圆形边框(可选) -->
</shape>

View File

@ -172,7 +172,22 @@
android:id="@+id/face_rect_view_container"
android:layout_width="470dp"
android:layout_height="470dp"
android:background="@drawable/face_bg"
android:padding="1px"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:background="#50000000"
android:elevation="999dp"
android:layout_height="50dp">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="检测中"
android:textSize="25sp"
android:textColor="@color/white"/>
</LinearLayout>
<TextureView
android:id="@+id/texture_preview"
android:layout_width="match_parent"