diff options
author | Sundar Raman <sunds@ti.com> | 2011-08-25 21:28:35 -0700 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-08-26 12:39:42 -0700 |
commit | 967f1197f015b6d2f3b34e60fa787f7066efb824 (patch) | |
tree | 54fb659724261bc7155a4d340fd089371c16fd70 /camera/OMXCameraAdapter/OMXFD.cpp | |
parent | 816f63fd6a78b45e18819d9967d409c212c88eae (diff) | |
download | hardware_ti_omap4xxx-967f1197f015b6d2f3b34e60fa787f7066efb824.zip hardware_ti_omap4xxx-967f1197f015b6d2f3b34e60fa787f7066efb824.tar.gz hardware_ti_omap4xxx-967f1197f015b6d2f3b34e60fa787f7066efb824.tar.bz2 |
CameraHAL: Filter face detection result to avoid false faces being detected
For real faces, it is seen that the h/w passes a score >=80
For false faces, we seem to get even a score of 70 sometimes.
In order to avoid any issue at application level, we filter
<=70 score.
Change-Id: Ia4855fd79559e6eb8398d80479cbafbd343321f7
Signed-off-by: Sundar Raman <sunds@ti.com>
Diffstat (limited to 'camera/OMXCameraAdapter/OMXFD.cpp')
-rw-r--r-- | camera/OMXCameraAdapter/OMXFD.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/camera/OMXCameraAdapter/OMXFD.cpp b/camera/OMXCameraAdapter/OMXFD.cpp index 92a9eea..e119c28 100644 --- a/camera/OMXCameraAdapter/OMXFD.cpp +++ b/camera/OMXCameraAdapter/OMXFD.cpp @@ -28,6 +28,8 @@ #include "CameraHal.h" #include "OMXCameraAdapter.h" +#define FACE_DETECTION_THRESHOLD 80 + namespace android { status_t OMXCameraAdapter::setParametersFD(const CameraParameters ¶ms, @@ -379,30 +381,39 @@ status_t OMXCameraAdapter::encodeFaceCoordinates(const OMX_FACEDETECTIONTYPE *fa trans_bot = 3; // bottom } - for ( int i = 0 ; i < faceData->ulFaceCount ; i++) - { - tmp = ( double ) faceData->tFacePosition[i].nLeft / ( double ) previewWidth; + int j = 0, i = 0; + for ( ; j < faceData->ulFaceCount ; j++) + { + //Face filtering + //For real faces, it is seen that the h/w passes a score >=80 + //For false faces, we seem to get even a score of 70 sometimes. + //In order to avoid any issue at application level, we filter + //<=70 score here. + if(faceData->tFacePosition[j].nScore <= FACE_DETECTION_THRESHOLD) + continue; + + tmp = ( double ) faceData->tFacePosition[j].nLeft / ( double ) previewWidth; tmp *= hRange; tmp -= hRange/2; faces[i].rect[trans_left] = tmp; - tmp = ( double ) faceData->tFacePosition[i].nTop / ( double )previewHeight; + tmp = ( double ) faceData->tFacePosition[j].nTop / ( double )previewHeight; tmp *= vRange; tmp -= vRange/2; faces[i].rect[trans_top] = tmp; - tmp = ( double ) faceData->tFacePosition[i].nWidth / ( double ) previewWidth; + tmp = ( double ) faceData->tFacePosition[j].nWidth / ( double ) previewWidth; tmp *= hRange; tmp *= orient_mult; faces[i].rect[trans_right] = faces[i].rect[trans_left] + tmp; - tmp = ( double ) faceData->tFacePosition[i].nHeight / ( double ) previewHeight; + tmp = ( double ) faceData->tFacePosition[j].nHeight / ( double ) previewHeight; tmp *= vRange; tmp *= orient_mult; faces[i].rect[trans_bot] = faces[i].rect[trans_top] + tmp; - faces[i].score = faceData->tFacePosition[i].nScore; + faces[i].score = faceData->tFacePosition[j].nScore; faces[i].id = 0; faces[i].left_eye[0] = CameraFDResult::INVALID_DATA; faces[i].left_eye[1] = CameraFDResult::INVALID_DATA; @@ -410,9 +421,10 @@ status_t OMXCameraAdapter::encodeFaceCoordinates(const OMX_FACEDETECTIONTYPE *fa faces[i].right_eye[1] = CameraFDResult::INVALID_DATA; faces[i].mouth[0] = CameraFDResult::INVALID_DATA; faces[i].mouth[1] = CameraFDResult::INVALID_DATA; + i++; } - faceResult->number_of_faces = faceData->ulFaceCount; + faceResult->number_of_faces = i; faceResult->faces = faces; } else { |