Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ab4274e4f | ||
|
|
5d8e108306 | ||
|
|
52c9da08ed | ||
|
|
496d56f9c6 | ||
|
|
60b40bfd5f | ||
|
|
b44162e6cb | ||
|
|
6ef6e012bd | ||
|
|
f5b2d490c0 | ||
|
|
4c5a05ae21 | ||
|
|
1f9e4939b9 |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -9,7 +9,33 @@ layout(location = 0) out vec4 outColor;
|
||||
// 纹理采样器
|
||||
layout(binding = 0) uniform sampler2D texSampler;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float zoom;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float radius;
|
||||
float ux;
|
||||
float uy;
|
||||
} pushConstants;
|
||||
|
||||
void main() {
|
||||
// 采样纹理
|
||||
outColor = texture(texSampler, inTexCoord);
|
||||
// outFragColor = color;
|
||||
// 获取当前片元的屏幕坐标(左下角为原点)
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
|
||||
// 屏幕中心(480x480 的中心是 (240, 240))
|
||||
vec2 center = vec2(240.0, 240.0);
|
||||
|
||||
// 计算到中心的距离(欧氏距离,单位:像素)
|
||||
float dist = length(fragCoord - center);
|
||||
|
||||
// 判断是否在半径之外
|
||||
if (dist > pushConstants.radius) {
|
||||
// 使用 push constant 中的 RGB 颜色(注意 alpha 设为 1.0)
|
||||
outColor = vec4(pushConstants.r, pushConstants.g, pushConstants.b, 1.0);
|
||||
} else {
|
||||
// 采样纹理
|
||||
outColor = texture(texSampler, inTexCoord);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,15 @@ const vec2 texCoords[6] = vec2[6](
|
||||
|
||||
// 定义 Push Constant,只有一个 float
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
float zoom;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float radius;
|
||||
float ux;
|
||||
float uy;
|
||||
float offset_x;
|
||||
float offset_y;
|
||||
} pushConstants;
|
||||
|
||||
|
||||
@@ -48,7 +56,9 @@ layout(location = 0) out vec2 outTexCoord;
|
||||
void main() {
|
||||
// 获取顶点位置
|
||||
vec2 position = positions[gl_VertexIndex];
|
||||
position = position * pushConstants.myValue;
|
||||
position = position * pushConstants.zoom;
|
||||
position.x = position.x + (pushConstants.offset_x/480);
|
||||
position.y = position.y + (pushConstants.offset_y/480);
|
||||
|
||||
// 设置输出位置(Vulkan使用不同的坐标系)
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
|
||||
@@ -6,7 +6,11 @@ layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
float zoom;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float radius;
|
||||
float ux;
|
||||
float uy;
|
||||
} pushConstants;
|
||||
@@ -16,10 +20,25 @@ layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
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);
|
||||
// outFragColor = color;
|
||||
// 获取当前片元的屏幕坐标(左下角为原点)
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
|
||||
outFragColor = color;
|
||||
// 屏幕中心(480x480 的中心是 (240, 240))
|
||||
vec2 center = vec2(240.0, 240.0);
|
||||
|
||||
// 计算到中心的距离(欧氏距离,单位:像素)
|
||||
float dist = length(fragCoord - center);
|
||||
|
||||
// 判断是否在半径之外
|
||||
if (dist > pushConstants.radius) {
|
||||
// 使用 push constant 中的 RGB 颜色(注意 alpha 设为 1.0)
|
||||
outFragColor = vec4(pushConstants.r, pushConstants.g, pushConstants.b, 1.0);
|
||||
} else {
|
||||
vec2 pos = vec2(pushConstants.ux/4096.f, pushConstants.uy/2048.f);
|
||||
vec2 uv = pos + vec2(inUV.x/8.f, inUV.y/4.f);
|
||||
vec4 color = texture(samplerColor, uv);
|
||||
outFragColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,9 +17,15 @@ layout (location = 0) out vec2 outUV;
|
||||
layout (location = 1) out vec3 outNormal;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
float zoom;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float radius;
|
||||
float ux;
|
||||
float uy;
|
||||
float offset_x;
|
||||
float offset_y;
|
||||
} pushConstants;
|
||||
|
||||
out gl_PerVertex
|
||||
@@ -32,7 +38,9 @@ void main()
|
||||
outUV = inUV;
|
||||
|
||||
vec2 position = vec2(inPos.xy*2 -1);
|
||||
position = position * pushConstants.myValue;
|
||||
position = position * pushConstants.zoom;
|
||||
position.x = position.x + (pushConstants.offset_x/480);
|
||||
position.y = position.y + (pushConstants.offset_y/480);
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
|
||||
@@ -39,9 +39,12 @@ 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);
|
||||
//FaceApp application;
|
||||
//g_Application = &application;
|
||||
if(g_Application == nullptr) {
|
||||
g_Application = new FaceApp();
|
||||
}
|
||||
g_Application->SetInitArg(g_InitArgString);
|
||||
pApp->onAppCmd = handle_cmd;
|
||||
long long last_update_time = 0;
|
||||
android_app_set_motion_event_filter(pApp, nullptr);
|
||||
@@ -73,11 +76,11 @@ void android_main(struct android_app *pApp) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(application.isInited())
|
||||
if(g_Application->isInited())
|
||||
{
|
||||
auto frameTime = (start_time - _lastDrawFrameTime);
|
||||
_lastDrawFrameTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
|
||||
application.drawFrame(frameTime);
|
||||
g_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;
|
||||
@@ -89,7 +92,9 @@ void android_main(struct android_app *pApp) {
|
||||
this_thread::sleep_for(chrono::milliseconds((35-function_time)));
|
||||
}
|
||||
} while (!pApp->destroyRequested);
|
||||
application.cleanup();
|
||||
//application.cleanup();
|
||||
g_Application->cleanupSecondInit();
|
||||
g_Application->clearnSecondFaceApp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +159,7 @@ Java_com_hmwl_face_1sdk_FaceActivity_SetCppInitArg(JNIEnv *env, jobject thiz, js
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_StopRunning(JNIEnv *env, jobject thiz) {
|
||||
g_Application->_running = false;
|
||||
g_Application->Stop();
|
||||
}
|
||||
|
||||
JavaVM* g_jvm = nullptr;
|
||||
|
||||
@@ -94,12 +94,12 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
{
|
||||
detectFace(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.close();
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// image.close();
|
||||
// }
|
||||
} finally {
|
||||
//image.close(); // 确保在这里关闭
|
||||
image.close(); // 确保在这里关闭
|
||||
//Log.d("Camera", "Image closed, ready for next frame");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ class FaceLandmarkerHelper(
|
||||
Bitmap.Config.ARGB_8888
|
||||
)
|
||||
imageProxy.use { bitmapBuffer.copyPixelsFromBuffer(imageProxy.planes[0].buffer) }
|
||||
imageProxy.close()
|
||||
//imageProxy.close()
|
||||
|
||||
val matrix = Matrix().apply {
|
||||
// Rotate the frame received from the camera to be in the same direction as it'll be shown
|
||||
|
||||
@@ -4,12 +4,23 @@ import org.json.JSONObject;
|
||||
public class InitArg {
|
||||
public int action_fps;
|
||||
public float zoom;
|
||||
|
||||
public float r;
|
||||
public float g;
|
||||
public float b;
|
||||
public float radius;
|
||||
public float offset_x;
|
||||
public float offset_y;
|
||||
public String toJson() {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("action_fps", action_fps);
|
||||
jsonObject.put("zoom", zoom);
|
||||
jsonObject.put("r", r);
|
||||
jsonObject.put("g", g);
|
||||
jsonObject.put("b", b);
|
||||
jsonObject.put("radius", radius);
|
||||
jsonObject.put("offset_x", offset_x);
|
||||
jsonObject.put("offset_y", offset_y);
|
||||
return jsonObject.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -9,7 +9,7 @@ android {
|
||||
compileSdk 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.inewme.uvmirror.f20260420"
|
||||
applicationId "com.inewme.uvmirror.f20260113"
|
||||
minSdk 30
|
||||
targetSdk 36
|
||||
versionCode 1
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |