Improve the face recognition accuracy in streaming mode
authorGongwook Lee <gongwook78.lee@samsung.com>
Wed, 20 Mar 2013 04:57:54 +0000 (13:57 +0900)
committerGongwook Lee <gongwook78.lee@samsung.com>
Wed, 20 Mar 2013 04:57:54 +0000 (13:57 +0900)
Change-Id: Id83049c492eea906a03902c96ca5a6459554a062
Signed-off-by: Gongwook Lee <gongwook78.lee@samsung.com>
src/FUixVisionFaceDetector.cpp
src/FUixVisionFaceRecognizer.cpp
src/FUixVision_FaceDetectorImpl.cpp
src/FUixVision_FaceRecognizerImpl.cpp
src/FUixVision_FaceRecognizerImpl.h
src/FUixVision_FaceUtil.cpp

index a6cb5bb..26a8049 100644 (file)
@@ -270,7 +270,7 @@ FaceDetector::PreprocessDataN(const Tizen::Base::ByteBuffer& byteBuffer, const T
        pGrayBuf = __pFaceDetectorImpl->ConvertToGrayN(byteBuffer, dim, format);
 
        pProcessedData = std::unique_ptr<FaceBuffer>(new (std::nothrow) FaceBuffer(*pGrayBuf, dim));
-       SysTryCatch(NID_UIX, pProcessedData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+       SysTryCatch(NID_UIX, pProcessedData.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
                        , GetErrorMessage(E_OUT_OF_MEMORY));
 
        delete pGrayBuf;
index 2d178cf..0a7cc73 100644 (file)
@@ -330,7 +330,7 @@ FaceRecognizer::ExtractFeatureN(const FaceBuffer& preprocessedFaceBuffer, const
                                        r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to extract the facial information.", GetErrorMessage(E_OPERATION_FAILED));
        }
 
-       return __pFaceRecognizerImpl->ExtractFeatureN(*(preprocessedFaceBuffer.GetBuffer()), resolution, faceRect);
+       return __pFaceRecognizerImpl->ExtractFeatureN(*(preprocessedFaceBuffer.GetBuffer()), resolution, faceRect, eyeLeft, eyeRight);
 
 CATCH:
        SetLastResult(r);
index 7c7516f..faea0bc 100644 (file)
@@ -525,12 +525,14 @@ _FaceDetectorImpl::ConvertToGrayN(const Tizen::Base::ByteBuffer& byteBuffer, con
 {
        result r = E_SUCCESS;
        ClearLastResult();
+       int capacity = 0;
 
        std::unique_ptr< Tizen::Base::ByteBuffer > pGrayBuf(new (std::nothrow) Tizen::Base::ByteBuffer());
        SysTryReturn(NID_UIX, pGrayBuf != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
                                , GetErrorMessage(E_OUT_OF_MEMORY));
 
-       r = pGrayBuf->Construct(resolution.width * resolution.height);
+       capacity = byteBuffer.GetCapacity();
+       r = pGrayBuf->Construct(capacity);
        SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
 
        switch (format)
@@ -546,8 +548,7 @@ _FaceDetectorImpl::ConvertToGrayN(const Tizen::Base::ByteBuffer& byteBuffer, con
                break;
 
        case PIXEL_FORMAT_YCbCr420_PLANAR:
-               memcpy((unsigned char*) (pGrayBuf->GetPointer()),
-                          (unsigned char*) byteBuffer.GetPointer(), sizeof(unsigned char) * resolution.width * resolution.height);
+               memcpy((unsigned char*)(pGrayBuf->GetPointer()), (unsigned char*)(byteBuffer.GetPointer()), capacity);
                break;
 
        default:
index f7e2923..3db2423 100644 (file)
@@ -373,7 +373,6 @@ _FaceRecognizerImpl::ExtractFaceFeaturesFromBufferN(const Tizen::Base::ByteBuffe
                                   , GetErrorMessage(E_FAILURE));
        }
 
-       //isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, "/usr/share/face-engine/data/");
        isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, _FACE_ENGINE_BIN_PATH);
 
        //SysTryCatch(NID_UIX, isValidFREngine == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
@@ -475,7 +474,6 @@ _FaceRecognizerImpl::ExtractFaceFeaturesFromBitmapN(const Tizen::Base::ByteBuffe
                                   , GetErrorMessage(E_FAILURE));
        }
 
-       //isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2,"/usr/share/face-engine/data/");
        isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, _FACE_ENGINE_BIN_PATH);
        //SysTryCatch(NID_UIX, isValidFREngine == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
 
@@ -576,7 +574,6 @@ _FaceRecognizerImpl::ExtractFaceFeaturesFromBitmapN(const Tizen::Graphics::Bitma
                                   , GetErrorMessage(E_FAILURE));
        }
 
-       //isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2,"/usr/share/face-engine/data/");
        isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, _FACE_ENGINE_BIN_PATH);
        //SysTryCatch(NID_UIX, isValidFREngine == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
 
@@ -1114,7 +1111,8 @@ CATCH:
 
 Tizen::Base::ByteBuffer*
 _FaceRecognizerImpl::ExtractFeatureN(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution,
-                                                                        const Tizen::Graphics::Rectangle& faceRect)
+                                                                        const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Point eyeLeft,
+                                                                       Tizen::Graphics::Point eyeRight)
 {
        ClearLastResult();
        result r = E_SUCCESS;
@@ -1139,9 +1137,11 @@ _FaceRecognizerImpl::ExtractFeatureN(const Tizen::Base::ByteBuffer& grayBuffer,
        __pFaceEngineInfoTemp->g_FaceROI[0].y = faceRect.y;
        __pFaceEngineInfoTemp->g_FaceROI[0].width = faceRect.width;
        __pFaceEngineInfoTemp->g_FaceROI[0].height = faceRect.height;
+       __pFaceEngineInfoTemp->g_EyeROI[0].lx = eyeLeft.x;
+       __pFaceEngineInfoTemp->g_EyeROI[0].ly = eyeLeft.y;
+       __pFaceEngineInfoTemp->g_EyeROI[0].rx = eyeRight.x;
+       __pFaceEngineInfoTemp->g_EyeROI[0].ry = eyeRight.y;
 
-       //caApp_RunFaceDetection((unsigned char*)grayBuffer, resolution.width, resolution.height, __pFaceEngineInfoTemp);
-       //isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2,"/usr/share/face-engine/data/");
        isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, _FACE_ENGINE_BIN_PATH);
        //SysTryCatch(NID_UIX, isValidFREngine == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
 
index d122826..efd20bd 100644 (file)
@@ -289,7 +289,8 @@ public:
         *                                                                      It can be happened when the detected faces are too small or the image is not clear. @n
         *                                                                      This is the result of a normal operation. @n
         */
-       Tizen::Base::ByteBuffer* ExtractFeatureN(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect);
+       Tizen::Base::ByteBuffer* ExtractFeatureN(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect,
+                                                                                               Tizen::Graphics::Point eyeLeft, Tizen::Graphics::Point eyeRight);
 
        /**
         *      Extracts the eye state.
index 006685e..cde82e0 100644 (file)
@@ -89,7 +89,6 @@ _FaceUtil::ConvertRgb565ToGray(const unsigned char& buf, unsigned char* pGrayBuf
 void
 _FaceUtil::ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height)
 {
-       SysAssert(pGrayBuf != null);
        if (pGrayBuf == null)
        {
                return;