diff options
author | Shuzhen Wang <shuzhenw@codeaurora.org> | 2015-07-06 15:20:24 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:27:32 -0600 |
commit | 4b450ee47386bd982a96c6bf460d010521cf0cff (patch) | |
tree | c8d63e501d96fdd6068fbff39f2c7509fddaa40a | |
parent | 216c932ab6eb1b6601d779bc0cadbabc44280116 (diff) | |
download | frameworks_base-4b450ee47386bd982a96c6bf460d010521cf0cff.zip frameworks_base-4b450ee47386bd982a96c6bf460d010521cf0cff.tar.gz frameworks_base-4b450ee47386bd982a96c6bf460d010521cf0cff.tar.bz2 |
Camera: Extend face detection
This change is the combination of below commits, plus removing
ExtendedFace class from frameworks/base.
# This is the 1st commit message:
Add framework support for extended face detect
CRs-Fixed: 587195
Change-Id: I2a1c477ee6d11f2b9764966abbb85ede9100fe91
# This is the 2nd commit message:
Camera: Extended face features added
- QCFace renamed to ExtendedFace
CRs-Fixed: 587195
Change-Id: I7c7e2073f283522c2f0bd0fa5e7b96a74ae18011
# This is the 3rd commit message:
Camera: QCFace AOST copyrights fixed
AOST files copyright data must not be updated to 2014
CRs-Fixed: 587195
Change-Id: I0cd603da674152c9f47350e571ec3e230b61f8dd
Change-Id: I5d099efe1721e5d26af51006dae4e5f3ea3292d6
-rw-r--r-- | core/java/android/hardware/Camera.java | 17 | ||||
-rw-r--r-- | core/jni/android_hardware_Camera.cpp | 68 |
2 files changed, 82 insertions, 3 deletions
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index cbcc87e..0c8e5aa 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -1839,6 +1839,23 @@ public class Camera { * as a set. Either they are all valid, or none of them are. */ public Point mouth = null; + + /** + * {@hide} + */ + public int smileDegree = 0; + /** + * {@hide} + */ + public int smileScore = 0; + /** + * {@hide} + */ + public int blinkDetected = 0; + /** + * {@hide} + */ + public int faceRecognised = 0; } /** diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 5f1c6bf..e22725b 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -62,6 +62,18 @@ struct fields_t { jmethodID rect_constructor; jmethodID face_constructor; jmethodID point_constructor; + jfieldID face_sm_degree; + jfieldID face_sm_score; + jfieldID face_blink_detected; + jfieldID face_gaze_angle; + jfieldID face_updown_dir; + jfieldID face_leftright_dir; + jfieldID face_roll_dir; + jfieldID face_leye_blink; + jfieldID face_reye_blink; + jfieldID face_left_right_gaze; + jfieldID face_top_bottom_gaze; + jfieldID face_recognised; }; static fields_t fields; @@ -96,6 +108,7 @@ private: jclass mFaceClass; // strong reference to Face class jclass mRectClass; // strong reference to Rect class jclass mPointClass; // strong reference to Point class + bool mIsExtendedFace; Mutex mLock; /* @@ -147,8 +160,16 @@ JNICameraContext::JNICameraContext(JNIEnv* env, jobject weak_this, jclass clazz, mCameraJClass = (jclass)env->NewGlobalRef(clazz); mCamera = camera; - jclass faceClazz = env->FindClass("android/hardware/Camera$Face"); - mFaceClass = (jclass) env->NewGlobalRef(faceClazz); + jclass extendedfaceClazz = env->FindClass("org/codeaurora/camera/ExtendedFace"); + if (NULL != extendedfaceClazz) { + mFaceClass = (jclass) env->NewGlobalRef(extendedfaceClazz); + mIsExtendedFace = true; + } else { + env->ExceptionClear(); + jclass faceClazz = env->FindClass("android/hardware/Camera$Face"); + mFaceClass = (jclass) env->NewGlobalRef(faceClazz); + mIsExtendedFace = false; + } jclass rectClazz = env->FindClass("android/graphics/Rect"); mRectClass = (jclass) env->NewGlobalRef(rectClazz); @@ -368,7 +389,6 @@ void JNICameraContext::postMetadata(JNIEnv *env, int32_t msgType, camera_frame_m env->SetIntField(rect, fields.rect_top, metadata->faces[i].rect[1]); env->SetIntField(rect, fields.rect_right, metadata->faces[i].rect[2]); env->SetIntField(rect, fields.rect_bottom, metadata->faces[i].rect[3]); - env->SetObjectField(face, fields.face_rect, rect); env->SetIntField(face, fields.face_score, metadata->faces[i].score); @@ -397,6 +417,21 @@ void JNICameraContext::postMetadata(JNIEnv *env, int32_t msgType, camera_frame_m env->SetIntField(mouth, fields.point_y, metadata->faces[i].mouth[1]); env->SetObjectField(face, fields.face_mouth, mouth); env->DeleteLocalRef(mouth); + + if (mIsExtendedFace) { + env->SetIntField(face, fields.face_sm_degree, metadata->faces[i].smile_degree); + env->SetIntField(face, fields.face_sm_score, metadata->faces[i].smile_score); + env->SetIntField(face, fields.face_blink_detected, metadata->faces[i].blink_detected); + env->SetIntField(face, fields.face_recognised, metadata->faces[i].face_recognised); + env->SetIntField(face, fields.face_gaze_angle, metadata->faces[i].gaze_angle); + env->SetIntField(face, fields.face_updown_dir, metadata->faces[i].updown_dir); + env->SetIntField(face, fields.face_leftright_dir, metadata->faces[i].leftright_dir); + env->SetIntField(face, fields.face_roll_dir, metadata->faces[i].roll_dir); + env->SetIntField(face, fields.face_leye_blink, metadata->faces[i].leye_blink); + env->SetIntField(face, fields.face_reye_blink, metadata->faces[i].reye_blink); + env->SetIntField(face, fields.face_left_right_gaze, metadata->faces[i].left_right_gaze); + env->SetIntField(face, fields.face_top_bottom_gaze, metadata->faces[i].top_bottom_gaze); + } } env->DeleteLocalRef(face); @@ -1153,6 +1188,27 @@ int register_android_hardware_Camera(JNIEnv *env) { "android/graphics/Point", "y", "I", &fields.point_y}, }; + field extendedfacefields_to_find[] = { + { "org/codeaurora/camera/ExtendedFace", "rect", "Landroid/graphics/Rect;", &fields.face_rect }, + { "org/codeaurora/camera/ExtendedFace", "score", "I", &fields.face_score }, + { "org/codeaurora/camera/ExtendedFace", "id", "I", &fields.face_id }, + { "org/codeaurora/camera/ExtendedFace", "leftEye", "Landroid/graphics/Point;", &fields.face_left_eye }, + { "org/codeaurora/camera/ExtendedFace", "rightEye", "Landroid/graphics/Point;", &fields.face_right_eye }, + { "org/codeaurora/camera/ExtendedFace", "mouth", "Landroid/graphics/Point;", &fields.face_mouth }, + { "org/codeaurora/camera/ExtendedFace", "smileDegree", "I", &fields.face_sm_degree }, + { "org/codeaurora/camera/ExtendedFace", "smileScore", "I", &fields.face_sm_score }, + { "org/codeaurora/camera/ExtendedFace", "blinkDetected", "I", &fields.face_blink_detected }, + { "org/codeaurora/camera/ExtendedFace", "faceRecognized", "I", &fields.face_recognised }, + { "org/codeaurora/camera/ExtendedFace", "gazeAngle", "I", &fields.face_gaze_angle }, + { "org/codeaurora/camera/ExtendedFace", "updownDir", "I", &fields.face_updown_dir }, + { "org/codeaurora/camera/ExtendedFace", "leftrightDir", "I", &fields.face_leftright_dir }, + { "org/codeaurora/camera/ExtendedFace", "rollDir", "I", &fields.face_roll_dir }, + { "org/codeaurora/camera/ExtendedFace", "leyeBlink", "I", &fields.face_leye_blink }, + { "org/codeaurora/camera/ExtendedFace", "reyeBlink", "I", &fields.face_reye_blink }, + { "org/codeaurora/camera/ExtendedFace", "leftrightGaze", "I", &fields.face_left_right_gaze }, + { "org/codeaurora/camera/ExtendedFace", "topbottomGaze", "I", &fields.face_top_bottom_gaze }, + }; + find_fields(env, fields_to_find, NELEM(fields_to_find)); jclass clazz = FindClassOrDie(env, "android/hardware/Camera"); @@ -1172,6 +1228,12 @@ int register_android_hardware_Camera(JNIEnv *env) return -1; } + clazz = env->FindClass("org/codeaurora/camera/ExtendedFace"); + if (NULL != clazz) { + fields.face_constructor = env->GetMethodID(clazz, "<init>", "()V"); + find_fields(env, extendedfacefields_to_find, NELEM(extendedfacefields_to_find)); + } + // Register native functions return RegisterMethodsOrDie(env, "android/hardware/Camera", camMethods, NELEM(camMethods)); } |