完成动画切换
This commit is contained in:
@@ -82,7 +82,7 @@ void android_main(struct android_app *pApp) {
|
||||
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;
|
||||
//aout << "function_time:" << function_time << " fps:" << (1000/frameTime) << std::endl;
|
||||
if(function_time < 35)
|
||||
{
|
||||
this_thread::sleep_for(chrono::milliseconds((35-function_time)));
|
||||
@@ -246,7 +246,18 @@ extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_PreReadAction(JNIEnv *env, jobject thiz, jstring motion,
|
||||
jobject callback) {
|
||||
g_callback = env->NewGlobalRef(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);
|
||||
@@ -254,12 +265,7 @@ Java_com_hmwl_face_1sdk_FaceActivity_PreReadAction(JNIEnv *env, jobject thiz, js
|
||||
{
|
||||
aout << "ArgLen to long:" << len << std::endl;
|
||||
}
|
||||
if(g_Application->isInited())
|
||||
{
|
||||
g_Application->changeMotion(nativeString);
|
||||
}
|
||||
|
||||
// TODO: implement PreReadAction()
|
||||
std::string ret = g_Application->preReadyMotion(nativeString, CppCallback);
|
||||
return env->NewStringUTF(ret.c_str());
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
}
|
||||
|
||||
protected native void ChangeStateCpp(String json);
|
||||
protected void ChangeState(String json){
|
||||
protected void ChangeMotion(String json){
|
||||
Log.i("FaceActivity", "ChangeState:" + json);
|
||||
ChangeStateCpp(json);
|
||||
}
|
||||
@@ -291,6 +291,6 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
||||
@Override
|
||||
public void onEmpty() {
|
||||
// 当没有检测到人脸时的处理逻辑
|
||||
Log.d(TAG, "No face detected in the current frame");
|
||||
//Log.d(TAG, "No face detected in the current frame");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user