diff options
-rw-r--r-- | core/java/android/hardware/Camera.java | 38 | ||||
-rw-r--r-- | core/jni/android_hardware_Camera.cpp | 6 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraHardwareInterface.h | 4 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraHardwareStub.cpp | 6 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 2 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraService.h | 3 |
6 files changed, 33 insertions, 26 deletions
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index d6dbc15..b487764 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -131,7 +131,7 @@ public class Camera { private static final int CAMERA_MSG_RAW_IMAGE = 0x080; private static final int CAMERA_MSG_COMPRESSED_IMAGE = 0x100; private static final int CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x200; - private static final int CAMERA_MSG_FACE = 0x400; + private static final int CAMERA_MSG_METADATA_FACE = 0x400; private static final int CAMERA_MSG_ALL_MSGS = 0x4FF; private int mNativeContext; // accessed by native methods @@ -721,9 +721,9 @@ public class Camera { } return; - case CAMERA_MSG_FACE: + case CAMERA_MSG_METADATA_FACE: if (mFaceListener != null) { - mFaceListener.onFaceDetection((FaceMetadata[])msg.obj, mCamera); + mFaceListener.onFaceDetection((Face[])msg.obj, mCamera); } return; @@ -1078,11 +1078,11 @@ public class Camera { /** * Notify the listener of the detected faces in the preview frame. * - * @param faceMetadata the face information. The list is sorted by the - * score. The highest score is the first element. + * @param faces the detected faces. The list is sorted by the score. + * The highest score is the first element. * @param camera the Camera service object */ - void onFaceDetection(FaceMetadata[] faceMetadata, Camera camera); + void onFaceDetection(Face[] faces, Camera camera); } /** @@ -1151,20 +1151,24 @@ public class Camera { private native final void _stopFaceDetection(); /** - * The information of a face. + * The information of a face from camera face detection. * * @hide */ - public static class FaceMetadata { + public static class Face { /** * Bounds of the face. (-1000, -1000) represents the top-left of the * camera field of view, and (1000, 1000) represents the bottom-right of - * the field of view. This is supported by both hardware and software - * face detection. + * the field of view. The width and height cannot be 0 or negative. This + * is supported by both hardware and software face detection. + * + * <p>The direction is relative to the sensor orientation, that is, what + * the sensor sees. The direction is not affected by the rotation or + * mirroring of {@link #setDisplayOrientation(int)}.</p> * * @see #startFaceDetection(int) */ - Rect face; + Rect rect; /** * The confidence level of the face. The range is 1 to 100. 100 is the @@ -1183,20 +1187,20 @@ public class Camera { int id; /** - * The coordinates of the center of the left eye. null if this is not - * supported. + * The coordinates of the center of the left eye. The range is -1000 to + * 1000. null if this is not supported. */ Point leftEye; /** - * The coordinates of the center of the right eye. null if this is not - * supported. + * The coordinates of the center of the right eye. The range is -1000 to + * 1000. null if this is not supported. */ Point rightEye; /** - * The coordinates of the center of the mouth. null if this is not - * supported. + * The coordinates of the center of the mouth. The range is -1000 to + * 1000. null if this is not supported. */ Point mouth; } diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 3328fc8..3dcaa37 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -38,7 +38,7 @@ struct fields_t { jfieldID surfaceTexture; jfieldID facing; jfieldID orientation; - jfieldID face_rectangle; + jfieldID face_rect; jfieldID face_score; jfieldID rect_left; jfieldID rect_top; @@ -859,8 +859,8 @@ int register_android_hardware_Camera(JNIEnv *env) ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "I", &fields.surfaceTexture }, { "android/hardware/Camera$CameraInfo", "facing", "I", &fields.facing }, { "android/hardware/Camera$CameraInfo", "orientation", "I", &fields.orientation }, - { "android/hardware/Camera$FaceMetadata", "face", "Landroid/graphics/Rect;", &fields.face_rectangle }, - { "android/hardware/Camera$FaceMetadata", "score", "I", &fields.face_score }, + { "android/hardware/Camera$Face", "rect", "Landroid/graphics/Rect;", &fields.face_rect }, + { "android/hardware/Camera$Face", "score", "I", &fields.face_score }, { "android/graphics/Rect", "left", "I", &fields.rect_left }, { "android/graphics/Rect", "top", "I", &fields.rect_top }, { "android/graphics/Rect", "right", "I", &fields.rect_right }, diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h index 09e88c4..31544b3 100644 --- a/services/camera/libcameraservice/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/CameraHardwareInterface.h @@ -38,6 +38,7 @@ typedef void (*notify_callback)(int32_t msgType, typedef void (*data_callback)(int32_t msgType, const sp<IMemory> &dataPtr, + camera_frame_metadata_t *metadata, void* user); typedef void (*data_callback_timestamp)(nsecs_t timestamp, @@ -442,6 +443,7 @@ private: static void __data_cb(int32_t msg_type, const camera_memory_t *data, unsigned int index, + camera_frame_metadata_t *metadata, void *user) { LOGV("%s", __FUNCTION__); @@ -453,7 +455,7 @@ private: index, mem->mNumBufs); return; } - __this->mDataCb(msg_type, mem->mBuffers[index], __this->mCbUser); + __this->mDataCb(msg_type, mem->mBuffers[index], metadata, __this->mCbUser); } static void __data_cb_timestamp(nsecs_t timestamp, int32_t msg_type, diff --git a/services/camera/libcameraservice/CameraHardwareStub.cpp b/services/camera/libcameraservice/CameraHardwareStub.cpp index 07b5a37..863f19e 100644 --- a/services/camera/libcameraservice/CameraHardwareStub.cpp +++ b/services/camera/libcameraservice/CameraHardwareStub.cpp @@ -180,7 +180,7 @@ int CameraHardwareStub::previewThread() // Notify the client of a new frame. if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) - mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie); + mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, NULL, mCallbackCookie); // Advance the buffer pointer. mCurrentPreviewFrame = (mCurrentPreviewFrame + 1) % kBufferCount; @@ -290,14 +290,14 @@ int CameraHardwareStub::pictureThread() sp<MemoryBase> mem = new MemoryBase(mRawHeap, 0, w * h * 3 / 2); FakeCamera cam(w, h); cam.getNextFrameAsYuv420((uint8_t *)mRawHeap->base()); - mDataCb(CAMERA_MSG_RAW_IMAGE, mem, mCallbackCookie); + mDataCb(CAMERA_MSG_RAW_IMAGE, mem, NULL, mCallbackCookie); } if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) { sp<MemoryHeapBase> heap = new MemoryHeapBase(kCannedJpegSize); sp<MemoryBase> mem = new MemoryBase(heap, 0, kCannedJpegSize); memcpy(heap->base(), kCannedJpeg, kCannedJpegSize); - mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie); + mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL, mCallbackCookie); } return NO_ERROR; } diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 96b26e7..b03649e 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -988,7 +988,7 @@ void CameraService::Client::notifyCallback(int32_t msgType, int32_t ext1, } void CameraService::Client::dataCallback(int32_t msgType, - const sp<IMemory>& dataPtr, void* user) { + const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata, void* user) { LOG2("dataCallback(%d)", msgType); sp<Client> client = getClientFromCookie(user); diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index c5fefb8..af7f06e 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -140,7 +140,8 @@ private: // these are static callback functions static void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user); - static void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, void* user); + static void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, + camera_frame_metadata_t *metadata, void* user); static void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr, void* user); // convert client from cookie static sp<Client> getClientFromCookie(void* user); |