summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTae-Young Chung <ty83.chung@samsung.com>2016-04-04 12:02:11 +0900
committerTae-Young Chung <ty83.chung@samsung.com>2016-04-04 12:04:15 +0900
commita6959db3dba7a827108596f5811513826cf4ccd0 (patch)
treed6fd4233be5ca0a1ed96dd5aa3fd251e2938c6b4
parent43a24de64d9650bc734cbd070ee78812b01aec69 (diff)
downloadmediavision-a6959db3dba7a827108596f5811513826cf4ccd0.tar.gz
mediavision-a6959db3dba7a827108596f5811513826cf4ccd0.tar.bz2
mediavision-a6959db3dba7a827108596f5811513826cf4ccd0.zip
Improve recognition performance for EigenFaces and FisherFaces models
1. Change confidence calculation 2. Add error check routine for FisherFaces model when the number of face classes is less than 2 Change-Id: If848ecd48a2b53eb8c0a4b02ac060755c3b30e20 Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
-rw-r--r--mv_face/face/src/FaceRecognitionModel.cpp55
-rw-r--r--packaging/capi-media-vision.spec2
2 files changed, 38 insertions, 19 deletions
diff --git a/mv_face/face/src/FaceRecognitionModel.cpp b/mv_face/face/src/FaceRecognitionModel.cpp
index 7a42cffa..36863424 100644
--- a/mv_face/face/src/FaceRecognitionModel.cpp
+++ b/mv_face/face/src/FaceRecognitionModel.cpp
@@ -372,6 +372,17 @@ const std::set<int>& FaceRecognitionModel::getFaceLabels(void) const
int FaceRecognitionModel::learn(const FaceRecognitionModelConfig& config)
{
+ /* Check number of classes collected for learning, some algorithms
+ * require specific class number constraints. For example, Fisherfaces
+ * requires more that 1 class in training set */
+ if (MEDIA_VISION_FACE_MODEL_TYPE_FISHERFACES == config.mModelType &&
+ m_faceSamples.size() < 2) {
+ LOGE("Can't apply Fisherfaces learning algorithm. It requires at "
+ "least two classes (face labes) to learn on.");
+
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
bool isIncremental = false;
bool isUnisize = false;
@@ -456,30 +467,38 @@ int FaceRecognitionModel::recognize(const cv::Mat& image, FaceRecognitionResults
{
if (!m_recognizer.empty() && m_canRecognize) {
double absConf = 0.0;
+ cv::Mat predictionImg(m_learnAlgorithmConfig.mImgWidth,
+ m_learnAlgorithmConfig.mImgHeight, CV_8UC1);
+
if ((MEDIA_VISION_FACE_MODEL_TYPE_EIGENFACES == m_learnAlgorithmConfig.mModelType ||
- MEDIA_VISION_FACE_MODEL_TYPE_FISHERFACES == m_learnAlgorithmConfig.mModelType) &&
- (image.cols != m_learnAlgorithmConfig.mImgWidth ||
- image.rows != m_learnAlgorithmConfig.mImgHeight)) {
- cv::Mat predictionImg(
- m_learnAlgorithmConfig.mImgWidth,
- m_learnAlgorithmConfig.mImgHeight,
- CV_8UC1);
+ MEDIA_VISION_FACE_MODEL_TYPE_FISHERFACES == m_learnAlgorithmConfig.mModelType) &&
+ (image.cols != m_learnAlgorithmConfig.mImgWidth ||
+ image.rows != m_learnAlgorithmConfig.mImgHeight))
cv::resize(image, predictionImg, predictionImg.size());
- m_recognizer->predict(predictionImg, results.mFaceLabel, absConf);
-
- if (-1 != results.mFaceLabel) {
- results.mConfidence = 1.0;
- results.mIsRecognized = true;
- } else {
- results.mConfidence = 0.0;
- results.mIsRecognized = false;
+ else
+ predictionImg = image;
+
+ m_recognizer->predict(predictionImg, results.mFaceLabel, absConf);
+
+ if (-1 != results.mFaceLabel) {
+ double normShift = 7.5;
+ double normSmooth = 0.05;
+
+ if (MEDIA_VISION_FACE_MODEL_TYPE_EIGENFACES == m_learnAlgorithmConfig.mModelType) {
+ normShift = 5.0;
+ normSmooth = 0.0015;
+ } else if (MEDIA_VISION_FACE_MODEL_TYPE_FISHERFACES == m_learnAlgorithmConfig.mModelType) {
+ normShift = 5.0;
+ normSmooth = 0.01;
}
- } else {
- m_recognizer->predict(image, results.mFaceLabel, absConf);
+
/* Normalize the absolute value of the confidence */
- absConf = exp(7.5 - (0.05 * absConf));
+ absConf = exp(normShift - (normSmooth * absConf));
results.mConfidence = absConf / (1 + absConf);
results.mIsRecognized = true;
+ } else {
+ results.mConfidence = 0.0;
+ results.mIsRecognized = false;
}
results.mFaceLocation = cv::Rect(0, 0, image.cols, image.rows);
diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec
index 2e40b494..dab5a125 100644
--- a/packaging/capi-media-vision.spec
+++ b/packaging/capi-media-vision.spec
@@ -1,6 +1,6 @@
Name: capi-media-vision
Summary: Media Vision library for Tizen Native API
-Version: 0.3.11
+Version: 0.3.12
Release: 0
Group: Multimedia/Framework
License: Apache-2.0 and BSD-2.0