Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c83f36c976 | ||
|
|
29e0c1e9a8 | ||
|
|
7b07e7fbc1 | ||
|
|
b6ac86a134 | ||
|
|
6bbbb3c3ef | ||
|
|
e38da96e37 | ||
|
|
9ee028248d | ||
|
|
84cc693593 | ||
|
|
4cf1990b16 | ||
|
|
2130cf0e6b | ||
|
|
6717047d1d | ||
|
|
da2c97e412 | ||
|
|
db80a5dbbd | ||
|
|
634d22f3be | ||
|
|
835f768a4a | ||
|
|
1859706412 | ||
|
|
9c71e40c97 | ||
|
|
84d567674f | ||
|
|
43b00c8446 | ||
|
|
e23ccd75cd | ||
|
|
8623b71ab7 | ||
|
|
16efcbcff3 | ||
|
|
4f62081239 | ||
|
|
9f29667b73 | ||
|
|
0c7455650d | ||
|
|
00aabfc6d9 | ||
|
|
02a005f5b1 | ||
|
|
6495a27658 | ||
|
|
263a061d27 | ||
|
|
2555047190 | ||
|
|
dfbef7caf1 | ||
|
|
13357ab256 | ||
|
|
1dfc63543f | ||
|
|
10505c616f | ||
|
|
300340bb19 | ||
|
|
57b7c40835 | ||
|
|
b2da84f903 | ||
|
|
41a659bd6d | ||
|
|
afd02550a8 | ||
|
|
b73e94b7bf | ||
|
|
2876599568 | ||
|
|
f6dd3ab38e | ||
|
|
ce2444bd07 | ||
|
|
25fd6b4a32 |
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.22.1)
|
||||
|
||||
project("sample")
|
||||
project("face_sdk")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@@ -23,7 +23,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
third_party/vma/include
|
||||
)
|
||||
|
||||
add_library(sample SHARED
|
||||
add_library(face_sdk SHARED
|
||||
app/src/main/cpp/main.cpp
|
||||
app/src/main/cpp/AndroidOut.cpp
|
||||
vulkan/AppBase.h
|
||||
@@ -45,13 +45,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
target_link_libraries(sample
|
||||
target_link_libraries(face_sdk
|
||||
game-activity::game-activity_static
|
||||
Vulkan::Vulkan
|
||||
android
|
||||
log)
|
||||
|
||||
target_compile_definitions(sample PRIVATE
|
||||
target_compile_definitions(face_sdk PRIVATE
|
||||
VMA_STATIC_VULKAN_FUNCTIONS=0
|
||||
VMA_DYNAMIC_VULKAN_FUNCTIONS=1
|
||||
)
|
||||
@@ -82,7 +82,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR WIN32)
|
||||
)
|
||||
|
||||
# 将源代码添加到此项目的可执行文件。
|
||||
add_executable (sample
|
||||
add_executable (face_sdk
|
||||
vulkan/AppBase.h
|
||||
vulkan/AppBase.cpp
|
||||
vulkan/Application.h
|
||||
@@ -97,7 +97,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR WIN32)
|
||||
endif()
|
||||
|
||||
|
||||
# target_compile_definitions(sample PRIVATE VK_NO_PROTOTYPES) 使用volk 动态加载的时候需要定义,不自动生成vulkan接口
|
||||
target_compile_definitions(sample PRIVATE GLM_ENABLE_EXPERIMENTAL)
|
||||
# target_compile_definitions(sample PRIVATE VULKAN_HPP_NO_STRUCT_CONSTRUCTORS) 解决vs 编译c++ 20 不支持新构造函数的特性
|
||||
# target_compile_definitions(face_sdk PRIVATE VK_NO_PROTOTYPES) 使用volk 动态加载的时候需要定义,不自动生成vulkan接口
|
||||
target_compile_definitions(face_sdk PRIVATE GLM_ENABLE_EXPERIMENTAL)
|
||||
# target_compile_definitions(face_sdk PRIVATE VULKAN_HPP_NO_STRUCT_CONSTRUCTORS) 解决vs 编译c++ 20 不支持新构造函数的特性
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
//alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
//id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
ext.vvl_version='1.4.321.0'
|
||||
apply from: "./download_vvl.gradle"
|
||||
|
||||
android {
|
||||
namespace 'com.hmwl.sample'
|
||||
compileSdk 35
|
||||
|
||||
namespace 'com.hmwl.face_sdk'
|
||||
compileSdk 36
|
||||
defaultConfig {
|
||||
applicationId "com.hmwl.sample"
|
||||
//applicationId "com.hmwl.face_sdk"
|
||||
minSdk 30
|
||||
targetSdk 35
|
||||
targetSdk 36
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -22,12 +23,25 @@ android {
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
jniDebuggable true
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DCMAKE_BUILD_TYPE=Debug"
|
||||
cppFlags "-DDEBUG -O0 -g"
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
debugSymbolLevel 'FULL' // Debug 版本包含完整符号
|
||||
}
|
||||
}
|
||||
|
||||
release {
|
||||
@@ -36,18 +50,54 @@ android {
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
// 添加 Kotlin 编译选项
|
||||
// kotlinOptions {
|
||||
// jvmTarget = '17' // 与 Java 版本保持一致
|
||||
// }
|
||||
|
||||
// kotlin {
|
||||
// jvmToolchain(17)
|
||||
// }
|
||||
|
||||
buildFeatures {
|
||||
prefab true
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jniLibs.srcDirs += [
|
||||
'libs/tasks-vision/jni',
|
||||
'libs/tasks-core/jni'
|
||||
]
|
||||
//java.srcDirs += [
|
||||
// 'libs/tasks-vision/vision_classes',
|
||||
// 'libs/tasks-core/core_classes'
|
||||
//]
|
||||
res.srcDirs += [
|
||||
'libs/tasks-vision/res',
|
||||
'libs/tasks-core/res'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path file('../CMakeLists.txt')
|
||||
version '3.22.1'
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
pickFirst '**/*.jar'
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '17'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -55,12 +105,17 @@ dependencies {
|
||||
implementation libs.appcompat
|
||||
implementation libs.material
|
||||
implementation libs.games.activity
|
||||
implementation libs.androidx.core.core.ktx
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
|
||||
implementation files('libs/tasks-vision-0.10.26.aar')
|
||||
implementation files('libs/tasks-core-0.10.26.aar')
|
||||
|
||||
implementation 'com.google.protobuf:protobuf-javalite:3.21.12'
|
||||
implementation files('libs/tasks-vision.jar', 'libs/tasks-core.jar')
|
||||
|
||||
//implementation fileTree(dir: 'libs/tasks-vision', include: ['*.jar'])
|
||||
//implementation fileTree(dir: 'libs/tasks-core', include: ['*.jar'])
|
||||
|
||||
|
||||
def camerax_version = '1.4.2'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
apply plugin: 'com.android.application'
|
||||
//apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022-2024, The Android Open Source Project.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.tasks.core" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="24"
|
||||
android:targetSdkVersion="34" />
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,255 @@
|
||||
int anim fragment_fast_out_extra_slow_in 0x00000000
|
||||
int animator fragment_close_enter 0x00000000
|
||||
int animator fragment_close_exit 0x00000000
|
||||
int animator fragment_fade_enter 0x00000000
|
||||
int animator fragment_fade_exit 0x00000000
|
||||
int animator fragment_open_enter 0x00000000
|
||||
int animator fragment_open_exit 0x00000000
|
||||
int attr alpha 0x00000000
|
||||
int attr coordinatorLayoutStyle 0x00000000
|
||||
int attr font 0x00000000
|
||||
int attr fontProviderAuthority 0x00000000
|
||||
int attr fontProviderCerts 0x00000000
|
||||
int attr fontProviderFetchStrategy 0x00000000
|
||||
int attr fontProviderFetchTimeout 0x00000000
|
||||
int attr fontProviderPackage 0x00000000
|
||||
int attr fontProviderQuery 0x00000000
|
||||
int attr fontStyle 0x00000000
|
||||
int attr fontVariationSettings 0x00000000
|
||||
int attr fontWeight 0x00000000
|
||||
int attr keylines 0x00000000
|
||||
int attr layout_anchor 0x00000000
|
||||
int attr layout_anchorGravity 0x00000000
|
||||
int attr layout_behavior 0x00000000
|
||||
int attr layout_dodgeInsetEdges 0x00000000
|
||||
int attr layout_insetEdge 0x00000000
|
||||
int attr layout_keyline 0x00000000
|
||||
int attr statusBarBackground 0x00000000
|
||||
int attr ttcIndex 0x00000000
|
||||
int color notification_action_color_filter 0x00000000
|
||||
int color notification_icon_bg_color 0x00000000
|
||||
int color notification_material_background_media_default_color 0x00000000
|
||||
int color primary_text_default_material_dark 0x00000000
|
||||
int color ripple_material_light 0x00000000
|
||||
int color secondary_text_default_material_dark 0x00000000
|
||||
int color secondary_text_default_material_light 0x00000000
|
||||
int dimen compat_button_inset_horizontal_material 0x00000000
|
||||
int dimen compat_button_inset_vertical_material 0x00000000
|
||||
int dimen compat_button_padding_horizontal_material 0x00000000
|
||||
int dimen compat_button_padding_vertical_material 0x00000000
|
||||
int dimen compat_control_corner_material 0x00000000
|
||||
int dimen compat_notification_large_icon_max_height 0x00000000
|
||||
int dimen compat_notification_large_icon_max_width 0x00000000
|
||||
int dimen notification_action_icon_size 0x00000000
|
||||
int dimen notification_action_text_size 0x00000000
|
||||
int dimen notification_big_circle_margin 0x00000000
|
||||
int dimen notification_content_margin_start 0x00000000
|
||||
int dimen notification_large_icon_height 0x00000000
|
||||
int dimen notification_large_icon_width 0x00000000
|
||||
int dimen notification_main_column_padding_top 0x00000000
|
||||
int dimen notification_media_narrow_margin 0x00000000
|
||||
int dimen notification_right_icon_size 0x00000000
|
||||
int dimen notification_right_side_padding_top 0x00000000
|
||||
int dimen notification_small_icon_background_padding 0x00000000
|
||||
int dimen notification_small_icon_size_as_large 0x00000000
|
||||
int dimen notification_subtext_size 0x00000000
|
||||
int dimen notification_top_pad 0x00000000
|
||||
int dimen notification_top_pad_large_text 0x00000000
|
||||
int dimen subtitle_corner_radius 0x00000000
|
||||
int dimen subtitle_outline_width 0x00000000
|
||||
int dimen subtitle_shadow_offset 0x00000000
|
||||
int dimen subtitle_shadow_radius 0x00000000
|
||||
int drawable notification_action_background 0x00000000
|
||||
int drawable notification_bg 0x00000000
|
||||
int drawable notification_bg_low 0x00000000
|
||||
int drawable notification_bg_low_normal 0x00000000
|
||||
int drawable notification_bg_low_pressed 0x00000000
|
||||
int drawable notification_bg_normal 0x00000000
|
||||
int drawable notification_bg_normal_pressed 0x00000000
|
||||
int drawable notification_icon_background 0x00000000
|
||||
int drawable notification_template_icon_bg 0x00000000
|
||||
int drawable notification_template_icon_low_bg 0x00000000
|
||||
int drawable notification_tile_bg 0x00000000
|
||||
int drawable notify_panel_notification_icon_bg 0x00000000
|
||||
int id accessibility_action_clickable_span 0x00000000
|
||||
int id accessibility_custom_action_0 0x00000000
|
||||
int id accessibility_custom_action_1 0x00000000
|
||||
int id accessibility_custom_action_10 0x00000000
|
||||
int id accessibility_custom_action_11 0x00000000
|
||||
int id accessibility_custom_action_12 0x00000000
|
||||
int id accessibility_custom_action_13 0x00000000
|
||||
int id accessibility_custom_action_14 0x00000000
|
||||
int id accessibility_custom_action_15 0x00000000
|
||||
int id accessibility_custom_action_16 0x00000000
|
||||
int id accessibility_custom_action_17 0x00000000
|
||||
int id accessibility_custom_action_18 0x00000000
|
||||
int id accessibility_custom_action_19 0x00000000
|
||||
int id accessibility_custom_action_2 0x00000000
|
||||
int id accessibility_custom_action_20 0x00000000
|
||||
int id accessibility_custom_action_21 0x00000000
|
||||
int id accessibility_custom_action_22 0x00000000
|
||||
int id accessibility_custom_action_23 0x00000000
|
||||
int id accessibility_custom_action_24 0x00000000
|
||||
int id accessibility_custom_action_25 0x00000000
|
||||
int id accessibility_custom_action_26 0x00000000
|
||||
int id accessibility_custom_action_27 0x00000000
|
||||
int id accessibility_custom_action_28 0x00000000
|
||||
int id accessibility_custom_action_29 0x00000000
|
||||
int id accessibility_custom_action_3 0x00000000
|
||||
int id accessibility_custom_action_30 0x00000000
|
||||
int id accessibility_custom_action_31 0x00000000
|
||||
int id accessibility_custom_action_4 0x00000000
|
||||
int id accessibility_custom_action_5 0x00000000
|
||||
int id accessibility_custom_action_6 0x00000000
|
||||
int id accessibility_custom_action_7 0x00000000
|
||||
int id accessibility_custom_action_8 0x00000000
|
||||
int id accessibility_custom_action_9 0x00000000
|
||||
int id action0 0x00000000
|
||||
int id action_container 0x00000000
|
||||
int id action_divider 0x00000000
|
||||
int id action_image 0x00000000
|
||||
int id action_text 0x00000000
|
||||
int id actions 0x00000000
|
||||
int id all 0x00000000
|
||||
int id async 0x00000000
|
||||
int id blocking 0x00000000
|
||||
int id bottom 0x00000000
|
||||
int id cancel_action 0x00000000
|
||||
int id center 0x00000000
|
||||
int id center_horizontal 0x00000000
|
||||
int id center_vertical 0x00000000
|
||||
int id chronometer 0x00000000
|
||||
int id clip_horizontal 0x00000000
|
||||
int id clip_vertical 0x00000000
|
||||
int id dialog_button 0x00000000
|
||||
int id end 0x00000000
|
||||
int id end_padder 0x00000000
|
||||
int id fill 0x00000000
|
||||
int id fill_horizontal 0x00000000
|
||||
int id fill_vertical 0x00000000
|
||||
int id forever 0x00000000
|
||||
int id fragment_container_view_tag 0x00000000
|
||||
int id icon 0x00000000
|
||||
int id icon_group 0x00000000
|
||||
int id info 0x00000000
|
||||
int id italic 0x00000000
|
||||
int id left 0x00000000
|
||||
int id line1 0x00000000
|
||||
int id line3 0x00000000
|
||||
int id media_actions 0x00000000
|
||||
int id none 0x00000000
|
||||
int id normal 0x00000000
|
||||
int id notification_background 0x00000000
|
||||
int id notification_main_column 0x00000000
|
||||
int id notification_main_column_container 0x00000000
|
||||
int id right 0x00000000
|
||||
int id right_icon 0x00000000
|
||||
int id right_side 0x00000000
|
||||
int id special_effects_controller_view_tag 0x00000000
|
||||
int id start 0x00000000
|
||||
int id status_bar_latest_event_content 0x00000000
|
||||
int id tag_accessibility_actions 0x00000000
|
||||
int id tag_accessibility_clickable_spans 0x00000000
|
||||
int id tag_accessibility_heading 0x00000000
|
||||
int id tag_accessibility_pane_title 0x00000000
|
||||
int id tag_screen_reader_focusable 0x00000000
|
||||
int id tag_transition_group 0x00000000
|
||||
int id tag_unhandled_key_event_manager 0x00000000
|
||||
int id tag_unhandled_key_listeners 0x00000000
|
||||
int id text 0x00000000
|
||||
int id text2 0x00000000
|
||||
int id time 0x00000000
|
||||
int id title 0x00000000
|
||||
int id top 0x00000000
|
||||
int id view_tree_lifecycle_owner 0x00000000
|
||||
int id view_tree_saved_state_registry_owner 0x00000000
|
||||
int id view_tree_view_model_store_owner 0x00000000
|
||||
int id visible_removing_fragment_view_tag 0x00000000
|
||||
int integer cancel_button_image_alpha 0x00000000
|
||||
int integer status_bar_notification_info_maxnum 0x00000000
|
||||
int layout custom_dialog 0x00000000
|
||||
int layout notification_action 0x00000000
|
||||
int layout notification_action_tombstone 0x00000000
|
||||
int layout notification_media_action 0x00000000
|
||||
int layout notification_media_cancel_action 0x00000000
|
||||
int layout notification_template_big_media 0x00000000
|
||||
int layout notification_template_big_media_custom 0x00000000
|
||||
int layout notification_template_big_media_narrow 0x00000000
|
||||
int layout notification_template_big_media_narrow_custom 0x00000000
|
||||
int layout notification_template_custom_big 0x00000000
|
||||
int layout notification_template_icon_group 0x00000000
|
||||
int layout notification_template_lines_media 0x00000000
|
||||
int layout notification_template_media 0x00000000
|
||||
int layout notification_template_media_custom 0x00000000
|
||||
int layout notification_template_part_chronometer 0x00000000
|
||||
int layout notification_template_part_time 0x00000000
|
||||
int string status_bar_notification_info_overflow 0x00000000
|
||||
int style TextAppearance_Compat_Notification 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Info 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Info_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Line2 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Line2_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Time 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Time_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Title 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Title_Media 0x00000000
|
||||
int style Widget_Compat_NotificationActionContainer 0x00000000
|
||||
int style Widget_Compat_NotificationActionText 0x00000000
|
||||
int style Widget_Support_CoordinatorLayout 0x00000000
|
||||
int[] styleable ColorStateListItem { 0x010101a5, 0x0101031f, 0x00000000 }
|
||||
int styleable ColorStateListItem_android_color 0
|
||||
int styleable ColorStateListItem_android_alpha 1
|
||||
int styleable ColorStateListItem_alpha 2
|
||||
int[] styleable CoordinatorLayout { 0x00000000, 0x00000000 }
|
||||
int styleable CoordinatorLayout_keylines 0
|
||||
int styleable CoordinatorLayout_statusBarBackground 1
|
||||
int[] styleable CoordinatorLayout_Layout { 0x010100b3, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
int styleable CoordinatorLayout_Layout_android_layout_gravity 0
|
||||
int styleable CoordinatorLayout_Layout_layout_anchor 1
|
||||
int styleable CoordinatorLayout_Layout_layout_anchorGravity 2
|
||||
int styleable CoordinatorLayout_Layout_layout_behavior 3
|
||||
int styleable CoordinatorLayout_Layout_layout_dodgeInsetEdges 4
|
||||
int styleable CoordinatorLayout_Layout_layout_insetEdge 5
|
||||
int styleable CoordinatorLayout_Layout_layout_keyline 6
|
||||
int[] styleable FontFamily { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
int styleable FontFamily_fontProviderAuthority 0
|
||||
int styleable FontFamily_fontProviderCerts 1
|
||||
int styleable FontFamily_fontProviderFetchStrategy 2
|
||||
int styleable FontFamily_fontProviderFetchTimeout 3
|
||||
int styleable FontFamily_fontProviderPackage 4
|
||||
int styleable FontFamily_fontProviderQuery 5
|
||||
int[] styleable FontFamilyFont { 0x01010532, 0x01010533, 0x0101053f, 0x0101056f, 0x01010570, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
int styleable FontFamilyFont_android_font 0
|
||||
int styleable FontFamilyFont_android_fontWeight 1
|
||||
int styleable FontFamilyFont_android_fontStyle 2
|
||||
int styleable FontFamilyFont_android_ttcIndex 3
|
||||
int styleable FontFamilyFont_android_fontVariationSettings 4
|
||||
int styleable FontFamilyFont_font 5
|
||||
int styleable FontFamilyFont_fontStyle 6
|
||||
int styleable FontFamilyFont_fontVariationSettings 7
|
||||
int styleable FontFamilyFont_fontWeight 8
|
||||
int styleable FontFamilyFont_ttcIndex 9
|
||||
int[] styleable Fragment { 0x01010003, 0x010100d0, 0x010100d1 }
|
||||
int styleable Fragment_android_name 0
|
||||
int styleable Fragment_android_id 1
|
||||
int styleable Fragment_android_tag 2
|
||||
int[] styleable FragmentContainerView { 0x01010003, 0x010100d1 }
|
||||
int styleable FragmentContainerView_android_name 0
|
||||
int styleable FragmentContainerView_android_tag 1
|
||||
int[] styleable GradientColor { 0x0101019d, 0x0101019e, 0x010101a1, 0x010101a2, 0x010101a3, 0x010101a4, 0x01010201, 0x0101020b, 0x01010510, 0x01010511, 0x01010512, 0x01010513 }
|
||||
int styleable GradientColor_android_startColor 0
|
||||
int styleable GradientColor_android_endColor 1
|
||||
int styleable GradientColor_android_type 2
|
||||
int styleable GradientColor_android_centerX 3
|
||||
int styleable GradientColor_android_centerY 4
|
||||
int styleable GradientColor_android_gradientRadius 5
|
||||
int styleable GradientColor_android_tileMode 6
|
||||
int styleable GradientColor_android_centerColor 7
|
||||
int styleable GradientColor_android_startX 8
|
||||
int styleable GradientColor_android_startY 9
|
||||
int styleable GradientColor_android_endX 10
|
||||
int styleable GradientColor_android_endY 11
|
||||
int[] styleable GradientColorItem { 0x010101a5, 0x01010514 }
|
||||
int styleable GradientColorItem_android_color 0
|
||||
int styleable GradientColorItem_android_offset 1
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.tasks.vision" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="24"
|
||||
android:targetSdkVersion="34" />
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,255 @@
|
||||
int anim fragment_fast_out_extra_slow_in 0x00000000
|
||||
int animator fragment_close_enter 0x00000000
|
||||
int animator fragment_close_exit 0x00000000
|
||||
int animator fragment_fade_enter 0x00000000
|
||||
int animator fragment_fade_exit 0x00000000
|
||||
int animator fragment_open_enter 0x00000000
|
||||
int animator fragment_open_exit 0x00000000
|
||||
int attr alpha 0x00000000
|
||||
int attr coordinatorLayoutStyle 0x00000000
|
||||
int attr font 0x00000000
|
||||
int attr fontProviderAuthority 0x00000000
|
||||
int attr fontProviderCerts 0x00000000
|
||||
int attr fontProviderFetchStrategy 0x00000000
|
||||
int attr fontProviderFetchTimeout 0x00000000
|
||||
int attr fontProviderPackage 0x00000000
|
||||
int attr fontProviderQuery 0x00000000
|
||||
int attr fontStyle 0x00000000
|
||||
int attr fontVariationSettings 0x00000000
|
||||
int attr fontWeight 0x00000000
|
||||
int attr keylines 0x00000000
|
||||
int attr layout_anchor 0x00000000
|
||||
int attr layout_anchorGravity 0x00000000
|
||||
int attr layout_behavior 0x00000000
|
||||
int attr layout_dodgeInsetEdges 0x00000000
|
||||
int attr layout_insetEdge 0x00000000
|
||||
int attr layout_keyline 0x00000000
|
||||
int attr statusBarBackground 0x00000000
|
||||
int attr ttcIndex 0x00000000
|
||||
int color notification_action_color_filter 0x00000000
|
||||
int color notification_icon_bg_color 0x00000000
|
||||
int color notification_material_background_media_default_color 0x00000000
|
||||
int color primary_text_default_material_dark 0x00000000
|
||||
int color ripple_material_light 0x00000000
|
||||
int color secondary_text_default_material_dark 0x00000000
|
||||
int color secondary_text_default_material_light 0x00000000
|
||||
int dimen compat_button_inset_horizontal_material 0x00000000
|
||||
int dimen compat_button_inset_vertical_material 0x00000000
|
||||
int dimen compat_button_padding_horizontal_material 0x00000000
|
||||
int dimen compat_button_padding_vertical_material 0x00000000
|
||||
int dimen compat_control_corner_material 0x00000000
|
||||
int dimen compat_notification_large_icon_max_height 0x00000000
|
||||
int dimen compat_notification_large_icon_max_width 0x00000000
|
||||
int dimen notification_action_icon_size 0x00000000
|
||||
int dimen notification_action_text_size 0x00000000
|
||||
int dimen notification_big_circle_margin 0x00000000
|
||||
int dimen notification_content_margin_start 0x00000000
|
||||
int dimen notification_large_icon_height 0x00000000
|
||||
int dimen notification_large_icon_width 0x00000000
|
||||
int dimen notification_main_column_padding_top 0x00000000
|
||||
int dimen notification_media_narrow_margin 0x00000000
|
||||
int dimen notification_right_icon_size 0x00000000
|
||||
int dimen notification_right_side_padding_top 0x00000000
|
||||
int dimen notification_small_icon_background_padding 0x00000000
|
||||
int dimen notification_small_icon_size_as_large 0x00000000
|
||||
int dimen notification_subtext_size 0x00000000
|
||||
int dimen notification_top_pad 0x00000000
|
||||
int dimen notification_top_pad_large_text 0x00000000
|
||||
int dimen subtitle_corner_radius 0x00000000
|
||||
int dimen subtitle_outline_width 0x00000000
|
||||
int dimen subtitle_shadow_offset 0x00000000
|
||||
int dimen subtitle_shadow_radius 0x00000000
|
||||
int drawable notification_action_background 0x00000000
|
||||
int drawable notification_bg 0x00000000
|
||||
int drawable notification_bg_low 0x00000000
|
||||
int drawable notification_bg_low_normal 0x00000000
|
||||
int drawable notification_bg_low_pressed 0x00000000
|
||||
int drawable notification_bg_normal 0x00000000
|
||||
int drawable notification_bg_normal_pressed 0x00000000
|
||||
int drawable notification_icon_background 0x00000000
|
||||
int drawable notification_template_icon_bg 0x00000000
|
||||
int drawable notification_template_icon_low_bg 0x00000000
|
||||
int drawable notification_tile_bg 0x00000000
|
||||
int drawable notify_panel_notification_icon_bg 0x00000000
|
||||
int id accessibility_action_clickable_span 0x00000000
|
||||
int id accessibility_custom_action_0 0x00000000
|
||||
int id accessibility_custom_action_1 0x00000000
|
||||
int id accessibility_custom_action_10 0x00000000
|
||||
int id accessibility_custom_action_11 0x00000000
|
||||
int id accessibility_custom_action_12 0x00000000
|
||||
int id accessibility_custom_action_13 0x00000000
|
||||
int id accessibility_custom_action_14 0x00000000
|
||||
int id accessibility_custom_action_15 0x00000000
|
||||
int id accessibility_custom_action_16 0x00000000
|
||||
int id accessibility_custom_action_17 0x00000000
|
||||
int id accessibility_custom_action_18 0x00000000
|
||||
int id accessibility_custom_action_19 0x00000000
|
||||
int id accessibility_custom_action_2 0x00000000
|
||||
int id accessibility_custom_action_20 0x00000000
|
||||
int id accessibility_custom_action_21 0x00000000
|
||||
int id accessibility_custom_action_22 0x00000000
|
||||
int id accessibility_custom_action_23 0x00000000
|
||||
int id accessibility_custom_action_24 0x00000000
|
||||
int id accessibility_custom_action_25 0x00000000
|
||||
int id accessibility_custom_action_26 0x00000000
|
||||
int id accessibility_custom_action_27 0x00000000
|
||||
int id accessibility_custom_action_28 0x00000000
|
||||
int id accessibility_custom_action_29 0x00000000
|
||||
int id accessibility_custom_action_3 0x00000000
|
||||
int id accessibility_custom_action_30 0x00000000
|
||||
int id accessibility_custom_action_31 0x00000000
|
||||
int id accessibility_custom_action_4 0x00000000
|
||||
int id accessibility_custom_action_5 0x00000000
|
||||
int id accessibility_custom_action_6 0x00000000
|
||||
int id accessibility_custom_action_7 0x00000000
|
||||
int id accessibility_custom_action_8 0x00000000
|
||||
int id accessibility_custom_action_9 0x00000000
|
||||
int id action0 0x00000000
|
||||
int id action_container 0x00000000
|
||||
int id action_divider 0x00000000
|
||||
int id action_image 0x00000000
|
||||
int id action_text 0x00000000
|
||||
int id actions 0x00000000
|
||||
int id all 0x00000000
|
||||
int id async 0x00000000
|
||||
int id blocking 0x00000000
|
||||
int id bottom 0x00000000
|
||||
int id cancel_action 0x00000000
|
||||
int id center 0x00000000
|
||||
int id center_horizontal 0x00000000
|
||||
int id center_vertical 0x00000000
|
||||
int id chronometer 0x00000000
|
||||
int id clip_horizontal 0x00000000
|
||||
int id clip_vertical 0x00000000
|
||||
int id dialog_button 0x00000000
|
||||
int id end 0x00000000
|
||||
int id end_padder 0x00000000
|
||||
int id fill 0x00000000
|
||||
int id fill_horizontal 0x00000000
|
||||
int id fill_vertical 0x00000000
|
||||
int id forever 0x00000000
|
||||
int id fragment_container_view_tag 0x00000000
|
||||
int id icon 0x00000000
|
||||
int id icon_group 0x00000000
|
||||
int id info 0x00000000
|
||||
int id italic 0x00000000
|
||||
int id left 0x00000000
|
||||
int id line1 0x00000000
|
||||
int id line3 0x00000000
|
||||
int id media_actions 0x00000000
|
||||
int id none 0x00000000
|
||||
int id normal 0x00000000
|
||||
int id notification_background 0x00000000
|
||||
int id notification_main_column 0x00000000
|
||||
int id notification_main_column_container 0x00000000
|
||||
int id right 0x00000000
|
||||
int id right_icon 0x00000000
|
||||
int id right_side 0x00000000
|
||||
int id special_effects_controller_view_tag 0x00000000
|
||||
int id start 0x00000000
|
||||
int id status_bar_latest_event_content 0x00000000
|
||||
int id tag_accessibility_actions 0x00000000
|
||||
int id tag_accessibility_clickable_spans 0x00000000
|
||||
int id tag_accessibility_heading 0x00000000
|
||||
int id tag_accessibility_pane_title 0x00000000
|
||||
int id tag_screen_reader_focusable 0x00000000
|
||||
int id tag_transition_group 0x00000000
|
||||
int id tag_unhandled_key_event_manager 0x00000000
|
||||
int id tag_unhandled_key_listeners 0x00000000
|
||||
int id text 0x00000000
|
||||
int id text2 0x00000000
|
||||
int id time 0x00000000
|
||||
int id title 0x00000000
|
||||
int id top 0x00000000
|
||||
int id view_tree_lifecycle_owner 0x00000000
|
||||
int id view_tree_saved_state_registry_owner 0x00000000
|
||||
int id view_tree_view_model_store_owner 0x00000000
|
||||
int id visible_removing_fragment_view_tag 0x00000000
|
||||
int integer cancel_button_image_alpha 0x00000000
|
||||
int integer status_bar_notification_info_maxnum 0x00000000
|
||||
int layout custom_dialog 0x00000000
|
||||
int layout notification_action 0x00000000
|
||||
int layout notification_action_tombstone 0x00000000
|
||||
int layout notification_media_action 0x00000000
|
||||
int layout notification_media_cancel_action 0x00000000
|
||||
int layout notification_template_big_media 0x00000000
|
||||
int layout notification_template_big_media_custom 0x00000000
|
||||
int layout notification_template_big_media_narrow 0x00000000
|
||||
int layout notification_template_big_media_narrow_custom 0x00000000
|
||||
int layout notification_template_custom_big 0x00000000
|
||||
int layout notification_template_icon_group 0x00000000
|
||||
int layout notification_template_lines_media 0x00000000
|
||||
int layout notification_template_media 0x00000000
|
||||
int layout notification_template_media_custom 0x00000000
|
||||
int layout notification_template_part_chronometer 0x00000000
|
||||
int layout notification_template_part_time 0x00000000
|
||||
int string status_bar_notification_info_overflow 0x00000000
|
||||
int style TextAppearance_Compat_Notification 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Info 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Info_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Line2 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Line2_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Time 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Time_Media 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Title 0x00000000
|
||||
int style TextAppearance_Compat_Notification_Title_Media 0x00000000
|
||||
int style Widget_Compat_NotificationActionContainer 0x00000000
|
||||
int style Widget_Compat_NotificationActionText 0x00000000
|
||||
int style Widget_Support_CoordinatorLayout 0x00000000
|
||||
int[] styleable ColorStateListItem { 0x010101a5, 0x0101031f, 0x00000000 }
|
||||
int styleable ColorStateListItem_android_color 0
|
||||
int styleable ColorStateListItem_android_alpha 1
|
||||
int styleable ColorStateListItem_alpha 2
|
||||
int[] styleable CoordinatorLayout { 0x00000000, 0x00000000 }
|
||||
int styleable CoordinatorLayout_keylines 0
|
||||
int styleable CoordinatorLayout_statusBarBackground 1
|
||||
int[] styleable CoordinatorLayout_Layout { 0x010100b3, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
int styleable CoordinatorLayout_Layout_android_layout_gravity 0
|
||||
int styleable CoordinatorLayout_Layout_layout_anchor 1
|
||||
int styleable CoordinatorLayout_Layout_layout_anchorGravity 2
|
||||
int styleable CoordinatorLayout_Layout_layout_behavior 3
|
||||
int styleable CoordinatorLayout_Layout_layout_dodgeInsetEdges 4
|
||||
int styleable CoordinatorLayout_Layout_layout_insetEdge 5
|
||||
int styleable CoordinatorLayout_Layout_layout_keyline 6
|
||||
int[] styleable FontFamily { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
int styleable FontFamily_fontProviderAuthority 0
|
||||
int styleable FontFamily_fontProviderCerts 1
|
||||
int styleable FontFamily_fontProviderFetchStrategy 2
|
||||
int styleable FontFamily_fontProviderFetchTimeout 3
|
||||
int styleable FontFamily_fontProviderPackage 4
|
||||
int styleable FontFamily_fontProviderQuery 5
|
||||
int[] styleable FontFamilyFont { 0x01010532, 0x01010533, 0x0101053f, 0x0101056f, 0x01010570, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }
|
||||
int styleable FontFamilyFont_android_font 0
|
||||
int styleable FontFamilyFont_android_fontWeight 1
|
||||
int styleable FontFamilyFont_android_fontStyle 2
|
||||
int styleable FontFamilyFont_android_ttcIndex 3
|
||||
int styleable FontFamilyFont_android_fontVariationSettings 4
|
||||
int styleable FontFamilyFont_font 5
|
||||
int styleable FontFamilyFont_fontStyle 6
|
||||
int styleable FontFamilyFont_fontVariationSettings 7
|
||||
int styleable FontFamilyFont_fontWeight 8
|
||||
int styleable FontFamilyFont_ttcIndex 9
|
||||
int[] styleable Fragment { 0x01010003, 0x010100d0, 0x010100d1 }
|
||||
int styleable Fragment_android_name 0
|
||||
int styleable Fragment_android_id 1
|
||||
int styleable Fragment_android_tag 2
|
||||
int[] styleable FragmentContainerView { 0x01010003, 0x010100d1 }
|
||||
int styleable FragmentContainerView_android_name 0
|
||||
int styleable FragmentContainerView_android_tag 1
|
||||
int[] styleable GradientColor { 0x0101019d, 0x0101019e, 0x010101a1, 0x010101a2, 0x010101a3, 0x010101a4, 0x01010201, 0x0101020b, 0x01010510, 0x01010511, 0x01010512, 0x01010513 }
|
||||
int styleable GradientColor_android_startColor 0
|
||||
int styleable GradientColor_android_endColor 1
|
||||
int styleable GradientColor_android_type 2
|
||||
int styleable GradientColor_android_centerX 3
|
||||
int styleable GradientColor_android_centerY 4
|
||||
int styleable GradientColor_android_gradientRadius 5
|
||||
int styleable GradientColor_android_tileMode 6
|
||||
int styleable GradientColor_android_centerColor 7
|
||||
int styleable GradientColor_android_startX 8
|
||||
int styleable GradientColor_android_startY 9
|
||||
int styleable GradientColor_android_endX 10
|
||||
int styleable GradientColor_android_endY 11
|
||||
int[] styleable GradientColorItem { 0x010101a5, 0x01010514 }
|
||||
int styleable GradientColorItem_android_color 0
|
||||
int styleable GradientColorItem_android_offset 1
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.hmwl.sample;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.hmwl.sample", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -2,33 +2,28 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- Declare features -->
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<!-- 声明摄像头硬件特性 -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Declare permissions -->
|
||||
<!-- 声明摄像头权限 -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Sample">
|
||||
<application>
|
||||
<!-- 声明 MainActivity -->
|
||||
<!-- 作为库,exported 通常设为 false,除非明确需要外部应用启动 -->
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
android:name=".FaceActivity"
|
||||
android:exported="true"
|
||||
tools:ignore="MissingClass"> <!-- 如果IDE报类找不到,可以添加这个 -->
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<!-- 重要:移除 MAIN/LAUNCHER intent-filter -->
|
||||
<!-- 让使用库的应用来决定哪个是主Activity -->
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="sample" />
|
||||
android:value="face_sdk" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -1,26 +1,25 @@
|
||||
#version 450
|
||||
#version 450
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
float ux;
|
||||
float uy;
|
||||
} pushConstants;
|
||||
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(samplerColor, inUV);
|
||||
vec2 pos = vec2(pushConstants.ux/2048.f, pushConstants.uy/2048.f);
|
||||
vec2 uv = pos + vec2(inUV.x/8.f, inUV.y/8.f);
|
||||
vec4 color = texture(samplerColor, uv);
|
||||
|
||||
vec3 N = normalize(inNormal);
|
||||
outFragColor = color;
|
||||
|
||||
vec4 textureColor = color;
|
||||
if (textureColor.a < 0.1) {
|
||||
//textureColor = vec4(0.2, 0.2, 0.2, 0.5);
|
||||
discard;
|
||||
}
|
||||
|
||||
outFragColor = textureColor;
|
||||
|
||||
// outFragColor = vec4(1, 0, 0, 1);
|
||||
}
|
||||
@@ -18,6 +18,8 @@ layout (location = 1) out vec3 outNormal;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
float ux;
|
||||
float uy;
|
||||
} pushConstants;
|
||||
|
||||
out gl_PerVertex
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#version 450
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
layout (binding = 2) uniform sampler2D samplerColor_ex;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(samplerColor, inUV);
|
||||
vec4 color_ex = texture(samplerColor_ex, inUV);
|
||||
|
||||
vec3 N = normalize(inNormal);
|
||||
|
||||
// 计算与 (0,0,1) 的点乘
|
||||
float ndot = dot(N, vec3(0.0, 0.0, -1.0));
|
||||
|
||||
// 保证结果 >= 0
|
||||
ndot = max(ndot, 0.0);
|
||||
|
||||
// 重新映射ndot值,让中间2/3部分进行融合
|
||||
// 当ndot在[0.166, 0.833]范围内时进行混合,两端保持不变
|
||||
float blendFactor;
|
||||
if (ndot < 0.0) {
|
||||
blendFactor = 0.0; // 完全使用color_ex
|
||||
} else if (ndot > 0.1) {
|
||||
blendFactor = 1.0; // 完全使用color
|
||||
} else {
|
||||
// 在中间2/3部分进行平滑过渡
|
||||
blendFactor = (ndot - 0.0) / (1 - 0);
|
||||
}
|
||||
|
||||
// 使用smoothstep创建中间2/3的融合区域
|
||||
// 参数说明:smoothstep(edge0, edge1, x)
|
||||
// 当x < edge0时返回0,当x > edge1时返回1,在中间时平滑过渡
|
||||
//float blendFactor = smoothstep(0.166, 0.833, ndot);
|
||||
|
||||
|
||||
// vec4 blendedColor = mix(color_ex, color, ndot);
|
||||
|
||||
// outFragColor = blendedColor;
|
||||
|
||||
if (ndot < 0.3){
|
||||
outFragColor = color_ex;
|
||||
}
|
||||
else
|
||||
{
|
||||
outFragColor = color;
|
||||
}
|
||||
|
||||
// outFragColor = vec4(1, 0, 0, 1);
|
||||
}
|
||||
@@ -12,9 +12,12 @@ using namespace std;
|
||||
extern "C" {
|
||||
|
||||
android_app* g_android_app = nullptr;
|
||||
Application* g_Application = nullptr;
|
||||
FaceApp* g_Application = nullptr;
|
||||
AAssetManager* g_assetManager = nullptr;
|
||||
|
||||
jobject g_callback = nullptr;
|
||||
jobject g_callbackAnimationFinished = nullptr;
|
||||
|
||||
void handle_cmd(android_app *pApp, int32_t cmd) {
|
||||
switch (cmd) {
|
||||
case APP_CMD_INIT_WINDOW:
|
||||
@@ -29,18 +32,22 @@ void handle_cmd(android_app *pApp, int32_t cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
const int ArgLen = 128*1024;
|
||||
char g_InitArgString[ArgLen] = {0};
|
||||
|
||||
void android_main(struct android_app *pApp) {
|
||||
aout << "Welcome to android_main" << std::endl;
|
||||
g_android_app = pApp;
|
||||
g_assetManager = pApp->activity->assetManager;
|
||||
FaceApp application;
|
||||
g_Application = &application;
|
||||
application.SetInitArg(g_InitArgString);
|
||||
pApp->onAppCmd = handle_cmd;
|
||||
|
||||
long long last_update_time = 0;
|
||||
android_app_set_motion_event_filter(pApp, nullptr);
|
||||
|
||||
long long _lastDrawFrameTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
do {
|
||||
auto ms = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
auto start_time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
// Process all pending events before running game logic.
|
||||
bool done = false;
|
||||
while (!done) {
|
||||
@@ -68,10 +75,19 @@ void android_main(struct android_app *pApp) {
|
||||
}
|
||||
if(application.isInited())
|
||||
{
|
||||
application.drawFrame();
|
||||
auto frameTime = (start_time - _lastDrawFrameTime);
|
||||
_lastDrawFrameTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
application.drawFrame(frameTime);
|
||||
}
|
||||
auto end_time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
auto frameTime = end_time - last_update_time;
|
||||
last_update_time = end_time;
|
||||
auto function_time = (end_time - start_time);
|
||||
//aout << "function_time:" << function_time << " fps:" << (1000/frameTime) << std::endl;
|
||||
if(function_time < 35)
|
||||
{
|
||||
this_thread::sleep_for(chrono::milliseconds((35-function_time)));
|
||||
}
|
||||
auto end_ms = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
this_thread::sleep_for(chrono::milliseconds((end_ms-ms)));
|
||||
} while (!pApp->destroyRequested);
|
||||
application.cleanup();
|
||||
}
|
||||
@@ -85,13 +101,15 @@ void processWithVulkan(uint8_t* data, int width, int height, int format,
|
||||
TextureLoadProcessWithVulkan(data, width, height, rowStride, dataSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_FaceActivity_processImageNative(JNIEnv *env, jobject thiz, jobject buffer,
|
||||
jint width, jint height, jint format,
|
||||
jint row_stride, jint pixel_stride,
|
||||
jint rotation) {
|
||||
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_processImageNative(JNIEnv *env, jobject thiz, jobject buffer,
|
||||
jint width, jint height, jint format,
|
||||
jint row_stride, jint pixel_stride,
|
||||
jint rotation) {
|
||||
// TODO: implement processImageNative()
|
||||
uint8_t* imageData = static_cast<uint8_t*>(env->GetDirectBufferAddress(buffer));
|
||||
jlong capacity = env->GetDirectBufferCapacity(buffer);
|
||||
|
||||
@@ -103,12 +121,11 @@ Java_com_hmwl_face_FaceActivity_processImageNative(JNIEnv *env, jobject thiz, jo
|
||||
// 创建 Vulkan 图像或更新现有图像
|
||||
processWithVulkan(imageData, width, height, format, row_stride, capacity);
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_FaceActivity_passDataToNative(JNIEnv *env, jobject thiz, jobject buffer,
|
||||
jint point_count, jint width, jint height) {
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_passDataToNative(JNIEnv *env, jobject thiz, jobject buffer,
|
||||
jint point_count, jint width, jint height) {
|
||||
// TODO: implement passDataToNative()
|
||||
float* pos = static_cast<float*>(env->GetDirectBufferAddress(buffer));
|
||||
|
||||
if (pos == nullptr) {
|
||||
@@ -119,3 +136,237 @@ Java_com_hmwl_face_FaceActivity_passDataToNative(JNIEnv *env, jobject thiz, jobj
|
||||
// 或者直接将指针传递给Vulkan
|
||||
ReceiveFacePoint(pos, point_count, width, height);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_SetCppInitArg(JNIEnv *env, jobject thiz, jstring json) {
|
||||
// TODO: implement SetCppInitArg()
|
||||
const char *nativeString = env->GetStringUTFChars(json, nullptr);
|
||||
jsize len = env->GetStringUTFLength(json);
|
||||
if(len > ArgLen)
|
||||
{
|
||||
aout << "ArgLen to long:" << len << std::endl;
|
||||
return;
|
||||
}
|
||||
memcpy(g_InitArgString, nativeString, len);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_StopRunning(JNIEnv *env, jobject thiz) {
|
||||
g_Application->_running = false;
|
||||
}
|
||||
|
||||
JavaVM* g_jvm = nullptr;
|
||||
|
||||
// 添加 JNI_OnLoad 函数
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
g_jvm = vm; // 保存 JavaVM 指针,供其他线程使用
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
void CppCallback()
|
||||
{
|
||||
JNIEnv* env = nullptr;
|
||||
bool needDetach = false;
|
||||
|
||||
// 获取当前线程的 JNIEnv
|
||||
JavaVM* vm = g_jvm; // 你需要提前保存 JavaVM* 到全局变量 g_jvm
|
||||
int status = vm->GetEnv((void**)&env, JNI_VERSION_1_6);
|
||||
if (status == JNI_EDETACHED) {
|
||||
// 当前线程未 attach,需 attach
|
||||
if (vm->AttachCurrentThread(&env, nullptr) != 0) {
|
||||
return;
|
||||
}
|
||||
needDetach = true;
|
||||
} else if (status != JNI_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_callback == nullptr) {
|
||||
if (needDetach) vm->DetachCurrentThread();
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 获取 CallbackInterface 的 class
|
||||
jclass callbackClass = env->GetObjectClass(g_callback);
|
||||
if (callbackClass == nullptr) {
|
||||
if (needDetach) vm->DetachCurrentThread();
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnLoadMotionListFinished", "(Ljava/lang/String;)V");
|
||||
if (methodId == nullptr) {
|
||||
env->ExceptionDescribe(); // 打印异常
|
||||
env->ExceptionClear();
|
||||
if (needDetach) vm->DetachCurrentThread();
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 构造 jstring 参数
|
||||
jstring jResult = env->NewStringUTF("ok");
|
||||
|
||||
// 4. 调用 Java 回调
|
||||
env->CallVoidMethod(g_callback, methodId, jResult);
|
||||
|
||||
// 5. 检查是否抛出异常
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
}
|
||||
|
||||
// 6. 释放局部引用(可选,但推荐)
|
||||
env->DeleteLocalRef(jResult);
|
||||
env->DeleteLocalRef(callbackClass);
|
||||
|
||||
// 7. 如果是临时 attach 的线程,要 detach
|
||||
if (needDetach) {
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CppAnimationFinishedCallback()
|
||||
{
|
||||
JNIEnv* env = nullptr;
|
||||
bool needDetach = false;
|
||||
|
||||
// 获取当前线程的 JNIEnv
|
||||
JavaVM* vm = g_jvm; // 你需要提前保存 JavaVM* 到全局变量 g_jvm
|
||||
int status = vm->GetEnv((void**)&env, JNI_VERSION_1_6);
|
||||
if (status == JNI_EDETACHED) {
|
||||
// 当前线程未 attach,需 attach
|
||||
if (vm->AttachCurrentThread(&env, nullptr) != 0) {
|
||||
return;
|
||||
}
|
||||
needDetach = true;
|
||||
} else if (status != JNI_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_callbackAnimationFinished == nullptr) {
|
||||
if (needDetach) vm->DetachCurrentThread();
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 获取 CallbackInterface 的 class
|
||||
jclass callbackClass = env->GetObjectClass(g_callbackAnimationFinished);
|
||||
if (callbackClass == nullptr) {
|
||||
if (needDetach) vm->DetachCurrentThread();
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnPlayMotionListFinished", "()V");
|
||||
if (methodId == nullptr) {
|
||||
env->ExceptionDescribe(); // 打印异常
|
||||
env->ExceptionClear();
|
||||
if (needDetach) vm->DetachCurrentThread();
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 调用 Java 回调
|
||||
env->CallVoidMethod(g_callbackAnimationFinished, methodId);
|
||||
|
||||
// 5. 检查是否抛出异常
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(callbackClass);
|
||||
|
||||
// 7. 如果是临时 attach 的线程,要 detach
|
||||
if (needDetach) {
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_PreReadAction(JNIEnv *env, jobject thiz, jstring motion,
|
||||
jobject callback) {
|
||||
// 清理旧的全局引用
|
||||
if (g_callback != nullptr) {
|
||||
env->DeleteGlobalRef(g_callback);
|
||||
g_callback = nullptr;
|
||||
}
|
||||
|
||||
// 保存新的回调
|
||||
if (callback != nullptr) {
|
||||
g_callback = env->NewGlobalRef(callback);
|
||||
} else {
|
||||
g_callback = nullptr;
|
||||
}
|
||||
|
||||
const char *nativeString = env->GetStringUTFChars(motion, nullptr);
|
||||
jsize len = env->GetStringUTFLength(motion);
|
||||
if(len > ArgLen)
|
||||
{
|
||||
aout << "ArgLen to long:" << len << std::endl;
|
||||
}
|
||||
|
||||
std::string ret = g_Application->preLoadMotionList(nativeString, CppCallback);
|
||||
return env->NewStringUTF(ret.c_str());
|
||||
}
|
||||
|
||||
const char DELIMITER = 0x1F; // same as \u001F
|
||||
|
||||
std::vector<std::string> splitMotionString(const std::string& input) {
|
||||
std::vector<std::string> result;
|
||||
if (input.empty()) return result;
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = input.find(DELIMITER);
|
||||
|
||||
while (pos != std::string::npos) {
|
||||
result.push_back(input.substr(start, pos - start));
|
||||
start = pos + 1;
|
||||
pos = input.find(DELIMITER, start);
|
||||
}
|
||||
// Add last part
|
||||
result.push_back(input.substr(start));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_ChangeMotionCpp(JNIEnv *env, jobject thiz, jstring json,
|
||||
jobject callback, jboolean loop) {
|
||||
// TODO: implement ChangeMotionCpp()
|
||||
const char *nativeString = env->GetStringUTFChars(json, nullptr);
|
||||
jsize len = env->GetStringUTFLength(json);
|
||||
if(len > ArgLen)
|
||||
{
|
||||
aout << "ArgLen to long:" << len << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存新的回调
|
||||
if (callback != nullptr) {
|
||||
g_callbackAnimationFinished = env->NewGlobalRef(callback);
|
||||
} else {
|
||||
g_callbackAnimationFinished = nullptr;
|
||||
}
|
||||
|
||||
if(g_Application->isInited())
|
||||
{
|
||||
std::vector<std::string> motions = splitMotionString(nativeString);
|
||||
g_Application->changeMotionList(motions, CppAnimationFinishedCallback, loop);
|
||||
}
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_StopMotionNative(JNIEnv *env, jobject thiz) {
|
||||
g_Application->StopMotion();
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_ResumeMotionNative(JNIEnv *env, jobject thiz) {
|
||||
// TODO: implement ResumeMotionNative()
|
||||
g_Application->ResumeMotion();
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.hmwl.face;
|
||||
package com.hmwl.face_sdk;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -31,13 +30,12 @@ import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.LandmarkerListener {
|
||||
private static final String TAG = "FaceActivity";
|
||||
|
||||
static {
|
||||
System.loadLibrary("sample");
|
||||
System.loadLibrary("face_sdk");
|
||||
}
|
||||
|
||||
private ProcessCameraProvider cameraProvider;
|
||||
@@ -50,6 +48,21 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == REQUEST_CAMERA_PERMISSION) {
|
||||
// 检查权限是否被授予
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// 用户授予了权限,启动相机
|
||||
startCamera();
|
||||
} else {
|
||||
requestCameraPermission();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startCamera() {
|
||||
ListenableFuture<ProcessCameraProvider> cameraProviderFuture =
|
||||
ProcessCameraProvider.getInstance(this);
|
||||
@@ -70,38 +83,14 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
|
||||
|
||||
imageAnalyzer.setAnalyzer(backgroundExecutor, new ImageAnalysis.Analyzer() {
|
||||
private long lastCaptureTime = 0;
|
||||
private int frameCount = 0;
|
||||
|
||||
@Override
|
||||
public void analyze(@NonNull ImageProxy image) {
|
||||
frameCount++;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
try {
|
||||
long captureTimeNs = image.getImageInfo().getTimestamp();
|
||||
long analyzeTime = System.currentTimeMillis();
|
||||
|
||||
// 简单直接的计算方法
|
||||
long captureTimeMs = TimeUnit.NANOSECONDS.toMillis(captureTimeNs);
|
||||
long latency = analyzeTime - captureTimeMs;
|
||||
|
||||
// 帧率计算
|
||||
if (lastCaptureTime > 0) {
|
||||
long frameInterval = captureTimeMs - lastCaptureTime;
|
||||
double fps = 1000.0 / frameInterval;
|
||||
|
||||
if (frameCount % 10 == 0) { // 每30帧打印一次
|
||||
Log.i("TimeLatency", String.format(
|
||||
"Frame %d - Latency: %d ms, FPS: %.1f",
|
||||
frameCount, latency, fps
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
lastCaptureTime = captureTimeMs;
|
||||
|
||||
processImageForVulkan(image);
|
||||
if(frameCount %2 == 0)
|
||||
if(frameCount %3 == 0)
|
||||
{
|
||||
detectFace(image);
|
||||
}
|
||||
@@ -146,6 +135,22 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop(){
|
||||
StopRunning();
|
||||
}
|
||||
|
||||
private native void StopMotionNative();
|
||||
public void StopMotion(){
|
||||
StopMotionNative();
|
||||
}
|
||||
|
||||
private native void ResumeMotionNative();
|
||||
public void ResumeMotion(){
|
||||
ResumeMotionNative();
|
||||
}
|
||||
|
||||
private native void StopRunning();
|
||||
|
||||
// Native 方法
|
||||
private native void processImageNative(ByteBuffer buffer, int width, int height,
|
||||
int format, int rowStride, int pixelStride,
|
||||
@@ -186,7 +191,6 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
0.5f,
|
||||
0.5f,
|
||||
1,
|
||||
0,
|
||||
RunningMode.LIVE_STREAM,
|
||||
FaceActivity.this,
|
||||
FaceActivity.this
|
||||
@@ -196,31 +200,6 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
int action = event.getActionMasked();
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
Log.d(TAG, "Java Layer: Touch DOWN at (" + x + ", " + y + ")");
|
||||
// ✅ 你可以在这里做些事,比如发消息给 C++,或 UI 反馈
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
Log.d(TAG, "Java Layer: Touch MOVE");
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
Log.d(TAG, "Java Layer: Touch UP");
|
||||
break;
|
||||
}
|
||||
|
||||
// ⚠️ 关键:返回 false 才能让事件继续传递给 Native 层(C++)
|
||||
// 如果返回 true,表示事件已被消费,C++ 层将收不到!
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
@@ -308,4 +287,48 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
}
|
||||
|
||||
public native void passDataToNative(ByteBuffer buffer, int pointCount, int width, int height);
|
||||
|
||||
protected native void SetCppInitArg(String json);
|
||||
|
||||
public void SetInitArg(String json)
|
||||
{
|
||||
SetCppInitArg(json);
|
||||
}
|
||||
|
||||
public interface LoadMotionListFinishedCallback {
|
||||
void OnLoadMotionListFinished(String result);
|
||||
}
|
||||
|
||||
public interface PlayMotionListFinishedCallback {
|
||||
void OnPlayMotionListFinished();
|
||||
}
|
||||
|
||||
protected native String PreReadAction(String motion, LoadMotionListFinishedCallback callback);
|
||||
public String PreLoadAction(String json, LoadMotionListFinishedCallback callback){
|
||||
return PreReadAction(json, callback);
|
||||
}
|
||||
|
||||
protected native void ChangeMotionCpp(String json, PlayMotionListFinishedCallback callback, boolean loop);
|
||||
public void PlayMotionList(List<String> motionList, boolean loop, PlayMotionListFinishedCallback callback)
|
||||
{
|
||||
if(callback == null)
|
||||
{
|
||||
callback = new PlayMotionListFinishedCallback() {
|
||||
@Override
|
||||
public void OnPlayMotionListFinished() {
|
||||
Log.i(TAG, "OnPlayMotionListFinished: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
final String DELIMITER = "\u001F"; // ASCII Unit Separator
|
||||
String motion_list_str = String.join(DELIMITER, motionList);
|
||||
ChangeMotionCpp(motion_list_str, callback, loop);
|
||||
}
|
||||
|
||||
// 添加这个缺失的方法
|
||||
@Override
|
||||
public void onEmpty() {
|
||||
// 当没有检测到人脸时的处理逻辑
|
||||
//Log.d(TAG, "No face detected in the current frame");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hmwl.face
|
||||
package com.hmwl.face_sdk
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
@@ -20,8 +20,7 @@ class FaceLandmarkerHelper(
|
||||
var minFaceTrackingConfidence: Float = DEFAULT_FACE_TRACKING_CONFIDENCE,
|
||||
var minFacePresenceConfidence: Float = DEFAULT_FACE_PRESENCE_CONFIDENCE,
|
||||
var maxNumFaces: Int = DEFAULT_NUM_FACES,
|
||||
var currentDelegate: Int = DELEGATE_CPU,
|
||||
var runningMode: RunningMode = RunningMode.IMAGE,
|
||||
var runningMode: RunningMode = RunningMode.LIVE_STREAM,
|
||||
val context: Context,
|
||||
// this listener is only used when running in RunningMode.LIVE_STREAM
|
||||
val faceLandmarkerHelperListener: LandmarkerListener? = null
|
||||
@@ -50,14 +49,7 @@ class FaceLandmarkerHelper(
|
||||
val baseOptionBuilder = BaseOptions.builder()
|
||||
|
||||
// Use the specified hardware for running the model. Default to CPU
|
||||
when (currentDelegate) {
|
||||
DELEGATE_CPU -> {
|
||||
baseOptionBuilder.setDelegate(Delegate.CPU)
|
||||
}
|
||||
DELEGATE_GPU -> {
|
||||
baseOptionBuilder.setDelegate(Delegate.GPU)
|
||||
}
|
||||
}
|
||||
baseOptionBuilder.setDelegate(Delegate.GPU)
|
||||
|
||||
baseOptionBuilder.setModelAssetPath(MP_FACE_LANDMARKER_TASK)
|
||||
|
||||
@@ -75,6 +67,9 @@ class FaceLandmarkerHelper(
|
||||
}
|
||||
}
|
||||
|
||||
minFaceDetectionConfidence = 0.1f;
|
||||
minFaceTrackingConfidence = 0.1f;
|
||||
minFacePresenceConfidence = 0.1f;
|
||||
try {
|
||||
val baseOptions = baseOptionBuilder.build()
|
||||
// Create an option builder with base options and specific
|
||||
@@ -246,32 +241,33 @@ class FaceLandmarkerHelper(
|
||||
val frameId = result.timestampMs()
|
||||
if( result.faceLandmarks().size > 0 ) {
|
||||
// 计算各种延时
|
||||
val timings = frameTimings[frameId]
|
||||
if (timings != null) {
|
||||
val totalLatency = resultTime - timings.captureTime
|
||||
val preprocessLatency = timings.preprocessEndTime - timings.preprocessStartTime
|
||||
val detectionLatency = resultTime - timings.detectionStartTime
|
||||
val captureToDetectionLatency = timings.detectionStartTime - timings.captureTime
|
||||
|
||||
Log.i("TimeLatency",
|
||||
"总延时: ${totalLatency}ms | " +
|
||||
"预处理: ${preprocessLatency}ms | " +
|
||||
"检测: ${detectionLatency}ms | " +
|
||||
"捕获到检测: ${captureToDetectionLatency}ms | " +
|
||||
"FPS: ${String.format("%.1f", currentFps)}"
|
||||
)
|
||||
|
||||
val finishTimeMs = SystemClock.uptimeMillis()
|
||||
val inferenceTime = finishTimeMs - result.timestampMs()
|
||||
faceLandmarkerHelperListener?.onResults(
|
||||
ResultBundle(
|
||||
result,
|
||||
inferenceTime, // 主要是检测时间
|
||||
input.height,
|
||||
input.width,
|
||||
)
|
||||
)
|
||||
} else {
|
||||
// val timings = frameTimings[frameId]
|
||||
// if (timings != null) {
|
||||
// val totalLatency = resultTime - timings.captureTime
|
||||
// val preprocessLatency = timings.preprocessEndTime - timings.preprocessStartTime
|
||||
// val detectionLatency = resultTime - timings.detectionStartTime
|
||||
// val captureToDetectionLatency = timings.detectionStartTime - timings.captureTime
|
||||
//
|
||||
// Log.i("TimeLatency",
|
||||
// "总延时: ${totalLatency}ms | " +
|
||||
// "预处理: ${preprocessLatency}ms | " +
|
||||
// "检测: ${detectionLatency}ms | " +
|
||||
// "捕获到检测: ${captureToDetectionLatency}ms | " +
|
||||
// "FPS: ${String.format("%.1f", currentFps)}"
|
||||
// )
|
||||
//
|
||||
// val finishTimeMs = SystemClock.uptimeMillis()
|
||||
// val inferenceTime = finishTimeMs - result.timestampMs()
|
||||
// faceLandmarkerHelperListener?.onResults(
|
||||
// ResultBundle(
|
||||
// result,
|
||||
// inferenceTime, // 主要是检测时间
|
||||
// input.height,
|
||||
// input.width,
|
||||
// )
|
||||
// )
|
||||
// } else
|
||||
//{
|
||||
val finishTimeMs = SystemClock.uptimeMillis()
|
||||
val inferenceTime = finishTimeMs - result.timestampMs()
|
||||
Log.i("TimeLatency",
|
||||
@@ -285,7 +281,7 @@ class FaceLandmarkerHelper(
|
||||
input.width
|
||||
)
|
||||
)
|
||||
}
|
||||
//}
|
||||
}
|
||||
else {
|
||||
faceLandmarkerHelperListener?.onEmpty()
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.hmwl.face_sdk;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Frame {
|
||||
public String name;
|
||||
public float x;
|
||||
public float y;
|
||||
public Frame(String name, float x, float y)
|
||||
{
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
public JSONObject toJsonObject(){
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", name);
|
||||
jsonObject.put("x", x);
|
||||
jsonObject.put("y", y);
|
||||
return jsonObject;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hmwl.face_sdk;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class InitArg {
|
||||
public int action_fps;
|
||||
public float zoom;
|
||||
|
||||
public String toJson() {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("action_fps", action_fps);
|
||||
jsonObject.put("zoom", zoom);
|
||||
return jsonObject.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.hmwl.face_sdk;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Motion {
|
||||
public String name = "no";
|
||||
public List<Frame> frames = new ArrayList<>();
|
||||
public Motion(String name, List<Frame> frames)
|
||||
{
|
||||
this.name = name;
|
||||
this.frames = frames;
|
||||
}
|
||||
|
||||
public JSONObject toJsonObject() {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", name);
|
||||
JSONArray jframes = new JSONArray();
|
||||
for(int i = 0; i < frames.size(); ++i){
|
||||
jframes.put(frames.get(i).toJsonObject());
|
||||
}
|
||||
jsonObject.put("frames", jframes);
|
||||
return jsonObject;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.hmwl.face_sdk;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MotionList {
|
||||
public List<Motion> motions = new ArrayList<>();
|
||||
public JSONObject toJsonObject() {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray jMotions = new JSONArray();
|
||||
for(int i = 0; i < motions.size(); ++i){
|
||||
jMotions.put(motions.get(i).toJsonObject());
|
||||
}
|
||||
jsonObject.put("motions", jMotions);
|
||||
return jsonObject;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new JSONObject();
|
||||
}
|
||||
}
|
||||
public String toJsonString(){
|
||||
return toJsonObject().toString();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.hmwl.sample;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.hmwl.face.FaceActivity;
|
||||
|
||||
public class MainActivity extends FaceActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.hmwl.sample;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,19 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.3.2'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
id 'org.jetbrains.kotlin.android' version '2.2.0' apply false
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false // 添加这行
|
||||
//alias(libs.plugins.kotlin.android) apply false
|
||||
//id 'org.jetbrains.kotlin.android' version '2.2.0' apply false
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
glslangValidator -V app/src/main/assets/shaders/bg.frag -o app/src/main/assets/shaders/bg.frag.spv
|
||||
glslangValidator -V app/src/main/assets/shaders/bg.vert -o app/src/main/assets/shaders/bg.vert.spv
|
||||
|
||||
glslangValidator -V app/src/main/assets/shaders/texture.frag -o app/src/main/assets/shaders/texture.frag.spv
|
||||
glslangValidator -V app/src/main/assets/shaders/texture.vert -o app/src/main/assets/shaders/texture.vert.spv
|
||||
|
||||
glslangValidator -V app/src/main/assets/shaders/simple_shader.frag -o app/src/main/assets/shaders/simple_shader.frag.spv
|
||||
glslangValidator -V app/src/main/assets/shaders/simple_shader.vert -o app/src/main/assets/shaders/simple_shader.vert.spv
|
||||
|
||||
glslangValidator -V app/src/main/assets/shaders/texture_thick.frag -o app/src/main/assets/shaders/texture_thick.frag.spv
|
||||
rem glslangValidator -V app/src/main/assets/shaders/texture_thick.vert -o app/src/main/assets/shaders/texture_thick.vert.spv
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,86 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
//alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.inewme.uvmirror'
|
||||
compileSdk 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.inewme.uvmirror.f20251129"
|
||||
minSdk 30
|
||||
targetSdk 36
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.debug
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion '1.5.1'
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '17'
|
||||
}
|
||||
// kotlinOptions {
|
||||
// jvmTarget = '17'
|
||||
// }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation libs.appcompat
|
||||
implementation libs.material
|
||||
implementation libs.games.activity
|
||||
implementation libs.core.ktx
|
||||
implementation libs.androidx.core.ktx
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
|
||||
implementation project(':app')
|
||||
// Jetpack Compose
|
||||
implementation "androidx.compose.ui:ui:1.5.0"
|
||||
implementation "androidx.compose.material3:material3:1.0.0"
|
||||
implementation "androidx.compose.foundation:foundation:1.5.0"
|
||||
implementation "androidx.compose.runtime:runtime:1.5.0"
|
||||
implementation "androidx.activity:activity-compose:1.7.2" // �ؼ����ṩ setContent
|
||||
|
||||
implementation "androidx.compose.ui:ui-tooling:1.5.4"
|
||||
|
||||
def camerax_version = '1.4.2'
|
||||
implementation "androidx.camera:camera-core:$camerax_version"
|
||||
implementation "androidx.camera:camera-camera2:$camerax_version"
|
||||
implementation "androidx.camera:camera-lifecycle:$camerax_version"
|
||||
implementation "androidx.camera:camera-view:$camerax_version"
|
||||
|
||||
implementation 'com.google.protobuf:protobuf-javalite:3.21.12'
|
||||
implementation 'com.google.android.datatransport:transport-runtime:3.1.9'
|
||||
implementation 'com.google.android.datatransport:transport-backend-cct:3.1.9'
|
||||
|
||||
implementation 'com.google.flogger:flogger:0.7.4'
|
||||
implementation 'com.google.flogger:flogger-system-backend:0.7.4'
|
||||
|
||||
implementation 'com.google.guava:guava:31.1-android'
|
||||
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7") // 提供 lifecycleScope
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Sample" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="face_sdk" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".MakeupActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |