src/FUixVisionFaceRecognitionInfo.cpp
src/FUixVisionFaceRecognizer.cpp
src/FUixVision_FaceRecognizerImpl.cpp
+ src/FUixVision_FaceUtil.cpp
)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" )
## Create Library
ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+## SET DEPENDENCY FLAGS
+ADD_DEPENDENCIES(${this_target} osp-appfw)
+ADD_DEPENDENCIES(${this_target} osp-uifw)
+ADD_DEPENDENCIES(${this_target} face-engine)
+
## SET LINKER FLAGS
SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-uix-face" )
+TARGET_LINK_LIBRARIES(${this_target} "-lface-engine-plugin" )
SET_TARGET_PROPERTIES(${this_target}
PROPERTIES
# pkgconfig file
CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig)
\ No newline at end of file
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig)
namespace Tizen { namespace Base { namespace Collection
{
class IList;
-template<class Type> class IListT;
+template< class Type > class IListT;
} } }
namespace Tizen { namespace Graphics
* @exception E_OUT_OF_MEMORY The memory is insufficient.
* @remarks The specific error code can be accessed using the GetLastResult() method.
*/
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* GetSupportedFormatListN(void) const;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* GetSupportedFormatListN(void) const;
/**
* Searches for faces from a video.
* @exception E_OUT_OF_MEMORY The memory is insufficient.
* @exception E_SYSTEM A system error has occurred.
* @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see FaceBuffer
+ * @see FaceBuffer
*/
FaceBuffer* PreprocessDataN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, Tizen::Graphics::PixelFormat format);
* @exception E_OUT_OF_MEMORY The memory is insufficient.
* @exception E_SYSTEM A system error has occurred.
* @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see FaceDetectorConfigProperty
+ * @see FaceDetectorConfigProperty
*/
Tizen::Base::Collection::IList* DetectFacesN(const FaceBuffer& preprocessedFaceBuffer, FaceDetectionOption option = FACE_DETECTION_OPTION_FAST);
* @exception E_OPERATION_FAILED The method has failed to extract the facial information, but there is no error reported. @n
* This happens when the detected faces are too small or the input data is not clear. This is the result of a normal operation.
* @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see FaceComponentsPosition
+ * @see FaceComponentsPosition
*/
FaceComponentsPosition* ExtractFaceComponentsN(const FaceBuffer& preprocessedFaceBuffer, const Tizen::Graphics::Rectangle& faceRect);
* This is the result of a normal operation.
* @remarks The specific error code can be accessed using the GetLastResult() method.
* @remarks This can be used for tracking the face from a sequential video data.
- * @see DetectFacesN()
+ * @see DetectFacesN()
*/
result GetFaceMovement(const FaceBuffer& prevData, const FaceBuffer& curData, const Tizen::Graphics::Rectangle& prevFaceRect, int& xDiff, int& yDiff);
#include <FBaseObject.h>
#include <FGrpRectangle.h>
-namespace Tizen { namespace Base{
+namespace Tizen { namespace Base
+{
class ByteBuffer;
} }
namespace Tizen { namespace Base { namespace Collection
{
class IList;
-template<class Type> class IListT;
-template<class KeyType, class ValueType> class IMapT;
+template< class Type > class IListT;
+template< class KeyType, class ValueType > class IMapT;
} } }
namespace Tizen { namespace Graphics
* @exception E_OUT_OF_MEMORY The memory is insufficient.
* @remarks The specific error code can be accessed using the GetLastResult() method.
*/
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* GetSupportedFormatListN(void) const;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* GetSupportedFormatListN(void) const;
/**
* Extracts the facial template that represents the face from a video.
* @remarks The specific error code can be accessed using the GetLastResult() method.
* @remarks If there are wrong values in the @c faceComponentPos, the result cannot be guaranteed even if it returns @c E_SUCCESS. Therefore, be sure not to change the value of @c faceComponentPos after getting it from ExtractFaceComponentsN().
* @see FaceDetector::PreprocessDataN()
- * @see FaceDetector::ExtractFaceComponentsN()
+ * @see FaceDetector::ExtractFaceComponentsN()
*/
Tizen::Base::ByteBuffer* ExtractFeatureN(const FaceBuffer& preprocessedFaceBuffer, const FaceComponentsPosition& faceComponentPos);
* @exception E_SYSTEM A system error has occurred.
* @remarks The specific error code can be accessed using the GetLastResult() method.
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>* DetectBlinksFromVideoStreamN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, const Tizen::Graphics::PixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >* DetectBlinksFromVideoStreamN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, const Tizen::Graphics::PixelFormat format);
/**
* @exception E_SYSTEM A system error has occurred.
* @remarks The specific error code can be accessed using the GetLastResult() method.
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>* DetectBlinksFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, Tizen::Graphics::BitmapPixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >* DetectBlinksFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, Tizen::Graphics::BitmapPixelFormat format);
/**
* Recognizes the facial expressions from a video.
* @exception E_SYSTEM A system error has occurred.
* @remarks The specific error code can be accessed using the GetLastResult() method.
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>* RecognizeExpressionsFromVideoStreamN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, const Tizen::Graphics::PixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >* RecognizeExpressionsFromVideoStreamN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, const Tizen::Graphics::PixelFormat format);
/**
* @exception E_SYSTEM A system error has occurred.
* @remarks The specific error code can be accessed using the GetLastResult() method.
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>* RecognizeExpressionsFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, Tizen::Graphics::BitmapPixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >* RecognizeExpressionsFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& dim, Tizen::Graphics::BitmapPixelFormat format);
private:
Name: osp-face
Summary: osp face library
-Version: 1.2.0.0
+Version: 1.2.1.0
Release: 2
Group: System/Libraries
License: TO_BE/FILLED_IN
Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
-BuildRequires: capi-uix-face-devel
+BuildRequires: pkgconfig(face-engine)
BuildRequires: pkgconfig(osp-appfw)
BuildRequires: osp-appfw-internal-devel
BuildRequires: pkgconfig(osp-uifw)
BuildRequires: osp-uifw-internal-devel
+Provides: libface-engine-plugin.so
+
# runtime requires
+Requires: face-engine
Requires: osp-appfw
+Requires: osp-uifw
%description
osp face library
%build
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
%ifarch %{ix86}
CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
%else
FaceComponentsPosition::SetEyePosition(const Tizen::Graphics::Point& eyeLeft, const Tizen::Graphics::Point& eyeRight)
{
SysTryReturn(NID_UIX, eyeLeft.x > 0 && eyeLeft.y > 0 && eyeRight.x > 0 && eyeRight.y > 0, E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The position of eyes should be greater or equal 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The position of eyes should be greater or equal 0.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_UIX, eyeRight.x > eyeLeft.x, E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The position of eyeRight should be greater than the position of eyeLeft.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The position of eyeRight should be greater than the position of eyeLeft.", GetErrorMessage(E_INVALID_ARG));
__eyeRight.x = eyeRight.x;
__eyeRight.y = eyeRight.y;
FaceComponentsPosition::SetMouthPosition(const Tizen::Graphics::Rectangle& mouthRect)
{
SysTryReturn(NID_UIX, mouthRect.x >= 0 && mouthRect.y >= 0, E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The x and y of the mouthRect should be greater or equal 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The x and y of the mouthRect should be greater or equal 0.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_UIX, mouthRect.width > 0 && mouthRect.height > 0, E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width and height of the mouthRect should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width and height of the mouthRect should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
__mouthRect.x = mouthRect.x;
__mouthRect.y = mouthRect.y;
FaceComponentsPosition::SetFacePosition(const Tizen::Graphics::Rectangle& faceRect)
{
SysTryReturn(NID_UIX, faceRect.x >= 0 && faceRect.y >= 0, E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The x and y of the faceRect should be greater or equal 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The x and y of the faceRect should be greater or equal 0.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_UIX, faceRect.width > 0 && faceRect.height > 0, E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width and height of the mouthRect should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width and height of the mouthRect should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
__faceRect.x = faceRect.x;
__faceRect.y = faceRect.y;
result r = E_SUCCESS;
- std::unique_ptr<_FaceDetectorImpl> pFaceDetectorImpl (new (std::nothrow) _FaceDetectorImpl());
+ std::unique_ptr< _FaceDetectorImpl > pFaceDetectorImpl(new (std::nothrow) _FaceDetectorImpl());
SysTryReturn(NID_UIX, pFaceDetectorImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pFaceDetectorImpl->Construct();
- SysTryReturn(NID_UIX, r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r));
+ SysTryReturn(NID_UIX, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
__pFaceDetectorImpl = pFaceDetectorImpl.release();
SysAssertf(__pFaceDetectorImpl != null, "Not yet constructed. Construct() should be called before use.");
SysTryReturn(NID_UIX, configProperty >= FACEDETECTOR_MAXNUMBER_VIDEO && configProperty <= FACEDETECTOR_SCALE_FACTOR,
- E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
- "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
+ "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
return __pFaceDetectorImpl->GetRange(configProperty, min, max, steppingDelta, defaultVal);
}
result r = E_SUCCESS;
SysTryCatch(NID_UIX, configProperty >= FACEDETECTOR_MAXNUMBER_VIDEO && configProperty <= FACEDETECTOR_SCALE_FACTOR,
- r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
- "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
+ "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
return __pFaceDetectorImpl->GetProperty(configProperty);
CATCH:
SetLastResult(r);
- return (long)-1;
+ return (long) -1;
}
result
SysAssertf(__pFaceDetectorImpl != null, "Not yet constructed. Construct() should be called before use.");
SysTryReturn(NID_UIX, configProperty >= FACEDETECTOR_MAXNUMBER_VIDEO && configProperty <= FACEDETECTOR_SCALE_FACTOR,
- E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
- "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
+ "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
return __pFaceDetectorImpl->SetProperty(configProperty, value);
}
-Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>*
+Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >*
FaceDetector::GetSupportedFormatListN(void) const
{
SysAssertf(__pFaceDetectorImpl != null, "Not yet constructed. Construct() should be called before use.");
result r = E_SUCCESS;
float bytePerPixel = 0.0f;
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* pList = null;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* pList = null;
- SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
- SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ SysTryCatch(NID_UIX, 0 <= resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ SysTryCatch(NID_UIX, 0 <= resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
pList = GetSupportedFormatListN();
}
SysTryCatch(NID_UIX,
- byteBuffer.GetLimit() == (int) (resolution.width * resolution.height * bytePerPixel), r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c byteBuffer does not have the size specified by the @c width, @c height, and @c format.", GetErrorMessage(E_INVALID_ARG));
+ byteBuffer.GetLimit() == (int) (resolution.width * resolution.height * bytePerPixel), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c byteBuffer does not have the size specified by the @c width, @c height, and @c format.", GetErrorMessage(E_INVALID_ARG));
return __pFaceDetectorImpl->DetectFacesFromBufferN(byteBuffer, resolution, format);
result r = E_SUCCESS;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, format > Tizen::Graphics::BITMAP_PIXEL_FORMAT_MIN && format < Tizen::Graphics::BITMAP_PIXEL_FORMAT_MAX, r =
- E_INVALID_ARG, E_INVALID_ARG, "[%s] Propagating.", GetErrorMessage(E_INVALID_ARG));
+ E_INVALID_ARG, E_INVALID_ARG, "[%s] Propagating.", GetErrorMessage(E_INVALID_ARG));
return __pFaceDetectorImpl->DetectFacesFromBitmapN(byteBuffer, resolution, format);
result r = E_SUCCESS;
float bytePerPixel = 0.0f;
- std::unique_ptr<FaceBuffer> pProcessedData;
+ std::unique_ptr< FaceBuffer > pProcessedData;
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* pFormatList = null;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* pFormatList = null;
Tizen::Base::ByteBuffer* pGrayBuf = null;
SysTryCatch(NID_UIX, 0 < dim.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < dim.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
pFormatList = GetSupportedFormatListN();
SysTryCatch(NID_UIX, pFormatList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
SysTryCatch(NID_UIX, pFormatList->Contains(
- format) == true, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format is invalid.", GetErrorMessage(E_INVALID_ARG));
+ format) == true, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format is invalid.", GetErrorMessage(E_INVALID_ARG));
pFormatList->RemoveAll();
}
SysTryCatch(NID_UIX,
- (int) (dim.width * dim.height * bytePerPixel) == byteBuffer.GetLimit(), r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c byteBuffer does not have the size specified by the @c width, @c height, and @c format.", GetErrorMessage(E_INVALID_ARG));
+ (int) (dim.width * dim.height * bytePerPixel) == byteBuffer.GetLimit(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c byteBuffer does not have the size specified by the @c width, @c height, and @c format.", GetErrorMessage(E_INVALID_ARG));
pGrayBuf = __pFaceDetectorImpl->ConvertToGrayN(byteBuffer, dim, format);
Tizen::Graphics::Point eyeLeft;
Tizen::Graphics::Rectangle mouthRect;
- std::unique_ptr<FaceComponentsPosition> pGeoInfo(new (std::nothrow) FaceComponentsPosition());
+ std::unique_ptr< FaceComponentsPosition > pGeoInfo(new (std::nothrow) FaceComponentsPosition());
SysTryReturn(NID_UIX, pGeoInfo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
resolution = preprocessedFaceBuffer.GetDimension();
SysTryReturn(NID_UIX,
- faceRect.x >= 0 && faceRect.y >= 0 && faceRect.width > 0 && faceRect.height > 0 &&
- faceRect.x + faceRect.width < resolution.width && faceRect.y + faceRect.height < resolution.height,
- null, E_INVALID_ARG,
- "[%s] The specified @c faceRect is not within the @c FaceComponentsPosition.", GetErrorMessage(E_INVALID_ARG));
+ faceRect.x >= 0 && faceRect.y >= 0 && faceRect.width > 0 && faceRect.height > 0 &&
+ faceRect.x + faceRect.width < resolution.width && faceRect.y + faceRect.height < resolution.height,
+ null, E_INVALID_ARG,
+ "[%s] The specified @c faceRect is not within the @c FaceComponentsPosition.", GetErrorMessage(E_INVALID_ARG));
r = pGeoInfo->SetFacePosition(faceRect);
SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
Tizen::Graphics::Point posDiff(0, 0);
resolution = prevData.GetDimension();
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - 001 Entering GetFaceMovement prevData.x = %d, prevData.y = %d", resolution.width, resolution.height);
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - 002 Entering GetFaceMovement curData.x = %d, curData.y = %d", curData.GetDimension().width, curData.GetDimension().height);
+
SysTryReturn(NID_UIX,
- resolution == curData.GetDimension(), E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The size of @c prevData and @c curData should be the same.", GetErrorMessage(E_INVALID_ARG));
+ resolution == curData.GetDimension(), E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The size of @c prevData and @c curData should be the same.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_UIX,
- prevFaceRect.x >= 0 && prevFaceRect.y >= 0 && prevFaceRect.width > 0 && prevFaceRect.height > 0 &&
- prevFaceRect.x + prevFaceRect.width < resolution.width && prevFaceRect.y + prevFaceRect.height < resolution.height,
- E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c prevFaceRect is not within the @c preprocessedData.", GetErrorMessage(E_INVALID_ARG));
+ prevFaceRect.x >= 0 && prevFaceRect.y >= 0 && prevFaceRect.width > 0 && prevFaceRect.height > 0 &&
+ prevFaceRect.x + prevFaceRect.width < resolution.width && prevFaceRect.y + prevFaceRect.height < resolution.height,
+ E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c prevFaceRect is not within the @c preprocessedData.", GetErrorMessage(E_INVALID_ARG));
r = __pFaceDetectorImpl->GetPosDifference(*(prevData.GetBuffer()), *(curData.GetBuffer()), resolution, prevFaceRect, posDiff);
SysTryReturn(NID_UIX, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
result r = E_SUCCESS;
- std::unique_ptr<_FaceRecognizerImpl> pFaceRecognizerImpl (new (std::nothrow) _FaceRecognizerImpl());
+ std::unique_ptr< _FaceRecognizerImpl > pFaceRecognizerImpl(new (std::nothrow) _FaceRecognizerImpl());
SysTryReturn(NID_UIX, pFaceRecognizerImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pFaceRecognizerImpl->Construct();
- SysTryReturn(NID_UIX, r == E_SUCCESS, r, r,"[%s] Construct failed",GetErrorMessage(r));
+ SysTryReturn(NID_UIX, r == E_SUCCESS, r, r, "[%s] Construct failed", GetErrorMessage(r));
__pFaceRecognizerImpl = pFaceRecognizerImpl.release();
result r = E_SUCCESS;
SysTryCatch(NID_UIX, configProperty >= FACERECOGNIZER_MAXNUMBER_VIDEO && configProperty <= FACERECOGNIZER_SCALE_IMAGE,
- r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
- "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
+ "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
return __pFaceRecognizerImpl->GetProperty(configProperty);
CATCH:
SetLastResult(r);
- return (long)-1;
+ return (long) -1;
}
result
return __pFaceRecognizerImpl->SetProperty(configProperty, value);
}
-Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>*
+Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >*
FaceRecognizer::GetSupportedFormatListN(void) const
{
SysAssertf(__pFaceRecognizerImpl != null, "Not yet constructed. Construct() should be called before use.");
result r = E_SUCCESS;
float bytePerPixel = 0.0f;
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* pList = null;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* pList = null;
pList = GetSupportedFormatListN();
SysTryCatch(NID_UIX, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
SysTryCatch(NID_UIX, (pList->Contains(format) == true), r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format is invalid."
- , GetErrorMessage(E_INVALID_ARG));
+ , GetErrorMessage(E_INVALID_ARG));
pList->RemoveAll();
delete pList;
pList = null;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
// Below check routine includes the Pixelformat. Therefore it is checked after verifying format is valid.
if (format == Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR)
bytePerPixel = 2.0f;
}
SysTryCatch(NID_UIX,
- !(Float::Compare((float)byteBuffer.GetLimit(), (float)(resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
- E_INVALID_ARG,
- "[%s] The specified @c byteBuffer does not have the size specified by the @c width, @c height, and @c format.",
- GetErrorMessage(E_INVALID_ARG));
+ !(Float::Compare((float) byteBuffer.GetLimit(), (float) (resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
+ E_INVALID_ARG,
+ "[%s] The specified @c byteBuffer does not have the size specified by the @c width, @c height, and @c format.",
+ GetErrorMessage(E_INVALID_ARG));
return __pFaceRecognizerImpl->ExtractFaceFeaturesFromBufferN(byteBuffer, resolution, format);
Tizen::Base::Collection::IList*
FaceRecognizer::ExtractFaceInfoFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- Tizen::Graphics::BitmapPixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ Tizen::Graphics::BitmapPixelFormat format)
{
SysAssertf(__pFaceRecognizerImpl != null, "Not yet constructed. Construct() should be called before use.");
result r = E_SUCCESS;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, format > Tizen::Graphics::BITMAP_PIXEL_FORMAT_MIN && format < Tizen::Graphics::BITMAP_PIXEL_FORMAT_MAX, r =
- E_INVALID_ARG, E_INVALID_ARG, "[%s] Propagating.", GetErrorMessage(E_INVALID_ARG));
+ E_INVALID_ARG, E_INVALID_ARG, "[%s] Propagating.", GetErrorMessage(E_INVALID_ARG));
return __pFaceRecognizerImpl->ExtractFaceFeaturesFromBitmapN(byteBuffer, resolution, format);
CATCH:
faceFeatures1 = face1.GetFaceFeatures();
SysTryCatch(NID_UIX, faceFeatures1 != null, r = E_INVALID_ARG, E_INVALID_ARG,
- ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
+ ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
faceFeatures2 = face2.GetFaceFeatures();
SysTryCatch(NID_UIX, faceFeatures2 != null, r = E_INVALID_ARG, E_INVALID_ARG,
- ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
+ ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
return __pFaceRecognizerImpl->IsMatching(*(faceFeatures1), *(faceFeatures2));
faceFeatures1 = face1.GetFaceFeatures();
SysTryCatch(NID_UIX, faceFeatures1 != null, r = E_INVALID_ARG, E_INVALID_ARG,
- ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
+ ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
faceFeatures2 = face2.GetFaceFeatures();
SysTryCatch(NID_UIX, faceFeatures2 != null, r = E_INVALID_ARG, E_INVALID_ARG,
- ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
+ ("[%s] A specified FaceRecognitionInfo is not constructed yet.", GetErrorMessage(E_INVALID_ARG)));
return __pFaceRecognizerImpl->MeasureSimilarity(*(faceFeatures1), *(faceFeatures2));
faceComponentPos.GetEyePosition(eyeLeft, eyeRight);
faceRect = faceComponentPos.GetFacePosition();
SysTryCatch(NID_UIX,
- eyeLeft.x >= 0 && eyeLeft.y >= 0 && eyeRight.x >= 0 && eyeRight.y >= 0 &&
- eyeRight.x <= resolution.width && eyeRight.y <= resolution.height && eyeLeft.y <= resolution.height,
- r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c eyes's positions in the faceComponentPos should be withiin the @c preprocessedFaceBuffer.",
- GetErrorMessage(E_INVALID_ARG));
+ eyeLeft.x >= 0 && eyeLeft.y >= 0 && eyeRight.x >= 0 && eyeRight.y >= 0 &&
+ eyeRight.x <= resolution.width && eyeRight.y <= resolution.height && eyeLeft.y <= resolution.height,
+ r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c eyes's positions in the faceComponentPos should be withiin the @c preprocessedFaceBuffer.",
+ GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, eyeLeft.x < eyeRight.x,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED,
- "[%s] The value of the x position for the right eye should be greater than left one.", GetErrorMessage(E_OPERATION_FAILED));
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED,
+ "[%s] The value of the x position for the right eye should be greater than left one.", GetErrorMessage(E_OPERATION_FAILED));
if (eyeLeft.y != eyeRight.y)
{
SysTryCatch(NID_UIX,
- ((eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x)) + ((eyeRight.y - eyeLeft.y) * (eyeRight.y - eyeLeft.y)) >
- EYE_DISTANCE_SQUARE,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to extract the facial information.", GetErrorMessage(E_OPERATION_FAILED));
+ ((eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x)) + ((eyeRight.y - eyeLeft.y) * (eyeRight.y - eyeLeft.y)) >
+ EYE_DISTANCE_SQUARE,
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to extract the facial information.", GetErrorMessage(E_OPERATION_FAILED));
}
else
{
SysTryCatch(NID_UIX, (eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x) > EYE_DISTANCE_SQUARE,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to extract the facial information.", GetErrorMessage(E_OPERATION_FAILED));
+ 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);
faceComponentPos.GetEyePosition(eyeLeft, eyeRight);
faceRect = faceComponentPos.GetFacePosition();
SysTryCatch(NID_UIX,
- eyeLeft.x >= 0 && eyeLeft.y >= 0 && eyeRight.x >= 0 && eyeRight.y >= 0 &&
- eyeRight.x <= resolution.width && eyeRight.y <= resolution.height && eyeLeft.y <= resolution.height,
- r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c eyes's positions in the faceComponentPos should be withiin the @c preprocessedFaceBuffer.", GetErrorMessage(E_INVALID_ARG));
+ eyeLeft.x >= 0 && eyeLeft.y >= 0 && eyeRight.x >= 0 && eyeRight.y >= 0 &&
+ eyeRight.x <= resolution.width && eyeRight.y <= resolution.height && eyeLeft.y <= resolution.height,
+ r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c eyes's positions in the faceComponentPos should be withiin the @c preprocessedFaceBuffer.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, eyeLeft.x < eyeRight.x,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED,
- "[%s] The value of the x position for the right eye should be greater than left one.", GetErrorMessage(E_OPERATION_FAILED));
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED,
+ "[%s] The value of the x position for the right eye should be greater than left one.", GetErrorMessage(E_OPERATION_FAILED));
if (eyeLeft.y != eyeRight.y)
{
SysTryCatch(NID_UIX,
- ((eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x)) + ((eyeRight.y - eyeLeft.y) * (eyeRight.y - eyeLeft.y)) >
- EYE_DISTANCE_SQUARE,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to detect the eye state.", GetErrorMessage(E_OPERATION_FAILED));
+ ((eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x)) + ((eyeRight.y - eyeLeft.y) * (eyeRight.y - eyeLeft.y)) >
+ EYE_DISTANCE_SQUARE,
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to detect the eye state.", GetErrorMessage(E_OPERATION_FAILED));
}
else
{
SysTryCatch(NID_UIX, (eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x) > EYE_DISTANCE_SQUARE,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to detect the eye state.", GetErrorMessage(E_OPERATION_FAILED));
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to detect the eye state.", GetErrorMessage(E_OPERATION_FAILED));
}
- return __pFaceRecognizerImpl->DetectEyeState(*(preprocessedFaceBuffer.GetBuffer()), resolution, faceRect);
+ return __pFaceRecognizerImpl->DetectEyeState(*(preprocessedFaceBuffer.GetBuffer()), resolution, faceRect, eyeLeft, eyeRight);
CATCH:
SetLastResult(r);
Tizen::Graphics::Rectangle faceRect;
Tizen::Graphics::Point eyeRight;
Tizen::Graphics::Point eyeLeft;
+ Tizen::Graphics::Rectangle mouthRect;
resolution = preprocessedFaceBuffer.GetDimension();
faceComponentPos.GetEyePosition(eyeLeft, eyeRight);
faceRect = faceComponentPos.GetFacePosition();
+ mouthRect = faceComponentPos.GetMouthPosition();
SysTryCatch(NID_UIX,
- eyeLeft.x >= 0 && eyeLeft.y >= 0 && eyeRight.x >= 0 && eyeRight.y >= 0 &&
- eyeRight.x <= resolution.width && eyeRight.y <= resolution.height && eyeLeft.y <= resolution.height,
- r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c eyes's positions in the faceComponentPos should be withiin the @c preprocessedFaceBuffer.", GetErrorMessage(E_INVALID_ARG));
+ eyeLeft.x >= 0 && eyeLeft.y >= 0 && eyeRight.x >= 0 && eyeRight.y >= 0 &&
+ eyeRight.x <= resolution.width && eyeRight.y <= resolution.height && eyeLeft.y <= resolution.height,
+ r = E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c eyes's positions in the faceComponentPos should be withiin the @c preprocessedFaceBuffer.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, eyeLeft.x < eyeRight.x,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED,
- "[%s] The value of the x position for the right eye should be greater than left one.", GetErrorMessage(E_OPERATION_FAILED));
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED,
+ "[%s] The value of the x position for the right eye should be greater than left one.", GetErrorMessage(E_OPERATION_FAILED));
if (eyeLeft.y != eyeRight.y)
{
SysTryCatch(NID_UIX,
- ((eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x)) + ((eyeRight.y - eyeLeft.y) * (eyeRight.y - eyeLeft.y)) >
- EYE_DISTANCE_SQUARE,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to recognize the facial expression.", GetErrorMessage(E_OPERATION_FAILED));
+ ((eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x)) + ((eyeRight.y - eyeLeft.y) * (eyeRight.y - eyeLeft.y)) >
+ EYE_DISTANCE_SQUARE,
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to recognize the facial expression.", GetErrorMessage(E_OPERATION_FAILED));
}
else
{
SysTryCatch(NID_UIX, (eyeRight.x - eyeLeft.x) * (eyeRight.x - eyeLeft.x) > EYE_DISTANCE_SQUARE,
- r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to recognize the facial expression.", GetErrorMessage(E_OPERATION_FAILED));
+ r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Fail to recognize the facial expression.", GetErrorMessage(E_OPERATION_FAILED));
}
- return __pFaceRecognizerImpl->RecognizeExpression(*(preprocessedFaceBuffer.GetBuffer()), resolution, faceRect);
+ return __pFaceRecognizerImpl->RecognizeExpression(*(preprocessedFaceBuffer.GetBuffer()), resolution, faceRect, mouthRect);
CATCH:
SetLastResult(r);
return FACIAL_EXPRESSION_NONE;
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >*
FaceRecognizer::DetectBlinksFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution,
Tizen::Graphics::BitmapPixelFormat format)
{
float bytePerPixel = 0.0f;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
- SysTryCatch(NID_UIX, Tizen::Graphics::BITMAP_PIXEL_FORMAT_MIN < format && Tizen::Graphics::BITMAP_PIXEL_FORMAT_MAX > format,
- r = E_INVALID_ARG, E_INVALID_ARG, "[%s] The specified @c format is not supported.", GetErrorMessage(E_INVALID_ARG));
+ SysTryCatch(NID_UIX, Tizen::Graphics::BITMAP_PIXEL_FORMAT_MIN< format&& Tizen::Graphics::BITMAP_PIXEL_FORMAT_MAX > format,
+ r = E_INVALID_ARG, E_INVALID_ARG, "[%s] The specified @c format is not supported.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, (format == Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888) || (format == Tizen::Graphics::BITMAP_PIXEL_FORMAT_RGB565),
- r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format(%d) is invalid.", GetErrorMessage(E_INVALID_ARG), format);
+ r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format(%d) is invalid.", GetErrorMessage(E_INVALID_ARG), format);
if (format == Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888)
{
}
SysTryCatch(NID_UIX,
- !(Float::Compare((float)byteBuffer.GetLimit(), (float)(resolution.width * resolution.height * bytePerPixel))),
- r = E_INVALID_ARG, E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by"
- "the @c width(%d), @c height(%d), and @c format(%d).",
+ !(Float::Compare((float) byteBuffer.GetLimit(), (float) (resolution.width * resolution.height * bytePerPixel))),
+ r = E_INVALID_ARG, E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by"
+ "the @c width(%d), @c height(%d), and @c format(%d).",
GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
return __pFaceRecognizerImpl->DetectBlinksFromBitmapN(byteBuffer, resolution, format);
return null;
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >*
FaceRecognizer::DetectBlinksFromVideoStreamN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution,
Tizen::Graphics::PixelFormat format)
{
ClearLastResult();
result r = E_SUCCESS;
float bytePerPixel = 0.0f;
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* pList = null;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* pList = null;
pList = GetSupportedFormatListN();
SysTryCatch(NID_UIX, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
SysTryCatch(NID_UIX, (pList->Contains(format) == true), r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format is invalid."
- , GetErrorMessage(E_INVALID_ARG));
+ , GetErrorMessage(E_INVALID_ARG));
pList->RemoveAll();
delete pList;
pList = null;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
// Below check routine includes the Pixelformat. Therefore it is checked after verifying format is valid.
if (format == Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR)
}
SysTryCatch(NID_UIX,
- !(Float::Compare((float)byteBuffer.GetLimit(), (float)(resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
- E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by the @c width(%d), @c height(%d), and"
- "@c format(%d).", GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
+ !(Float::Compare((float) byteBuffer.GetLimit(), (float) (resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
+ E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by the @c width(%d), @c height(%d), and"
+ "@c format(%d).", GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
return __pFaceRecognizerImpl->DetectBlinksFromBufferN(byteBuffer, resolution, format);
CATCH:
return null;
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >*
FaceRecognizer::RecognizeExpressionsFromStillImageN(const Tizen::Base::ByteBuffer& byteBuffer,
const Tizen::Graphics::Dimension& resolution,
Tizen::Graphics::BitmapPixelFormat format)
float bytePerPixel = 0.0f;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
- SysTryCatch(NID_UIX, Tizen::Graphics::BITMAP_PIXEL_FORMAT_MIN < format && Tizen::Graphics::BITMAP_PIXEL_FORMAT_MAX > format, r =
- E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The specified @c format is not supported.", GetErrorMessage(E_INVALID_ARG));
+ SysTryCatch(NID_UIX, Tizen::Graphics::BITMAP_PIXEL_FORMAT_MIN< format&& Tizen::Graphics::BITMAP_PIXEL_FORMAT_MAX > format, r =
+ E_INVALID_ARG, E_INVALID_ARG,
+ "[%s] The specified @c format is not supported.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, (format == Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888) || (format == Tizen::Graphics::BITMAP_PIXEL_FORMAT_RGB565),
- r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format(%d) is invalid.", GetErrorMessage(E_INVALID_ARG), format);
+ r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format(%d) is invalid.", GetErrorMessage(E_INVALID_ARG), format);
if (format == Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888)
{
}
SysTryCatch(NID_UIX,
- !(Float::Compare((float)byteBuffer.GetLimit(), (float)(resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
- E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by the @c width(%d), @c height(%d), and"
- "@c format(%d).", GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
+ !(Float::Compare((float) byteBuffer.GetLimit(), (float) (resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
+ E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by the @c width(%d), @c height(%d), and"
+ "@c format(%d).", GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
return __pFaceRecognizerImpl->RecognizeExpressionsFromBitmapN(byteBuffer, resolution, format);
CATCH:
return null;
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >*
FaceRecognizer::RecognizeExpressionsFromVideoStreamN(const Tizen::Base::ByteBuffer& byteBuffer,
const Tizen::Graphics::Dimension& resolution,
Tizen::Graphics::PixelFormat format)
ClearLastResult();
result r = E_SUCCESS;
float bytePerPixel = 0.0f;
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* pList = null;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* pList = null;
pList = GetSupportedFormatListN();
SysTryCatch(NID_UIX, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
SysTryCatch(NID_UIX, (pList->Contains(format) == true), r = E_INVALID_ARG, E_INVALID_ARG, "[%s] A specified format is invalid.",
- GetErrorMessage(E_INVALID_ARG));
+ GetErrorMessage(E_INVALID_ARG));
pList->RemoveAll();
delete pList;
pList = null;
SysTryCatch(NID_UIX, 0 < resolution.width, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The width of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
SysTryCatch(NID_UIX, 0 < resolution.height, r = E_INVALID_ARG, E_INVALID_ARG,
- "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
+ "[%s] The height of the resolution should be greater than 0.", GetErrorMessage(E_INVALID_ARG));
// Below check routine includes the Pixelformat. Therefore it is checked after verifying format is valid.
if (format == Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR)
}
SysTryCatch(NID_UIX,
- !(Float::Compare((float)byteBuffer.GetLimit(), (float)(resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
- E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by the @c width(%d), @c height(%d), and"
- " @c format(%d).", GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
+ !(Float::Compare((float) byteBuffer.GetLimit(), (float) (resolution.width * resolution.height * bytePerPixel))), r = E_INVALID_ARG,
+ E_INVALID_ARG, "[%s] The specified @c byteBuffer(%d) does not have the size specified by the @c width(%d), @c height(%d), and"
+ " @c format(%d).", GetErrorMessage(E_INVALID_ARG), byteBuffer.GetLimit(), resolution.width, resolution.height, bytePerPixel);
return __pFaceRecognizerImpl->RecognizeExpressionsFromBufferN(byteBuffer, resolution, format);
CATCH:
static const int _MAX_FD_SCALE_IMAGE = 3;
static const int _MIN_FD_SCALE_VIDEO = 1;
static const int _MIN_FD_SCALE_IMAGE = 1;
-static const int _FT_INTERVAL_DEFAULT = 100;
+static const int _FT_INTERVAL_DEFAULT = 20;
+static const int _FACEENGINE_INIT_SUCCESS = 1;
+static const int _FACEENGINE_RETURN_SUCCESS = 1;
+
_FaceDetectorImpl::_FaceDetectorImpl(void)
: __maxFacesVideo(0)
, __scaleVideo(0)
, __maxFacesImage(0)
, __scaleImage(0)
- , __faceHandleVideoMode(null)
, __isTrackingMode(false)
+ , __pFaceEngineInfo(null)
+ , __pFaceUtil(null)
+ , __prevDetectMode(__FACEDETECT_MODE_UNINITIALIZED)
{
}
_FaceDetectorImpl::~_FaceDetectorImpl(void)
{
- face_destroy(__faceHandleVideoMode);
+ //Tracking mode does not release the resources
+ ReleaseFaceEngine();
+
+ delete __pFaceEngineInfo;
+ delete __pFaceUtil;
+}
+
+bool
+_FaceDetectorImpl::ToBeInitialized(FaceDetectMode currMode)
+{
+ if (__prevDetectMode == currMode)
+ {
+ return false;
+ }
+
+ ReleaseFaceEngine();
+
+ __prevDetectMode = currMode;
+
+ return true;
+}
+
+bool
+_FaceDetectorImpl::ReleaseFaceEngine()
+{
+ if (__prevDetectMode != __FACEDETECT_MODE_UNINITIALIZED)
+ {
+ int retValue = caApp_FaceEngineRelease(__pFaceEngineInfo);
+ SysTryReturn(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, false, E_FAILURE,
+ "[%s] Failed to release face engine", GetErrorMessage(E_FAILURE));
+ }
+ __prevDetectMode = __FACEDETECT_MODE_UNINITIALIZED;
+
+ return true;
}
result
long min = 0;
long max = 0;
long steppingDelta = 0;
- int engineError = 0;
-
- engineError = face_create(&__faceHandleVideoMode);
- SysTryReturn(NID_UIX, engineError == FACE_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
GetRange(FACEDETECTOR_MAXNUMBER_VIDEO, min, max, steppingDelta, __maxFacesVideo);
GetRange(FACEDETECTOR_MAXNUMBER_IMAGE, min, max, steppingDelta, __maxFacesImage);
GetRange(FACEDETECTOR_SCALE_IMAGE, min, max, steppingDelta, __scaleImage);
GetRange(FACEDETECTOR_MAXNUMBER_FACES, min, max, steppingDelta, __maxFacesAtomic);
GetRange(FACEDETECTOR_SCALE_FACTOR, min, max, steppingDelta, __scaleAtomic);
+
+ std::unique_ptr< FaceEngineInfo > pFaceEngineInfo(new (std::nothrow) FaceEngineInfo);
+ SysTryReturn(NID_UIX, pFaceEngineInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pFaceEngineInfo = pFaceEngineInfo.release();
+
+ std::unique_ptr< _FaceUtil > pFaceUtil(new (std::nothrow) _FaceUtil);
+ SysTryReturn(NID_UIX, pFaceUtil != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pFaceUtil = pFaceUtil.release();
+
return r;
}
switch (configProperty)
{
case FACEDETECTOR_MAXNUMBER_VIDEO:
- {
- min = _MIN_FD_VIDEO_MAXNUM;
- max = _MAX_FD_VIDEO_MAXNUM;
- steppingDelta = 1;
- defaultVal = _MAX_FD_VIDEO_DEFAULT;
- }
- break;
+ {
+ min = _MIN_FD_VIDEO_MAXNUM;
+ max = _MAX_FD_VIDEO_MAXNUM;
+ steppingDelta = 1;
+ defaultVal = _MAX_FD_VIDEO_DEFAULT;
+ }
+ break;
case FACEDETECTOR_MAXNUMBER_IMAGE:
- {
- min = _MIN_FD_IMAGE_MAXNUM;
- max = _MAX_FD_IMAGE_MAXNUM;
- steppingDelta = 1;
- defaultVal = _MAX_FD_IMAGE_DEFAULT;
- }
- break;
+ {
+ min = _MIN_FD_IMAGE_MAXNUM;
+ max = _MAX_FD_IMAGE_MAXNUM;
+ steppingDelta = 1;
+ defaultVal = _MAX_FD_IMAGE_DEFAULT;
+ }
+ break;
case FACEDETECTOR_SCALE_VIDEO:
- {
- min = _MIN_FD_SCALE_VIDEO;
- max = _MAX_FD_SCALE_VIDEO;
- defaultVal = _FD_SCALE_VIDEO_DEFAULT;
- steppingDelta = 1;
- }
- break;
+ {
+ min = _MIN_FD_SCALE_VIDEO;
+ max = _MAX_FD_SCALE_VIDEO;
+ defaultVal = _FD_SCALE_VIDEO_DEFAULT;
+ steppingDelta = 1;
+ }
+ break;
case FACEDETECTOR_SCALE_IMAGE:
- {
- min = _MIN_FD_SCALE_IMAGE;
- max = _MAX_FD_SCALE_IMAGE;
- defaultVal = _FD_SCALE_IMAGE_DEFAULT;
- steppingDelta = 1;
- }
- break;
+ {
+ min = _MIN_FD_SCALE_IMAGE;
+ max = _MAX_FD_SCALE_IMAGE;
+ defaultVal = _FD_SCALE_IMAGE_DEFAULT;
+ steppingDelta = 1;
+ }
+ break;
case FACEDETECTOR_MAXNUMBER_FACES:
- {
- min = _MIN_FD_IMAGE_MAXNUM;
- max = _MAX_FD_IMAGE_MAXNUM;
- steppingDelta = 1;
- defaultVal = _MAX_FD_IMAGE_DEFAULT;
- }
- break;
+ {
+ min = _MIN_FD_IMAGE_MAXNUM;
+ max = _MAX_FD_IMAGE_MAXNUM;
+ steppingDelta = 1;
+ defaultVal = _MAX_FD_IMAGE_DEFAULT;
+ }
+ break;
case FACEDETECTOR_SCALE_FACTOR:
- {
- min = _MIN_FD_SCALE_IMAGE;
- max = _MAX_FD_SCALE_IMAGE;
- steppingDelta = 1;
- defaultVal = _FD_SCALE_IMAGE_DEFAULT;
- }
- break;
+ {
+ min = _MIN_FD_SCALE_IMAGE;
+ max = _MAX_FD_SCALE_IMAGE;
+ steppingDelta = 1;
+ defaultVal = _FD_SCALE_IMAGE_DEFAULT;
+ }
+ break;
default:
- {
- min = 0;
- max = 0;
- steppingDelta = 1;
- defaultVal = 0;
- SysTryReturn(NID_UIX, false, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
- GetErrorMessage(E_UNSUPPORTED_OPERATION));
- break;
- }
+ {
+ min = 0;
+ max = 0;
+ steppingDelta = 1;
+ defaultVal = 0;
+ SysTryReturn(NID_UIX, false, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
+ GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ break;
+ }
}
return res;
SysTryReturn(NID_UIX, false, -1, -1, "[%s] The device does not support this property.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
break;
}
- return (long)-1;
+ return (long) -1;
}
result
GetRange(configProperty, min, max, steppingDelta, defaultVal);
SysTryReturn(NID_UIX, value >= min && value <= max && value % steppingDelta == 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[%s] The specified value (%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), value);
+ "[%s] The specified value (%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), value);
switch (configProperty)
{
default:
SysTryReturn(NID_UIX, false, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
- GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ GetErrorMessage(E_UNSUPPORTED_OPERATION));
break;
}
return E_SUCCESS;
}
-Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>*
+Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >*
_FaceDetectorImpl::GetSupportedFormatListN(void) const
{
- std::unique_ptr<Tizen::Base::Collection::LinkedListT <Tizen::Graphics::PixelFormat>, CollectionAllElementDelete>
- pFormatList (new (std::nothrow) Tizen::Base::Collection::LinkedListT <Tizen::Graphics::PixelFormat>);
+ std::unique_ptr< Tizen::Base::Collection::LinkedListT< Tizen::Graphics::PixelFormat >, CollectionAllElementDelete >
+ pFormatList(new (std::nothrow) Tizen::Base::Collection::LinkedListT< Tizen::Graphics::PixelFormat >);
SysTryReturn(NID_UIX, pFormatList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
pFormatList->InsertAt(Tizen::Graphics::PIXEL_FORMAT_RGB565, 0);
const Tizen::Graphics::PixelFormat format)
{
result r = E_SUCCESS;
-
- int engineErr = 0;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
+ int retValue = 0;
unsigned char* pImageBuffer = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
ClearLastResult();
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
- SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory", GetErrorMessage(E_OUT_OF_MEMORY));
+
r = pDetectList->Construct();
SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
if (format == PIXEL_FORMAT_YCbCr420_PLANAR)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
+ pImageBuffer = (unsigned char*) byteBuffer.GetPointer();
}
else if (format == PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- pImageBuffer = (unsigned char*)byteBuffer.GetPointer();
- if (__isTrackingMode == true)
+ if (ToBeInitialized(__FACEDETECT_MODE_VIDEO))
{
- engineErr = face_destroy(__faceHandleVideoMode);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to destroy the handle.",
- GetErrorMessage(E_OPERATION_FAILED));
- engineErr = face_create(&__faceHandleVideoMode);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to create the handle.",
- GetErrorMessage(E_OPERATION_FAILED));
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesVideo, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, r = E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
}
- engineErr = face_attr_set_max_number_faces(__faceHandleVideoMode, __maxFacesVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(__faceHandleVideoMode, __scaleVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- faceCount = GetFaceRectsN(__faceHandleVideoMode, pImageBuffer, resolution.width, resolution.height, FACE_IMAGE_TYPE_CONTINUOUS,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
- __isTrackingMode = false;
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, r = E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- if (faceCount > 0)
+ if (__pFaceEngineInfo->g_iFaceDetectNum > 0)
{
- for (int i = 0; i < faceCount; i++)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
Tizen::Graphics::Rectangle* pRect =
- new (std::nothrow) Tizen::Graphics::Rectangle(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
- SysTryCatch(NID_UIX, pRect != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ new (std::nothrow) Tizen::Graphics::Rectangle(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
+
+ SysTryCatch(NID_UIX, pRect != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
r = pDetectList->Add(*pRect);
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
}
}
- free(pFaceRects);
-
return pDetectList.release();
CATCH:
- free(pFaceRects);
-
SetLastResult(r);
- return null;
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
Tizen::Base::Collection::IList*
{
result r = E_SUCCESS;
BufferInfo bitmapInfo;
-
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
unsigned char* pImageBuffer = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
+ int retValue = 0;
ClearLastResult();
- r = const_cast <Tizen::Graphics::Bitmap*>(&bitmap)->Lock(bitmapInfo);
+ r = const_cast< Tizen::Graphics::Bitmap* >(&bitmap)->Lock(bitmapInfo);
SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
- std::unique_ptr<unsigned char> pBuffer(new (std::nothrow) unsigned char[bitmapInfo.width * bitmapInfo.height]);
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[bitmapInfo.width * bitmapInfo.height]);
SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
SysTryCatch(NID_UIX, pDetectList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct();
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
if (bitmapInfo.pixelFormat == PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
- pImageBuffer = (unsigned char*)bitmapInfo.pPixels;
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) bitmapInfo.pPixels), pImageBuffer, bitmapInfo.width, bitmapInfo.height);
}
else if (bitmapInfo.pixelFormat == PIXEL_FORMAT_ARGB8888)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- pImageBuffer = pBuffer.get();
- SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
- , GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertArgb8888ToGray(*((unsigned char*)bitmapInfo.pPixels), pImageBuffer, bitmapInfo.width, bitmapInfo.height);
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) bitmapInfo.pPixels), pImageBuffer, bitmapInfo.width, bitmapInfo.height);
}
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- faceCount = GetFaceRectsN(faceHandle, pImageBuffer, bitmapInfo.width, bitmapInfo.height, FACE_IMAGE_TYPE_SINGLE,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ if (ToBeInitialized(__FACEDETECT_MODE_IMAGE))
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- __isTrackingMode = false;
+ retValue = caApp_RunFaceDetection(pImageBuffer, bitmapInfo.width, bitmapInfo.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- if (faceCount > 0)
+ if (__pFaceEngineInfo->g_iFaceDetectNum > 0)
{
- for (int i = 0; i < faceCount; i++)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- ConvertVirtualToPhysicalCoordinates(bitmap.GetWidth(), bitmap.GetHeight(), bitmapInfo.width, bitmapInfo.height, &pFaceRects[i]);
Tizen::Graphics::Rectangle* pRect =
- new (std::nothrow) Tizen::Graphics::Rectangle(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+ new (std::nothrow) Tizen::Graphics::Rectangle(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
+
SysTryCatch(NID_UIX, pRect != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pFaceUtil->ConvertVirtualToPhysicalCoordinates(bitmap.GetWidth(), bitmap.GetHeight(), bitmapInfo.width, bitmapInfo.height, pRect);
+
r = pDetectList->Add(*pRect);
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
}
}
- r = const_cast <Tizen::Graphics::Bitmap*>(&bitmap)->Unlock();
+
+ r = const_cast< Tizen::Graphics::Bitmap* >(&bitmap)->Unlock();
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
- free(pFaceRects);
- face_destroy(faceHandle);
+ ReleaseFaceEngine();
return pDetectList.release();
CATCH:
- free(pFaceRects);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, r, "XXXX - CATCH: _FaceDetectorImpl::DetectFacesFromBitmapN");
+ ReleaseFaceEngine();
SetLastResult(r);
- return null;
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
Tizen::Base::Collection::IList*
_FaceDetectorImpl::DetectFacesFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution,
Tizen::Graphics::BitmapPixelFormat format)
{
- result r = E_SUCCESS;
-
ClearLastResult();
-
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
+ result r = E_SUCCESS;
+ int retValue = 0;
unsigned char* pImageBuffer = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- std::unique_ptr<unsigned char> pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
SysTryCatch(NID_UIX, pDetectList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct();
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
if (format == BITMAP_PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
- pImageBuffer = (unsigned char*)byteBuffer.GetPointer();
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
else if (format == BITMAP_PIXEL_FORMAT_ARGB8888)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- pImageBuffer = pBuffer.get();
- SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
- , GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertArgb8888ToGray(*((unsigned char*)byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
+ if (ToBeInitialized(__FACEDETECT_MODE_IMAGE))
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- faceCount = GetFaceRectsN(faceHandle, pImageBuffer, resolution.width, resolution.height, FACE_IMAGE_TYPE_SINGLE,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
- __isTrackingMode = false;
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- if (faceCount > 0)
+ if (__pFaceEngineInfo->g_iFaceDetectNum > 0)
{
- for (int i = 0; i < faceCount; i++)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
Tizen::Graphics::Rectangle* pRect =
- new (std::nothrow) Tizen::Graphics::Rectangle(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
- SysTryCatch(NID_UIX, pRect != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ new (std::nothrow) Tizen::Graphics::Rectangle(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
+
+ SysTryCatch(NID_UIX, pRect != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
r = pDetectList->Add(*pRect);
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
}
}
- free(pFaceRects);
- face_destroy(faceHandle);
+ ReleaseFaceEngine();
return pDetectList.release();
CATCH:
- free(pFaceRects);
- face_destroy(faceHandle);
-
SetLastResult(r);
- return null;
+ ReleaseFaceEngine();
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
Tizen::Base::ByteBuffer*
Tizen::Graphics::PixelFormat format)
{
result r = E_SUCCESS;
-
ClearLastResult();
- std::unique_ptr<Tizen::Base::ByteBuffer> pGrayBuf( new (std::nothrow) Tizen::Base::ByteBuffer());
+ 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));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
r = pGrayBuf->Construct(resolution.width * resolution.height);
SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
switch (format)
{
case PIXEL_FORMAT_RGB565:
- ConvertRgb565ToGray(*((unsigned char*)byteBuffer.GetPointer()), (unsigned char*)pGrayBuf->GetPointer(),
- resolution.width, resolution.height);
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), (unsigned char*) pGrayBuf->GetPointer(),
+ resolution.width, resolution.height);
break;
case PIXEL_FORMAT_ARGB8888:
- ConvertArgb8888ToGray(*((unsigned char*)byteBuffer.GetPointer()), (unsigned char*)pGrayBuf->GetPointer(),
- resolution.width, resolution.height);
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) byteBuffer.GetPointer()), (unsigned char*) pGrayBuf->GetPointer(),
+ resolution.width, resolution.height);
break;
case PIXEL_FORMAT_YCbCr420_PLANAR:
memcpy((unsigned char*) (pGrayBuf->GetPointer()),
(unsigned char*) byteBuffer.GetPointer(), sizeof(unsigned char) * resolution.width * resolution.height);
break;
- default :
+
+ default:
break;
}
Tizen::Base::Collection::IList*
_FaceDetectorImpl::DetectFacesN(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution,
- FaceDetectionOption mode)
+ FaceDetectionOption mode)
{
+ int retValue = 0;
result r = E_SUCCESS;
- ClearLastResult();
-
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
unsigned char* pImageBuffer = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ ClearLastResult();
+
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
+ , GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct();
SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
- pImageBuffer = (unsigned char*)grayBuffer.GetPointer();
-
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ pImageBuffer = (unsigned char*) grayBuffer.GetPointer();
- if (mode == FACE_DETECTION_OPTION_FAST)
+ if (ToBeInitialized(__FACEDETECT_MODE_IMAGE))
{
- engineErr = face_attr_set_detect_mode(faceHandle, FACE_DETECT_MODE_FAST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to FAST",
- GetErrorMessage(E_FAILURE));
- }
- else
- {
- engineErr = face_attr_set_detect_mode(faceHandle, FACE_DETECT_MODE_ROBUST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to ROBUST",
- GetErrorMessage(E_FAILURE));
+ if (mode == FACE_DETECTION_OPTION_FAST)
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesAtomic, __scaleAtomic);
+ }
+ else
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLo_YAWo, FD_SIZE_COVERAGE_HIGH, __maxFacesAtomic, __scaleAtomic);
+ }
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
}
- faceCount = GetFaceRectsN(faceHandle, pImageBuffer, resolution.width, resolution.height, FACE_IMAGE_TYPE_SINGLE,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
- __isTrackingMode = false;
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- if (faceCount > 0)
+ if (__pFaceEngineInfo->g_iFaceDetectNum > 0)
{
- for (int i = 0; i < faceCount; i++)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
Tizen::Graphics::Rectangle* pRect =
- new (std::nothrow) Tizen::Graphics::Rectangle(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
- SysTryCatch(NID_UIX, pRect != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ new (std::nothrow) Tizen::Graphics::Rectangle(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
+
+ SysTryCatch(NID_UIX, pRect != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
r = pDetectList->Add(*pRect);
SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
}
}
- free(pFaceRects);
- face_destroy(faceHandle);
-
+ ReleaseFaceEngine();
return pDetectList.release();
-
CATCH:
- free(pFaceRects);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, r, "XXXX - CATCH _FaceDetectorImpl::DetectFacesN");
SetLastResult(r);
- return null;
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
result
_FaceDetectorImpl::ExtractFaceComponents(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution,
- const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Point& eyeRight,
- Tizen::Graphics::Point& eyeLeft, Tizen::Graphics::Rectangle& mouthRect)
+ const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Point& eyeRight,
+ Tizen::Graphics::Point& eyeLeft, Tizen::Graphics::Rectangle& mouthRect)
{
result r = E_SUCCESS;
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_h faceImage = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- face_rect_s* pFaceRects = null;
- face_rect_s tempFaceRect;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_point_s eyeL;
- face_point_s eyeR;
- face_rect_s mouthR;
- unsigned char* pImageBuffer = (unsigned char*)grayBuffer.GetPointer();
-
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
-
- tempFaceRect.x = faceRect.x;
- tempFaceRect.y = faceRect.y;
- tempFaceRect.w = faceRect.width;
- tempFaceRect.h = faceRect.height;
-
- engineErr = face_extract_component(faceHandle, faceImage, &tempFaceRect, &faceComponent);
-
- if(engineErr != FACE_ERROR_NONE)
- {
- engineErr = face_attr_set_detect_mode(faceHandle, FACE_DETECT_MODE_ROBUST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to ROBUST",
- GetErrorMessage(E_FAILURE));
+ int index = -1;
+ int retVal = 0;
+ FaceEngineInfo* pFaceEngineInfo = null;
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face at ROBUST mode",
- GetErrorMessage(E_FAILURE));
+ unsigned char* pImageBuffer = (unsigned char*) grayBuffer.GetPointer();
- tempFaceRect.x = faceRect.x;
- tempFaceRect.y = faceRect.y;
- tempFaceRect.w = faceRect.width;
- tempFaceRect.h = faceRect.height;
+ std::unique_ptr< FaceEngineInfo > pFaceEngineInfoTemp(new (std::nothrow) FaceEngineInfo);
+ SysTryReturn(NID_UIX, pFaceEngineInfoTemp != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
- engineErr = face_extract_component(faceHandle, faceImage, &tempFaceRect, &faceComponent);
- }
+ pFaceEngineInfo = pFaceEngineInfoTemp.get();
+ SysTryReturn(NID_UIX, pFaceEngineInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to extract the faceComponent.",
- GetErrorMessage(E_OPERATION_FAILED));
+ ReleaseFaceEngine();
- engineErr = face_component_get_right_eye_point(faceComponent, &eyeR);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to extract the faceComponent.",
- GetErrorMessage(E_OPERATION_FAILED));
+ retVal = caApp_FaceEngineInit(pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryReturn(NID_UIX, retVal == _FACEENGINE_INIT_SUCCESS, E_FAILURE, E_FAILURE, "[%s] Face Engine Init failed.", GetErrorMessage(E_FAILURE));
- engineErr = face_component_get_left_eye_point(faceComponent, &eyeL);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to extract the faceComponent.",
- GetErrorMessage(E_OPERATION_FAILED));
+ pFaceEngineInfo->g_iFaceDetectNum = 1;
+ pFaceEngineInfo->g_FaceROI[0].x = faceRect.x;
+ pFaceEngineInfo->g_FaceROI[0].y = faceRect.y;
+ pFaceEngineInfo->g_FaceROI[0].width = faceRect.width;
+ pFaceEngineInfo->g_FaceROI[0].height = faceRect.height;
- engineErr = face_component_get_mouth_rect(faceComponent, &mouthR);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to extract the faceComponent.",
- GetErrorMessage(E_OPERATION_FAILED));
+ retVal = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, pFaceEngineInfo, 0);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_OPERATION_FAILED, r = E_OPERATION_FAILED, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OPERATION_FAILED));
- eyeRight.x = eyeR.x;
- eyeRight.y = eyeR.y;
- eyeLeft.x = eyeL.x;
- eyeLeft.y = eyeL.y;
- mouthRect.x = mouthR.x;
- mouthRect.y = mouthR.y;
- mouthRect.width = mouthR.w;
- mouthRect.height = mouthR.h;
+ retVal = caApp_RunMouthDetection(pImageBuffer, resolution.width, resolution.height, pFaceEngineInfo, 0);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_OPERATION_FAILED, r = E_OPERATION_FAILED, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OPERATION_FAILED));
- face_image_destroy(faceImage);
- free(pFaceRects);
- face_component_destroy(faceComponent);
- face_destroy(faceHandle);
+ SysTryCatch(NID_UIX, ((pFaceEngineInfo->g_EyeROI[0].lx >= 0) && (pFaceEngineInfo->g_EyeROI[0].ly >= 0) &&
+ (pFaceEngineInfo->g_EyeROI[0].rx >= 0) && (pFaceEngineInfo->g_EyeROI[0].ry >= 0)),
+ r = E_OPERATION_FAILED, r = E_OPERATION_FAILED, "[%s] Failed to create the Buffer.", GetErrorMessage(E_OPERATION_FAILED));
- return r;
-CATCH:
- face_image_destroy(faceImage);
- free(pFaceRects);
- face_component_destroy(faceComponent);
- face_destroy(faceHandle);
+ SysTryCatch(NID_UIX, ((pFaceEngineInfo->g_MouthROI[0].x >= 0) && (pFaceEngineInfo->g_MouthROI[0].y >= 0) &&
+ (pFaceEngineInfo->g_MouthROI[0].width > 0) && (pFaceEngineInfo->g_MouthROI[0].height > 0)),
+ r = E_OPERATION_FAILED, r = E_OPERATION_FAILED, "[%s] Failed to create the Buffer.", GetErrorMessage(E_FAILURE));
- SetLastResult(r);
- return r;
-}
+ retVal = caApp_RunBlinkDetection(pImageBuffer, resolution.width, resolution.height, pFaceEngineInfo, true);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_OPERATION_FAILED, r = E_OPERATION_FAILED, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OPERATION_FAILED));
-result
-_FaceDetectorImpl::GetPosDifference(const Tizen::Base::ByteBuffer& prevGrayBuffer, const Tizen::Base::ByteBuffer& curGrayBuffer,
- const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect,
- Tizen::Graphics::Point& posDiff)
-{
- result r = E_SUCCESS;
-
- int engineErr = 0;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- face_image_h prevFaceImage = null;
- face_image_h curFaceImage = null;
- face_rect_s prevFaceRect;
- face_rect_s curFaceRect;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
-
- if (__isTrackingMode == false)
- {
- engineErr = face_destroy(__faceHandleVideoMode);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to destroy the handle.",
- GetErrorMessage(E_OPERATION_FAILED));
- engineErr = face_create(&__faceHandleVideoMode);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to create the handle.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- engineErr = face_attr_set_max_number_faces(__faceHandleVideoMode, __maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to set the property.",
- GetErrorMessage(E_OPERATION_FAILED));
- engineErr = face_attr_set_scale_factor(__faceHandleVideoMode, __scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to set the property.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- engineErr = face_attr_set_detect_inteval(__faceHandleVideoMode, _FT_INTERVAL_DEFAULT);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to set the property.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- face_rect_s* pFaceRectsTemp = null;
- faceCount = GetFaceRectsN(__faceHandleVideoMode, (unsigned char*)prevGrayBuffer.GetPointer(), resolution.width, resolution.height, FACE_IMAGE_TYPE_CONTINUOUS,
- imageColorspace, &pFaceRectsTemp);
- SysTryCatch(NID_UIX, faceCount >= 0, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the FaceRects.",
- GetErrorMessage(E_OPERATION_FAILED));
- free(pFaceRectsTemp);
-
- faceCount = GetFaceRectsN(__faceHandleVideoMode, (unsigned char*)curGrayBuffer.GetPointer(), resolution.width, resolution.height, FACE_IMAGE_TYPE_CONTINUOUS,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the FaceRects.",
- GetErrorMessage(E_OPERATION_FAILED));
- }
- else
- {
- faceCount = GetFaceRectsN(__faceHandleVideoMode, (unsigned char*)curGrayBuffer.GetPointer(), resolution.width, resolution.height, FACE_IMAGE_TYPE_CONTINUOUS,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the FaceRects.",
- GetErrorMessage(E_OPERATION_FAILED));
- }
- __isTrackingMode = true;
+ eyeLeft.x = pFaceEngineInfo->g_EyeROI[0].lx;
+ eyeLeft.y = pFaceEngineInfo->g_EyeROI[0].ly;
+ eyeRight.x = pFaceEngineInfo->g_EyeROI[0].rx;
+ eyeRight.y = pFaceEngineInfo->g_EyeROI[0].ry;
- engineErr = face_image_create(imageColorspace, (unsigned char*)prevGrayBuffer.GetPointer(), resolution.width, resolution.height,
- (resolution.width * resolution.height), &prevFaceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to create the faceImage.",
- GetErrorMessage(E_OPERATION_FAILED));
- engineErr = face_image_create(imageColorspace, (unsigned char*)curGrayBuffer.GetPointer(), resolution.width, resolution.height,
- (resolution.width * resolution.height), &curFaceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to create the faceImage.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- prevFaceRect.x = faceRect.x;
- prevFaceRect.y = faceRect.y;
- prevFaceRect.w = faceRect.width;
- prevFaceRect.h = faceRect.height;
-
- engineErr = face_get_movement(__faceHandleVideoMode, prevFaceImage, curFaceImage, &prevFaceRect, &curFaceRect);
-
- if(engineErr == FACE_ERROR_INVALID_PARAMTER)
- {
- __isTrackingMode = false;
-
- face_rect_s* pFaceRectsTemp = null;
-
- engineErr = face_destroy(__faceHandleVideoMode);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to destroy the handle.",
- GetErrorMessage(E_OPERATION_FAILED));
- engineErr = face_create(&__faceHandleVideoMode);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to create the handle.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- engineErr = face_attr_set_max_number_faces(__faceHandleVideoMode, __maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to set the property.",
- GetErrorMessage(E_OPERATION_FAILED));
- engineErr = face_attr_set_scale_factor(__faceHandleVideoMode, __scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to set the property.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- engineErr = face_attr_set_detect_inteval(__faceHandleVideoMode, _FT_INTERVAL_DEFAULT);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to set the property.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- engineErr = face_attr_set_detect_mode(__faceHandleVideoMode, FACE_DETECT_MODE_ROBUST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to ROBUST",
- GetErrorMessage(E_FAILURE));
-
- faceCount = GetFaceRectsN(__faceHandleVideoMode, (unsigned char*)prevGrayBuffer.GetPointer(), resolution.width, resolution.height, FACE_IMAGE_TYPE_SINGLE,
- imageColorspace, &pFaceRectsTemp);
-
- for(int i=0;i<faceCount;i++)
- {
- if(pFaceRectsTemp[i].x == faceRect.x && pFaceRectsTemp[i].y == faceRect.y && pFaceRectsTemp[i].w == faceRect.width && pFaceRectsTemp[i].h == faceRect.height)
- {
- int oldID = 0;
- float oldDistance = 0.0f;
- float nearDistance = 0.0f;
-
- engineErr = face_attr_set_detect_mode(__faceHandleVideoMode, FACE_DETECT_MODE_FAST);
- faceCount = GetFaceRectsN(__faceHandleVideoMode, (unsigned char*)prevGrayBuffer.GetPointer(), resolution.width, resolution.height, FACE_IMAGE_TYPE_CONTINUOUS,
- imageColorspace, &pFaceRectsTemp);
- SysTryCatch(NID_UIX, faceCount >= 0, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the FaceRects.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- faceCount = GetFaceRectsN(__faceHandleVideoMode, (unsigned char*)curGrayBuffer.GetPointer(), resolution.width, resolution.height, FACE_IMAGE_TYPE_CONTINUOUS,
- imageColorspace, &pFaceRects);
- SysTryCatch(NID_UIX, faceCount >= 0, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the FaceRects.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- for(int i = 0;i< faceCount; i++)
- {
- nearDistance = sqrt((pFaceRectsTemp[i].x - faceRect.x)^2 + (pFaceRectsTemp[i].y - faceRect.y)^2)
- + sqrt((pFaceRectsTemp[i].x + pFaceRectsTemp[i].w - faceRect.x - faceRect.width)^2 + (pFaceRectsTemp[i].y + pFaceRectsTemp[i].h - faceRect.y - faceRect.height)^2);
- if(oldDistance > nearDistance)
- {
- oldDistance = nearDistance;
- oldID = i;
- }
- }
-
- engineErr = face_get_movement(__faceHandleVideoMode, prevFaceImage, curFaceImage, &pFaceRectsTemp[oldID], &curFaceRect);
-
- if (curFaceRect.x == 0 && curFaceRect.y == 0 && curFaceRect.w == 0 && curFaceRect.h == 0)
- {
- engineErr = FACE_ERROR_OPERATION_FAILED;
- }
-
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the face movement.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- posDiff.x = curFaceRect.x - prevFaceRect.x;
- posDiff.y = curFaceRect.y - prevFaceRect.y;
-
- break;
- }
- }
- }
- else
- {
- if (curFaceRect.x == 0 && curFaceRect.y == 0 && curFaceRect.w == 0 && curFaceRect.h == 0)
- {
- engineErr = FACE_ERROR_OPERATION_FAILED;
- }
-
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to get the face movement.",
- GetErrorMessage(E_OPERATION_FAILED));
-
- posDiff.x = curFaceRect.x - prevFaceRect.x;
- posDiff.y = curFaceRect.y - prevFaceRect.y;
- }
-
- face_image_destroy(prevFaceImage);
- face_image_destroy(curFaceImage);
- free(pFaceRects);
-
- return r;
+ mouthRect.x = pFaceEngineInfo->g_MouthROI[0].x;
+ mouthRect.y = pFaceEngineInfo->g_MouthROI[0].y;
+ mouthRect.width = pFaceEngineInfo->g_MouthROI[0].width;
+ mouthRect.height = pFaceEngineInfo->g_MouthROI[0].height;
+ caApp_FaceEngineRelease(pFaceEngineInfo);
+ return E_SUCCESS;
CATCH:
- face_image_destroy(prevFaceImage);
- face_image_destroy(curFaceImage);
- free(pFaceRects);
-
+ caApp_FaceEngineRelease(pFaceEngineInfo);
return r;
}
-void
-_FaceDetectorImpl::ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height)
-{
- SysAssert(pGrayBuf != null);
- if (pGrayBuf == null)
- {
- return;
- }
-
- unsigned long* pSrc = (unsigned long*) &buf;
- unsigned char* pDSt = (unsigned char*) pGrayBuf;
- unsigned char* pEnd = pDSt + height * width;
-
- while (pDSt < pEnd)
- {
- unsigned long r = (*pSrc >> 16) & 0xFF;
- unsigned long g = (*pSrc >> 8) & 0xFF;
- unsigned long b = (*pSrc++) & 0xFF;
-
- *pDSt++ = (308 * r + 600 * g + 116 * b) >> 10;
- }
-}
-
-void
-_FaceDetectorImpl::ConvertRgb565ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height)
-{
- unsigned char* pDst = null;
- unsigned char* pEnd = null;
- unsigned short* pSrc = null;
-
- unsigned short r = 0;
- unsigned short g = 0;
- unsigned short b = 0;
- long lt = 0;
-
- SysAssert(pGrayBuf != null);
- if (pGrayBuf == null)
- {
- return;
- }
-
- pSrc = (unsigned short*) &buf;
- pDst = (unsigned char*) pGrayBuf;
- pEnd = (unsigned char*) ((unsigned char*) pGrayBuf + height * width);
-
- while (pDst < pEnd)
- {
- r = (unsigned char) ((*pSrc >> 11) << 3); // R
- g = (unsigned char) ((*pSrc & 0x07e0) >> 3); // +G
- b = (unsigned char) ((*pSrc++ & 0x001f) << 3); // +B
-
- // Y = 0.299 R + 0.587 G + 0.114 B
- lt = (306L * (long) r + 601L * (long) g + 117L * (long) b);
- *pDst++ = (unsigned char) (lt >> 10);
- //(BYTE)(((int)R+(int)G+(int)B) /3);
- }
-}
-
-void
-_FaceDetectorImpl::ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, face_rect_s* pFaceRects)
-{
- // no need to convert if both are same
- if (bufferWidth == bitmapWidth || bufferHeight == bitmapHeight)
- {
- return;
- }
-
- // Avoid 'division by zero'
- if (bufferWidth <= 0 || bufferHeight <= 0)
- {
- return;
- }
-
- // convert physical coordinate to virtual coordinate
- int x1 = pFaceRects->x;
- int x2 = x1 + pFaceRects->w;
- int y1 = pFaceRects->y;
- int y2 = y1 + pFaceRects->h;
-
- x1 = x1 * bitmapWidth / bufferWidth;
- x2 = x2 * bitmapWidth / bufferWidth;
- y1 = y1 * bitmapHeight / bufferHeight;
- y2 = y2 * bitmapHeight / bufferHeight;
-
- pFaceRects->x = x1;
- pFaceRects->y = y1;
- pFaceRects->w = x2 - x1;
- pFaceRects->h = y2 - y1;
-
- return;
-}
-int
-_FaceDetectorImpl::GetFaceRectsN(face_h& faceHandle, unsigned char* pImageBuffer, int width, int height,
- face_image_type_e mode, face_image_colorspace_e faceImageColorspace, face_rect_s** pFaceRects)
+result
+_FaceDetectorImpl::GetPosDifference(const Tizen::Base::ByteBuffer& prevGrayBuffer, const Tizen::Base::ByteBuffer& curGrayBuffer,
+ const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect,
+ Tizen::Graphics::Point& posDiff)
{
+ caFaceROI ROI = {0, 0, 0, 0};
+ int move_width = 0;
+ int move_height = 0;
+ int retVal = 0;
result r = E_SUCCESS;
- ClearLastResult();
- int engineErr = 0;
- face_image_h faceImage = null;
- int faceCount = 0;
- int bytePerPixel = 1;
- if (faceImageColorspace == FACE_IMAGE_COLORSPACE_RGB565)
- {
- bytePerPixel = 2;
- }
+ __isTrackingMode = true;
- engineErr = face_image_create(faceImageColorspace, pImageBuffer, width, height, (width * height * bytePerPixel), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ ROI.x = faceRect.x;
+ ROI.y = faceRect.y;
+ ROI.width = faceRect.width;
+ ROI.height = faceRect.height;
- engineErr = face_detect_faces(faceHandle, mode, faceImage, pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
- face_image_destroy(faceImage);
- SetLastResult(r);
+ retVal = caApp_TraceRegion((unsigned char*) prevGrayBuffer.GetPointer(), (unsigned char*) curGrayBuffer.GetPointer(),
+ ROI, resolution.width, resolution.height, &move_width, &move_height);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Failed to create the Buffer.", GetErrorMessage(E_OPERATION_FAILED));
- return faceCount;
+ posDiff.x = move_width;
+ posDiff.y = move_height;
-CATCH:
- face_image_destroy(faceImage);
+ return E_SUCCESS;
- SetLastResult(r);
- return -1;
+CATCH:
+ return r;
}
+
_FaceDetectorImpl*
_FaceDetectorImpl::GetInstance(FaceDetector* pFaceDetector)
{
#include <FGrpRectangle.h>
#include <FUixVisionFaceDetector.h>
#include <FUixVisionFaceTypes.h>
-#include "face.h"
+#include "caFaceAPP_interface.h"
+#include "FUixVision_FaceUtil.h"
struct CollectionAllElementDelete
{
- template<typename Collection>
- void operator()(Collection* c)
- {
+ template< typename Collection >
+ void operator ()(Collection* c)
+ {
c->RemoveAll();
delete c;
- }
+ }
};
namespace Tizen { namespace Uix { namespace Vision
: public Tizen::Base::Object
{
+ typedef enum
+ {
+ __FACEDETECT_MODE_UNINITIALIZED = 0x100,
+ __FACEDETECT_MODE_IMAGE,
+ __FACEDETECT_MODE_VIDEO,
+ }FaceDetectMode;
+
public:
/**
* This is the default constructor for this class.
* The object is not fully constructed after this constructor is called.
* For full construction, the Construct() method must be called right after calling this constructor.
*
- * @since 2.0
+ * @since 1.0
*/
_FaceDetectorImpl(void);
* This is the destructor for this class.
* This destructor overrides Tizen::Base::Object::~Object().
*
- * @since 2.0
+ * @since 1.0
*/
virtual ~_FaceDetectorImpl(void);
* @return An error code
* @exception E_SUCCESS The method was successful.
* @exception E_OUT_OF_MEMORY Insufficient memory.
- * @since 2.0
+ * @since 1.0
*/
result Construct(void);
* @exception E_SUCCESS - This method is successful.
* @exception E_OUT_OF_MEMORY - Failed to allocate required/requested memory.
*/
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* GetSupportedFormatListN(void) const;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* GetSupportedFormatListN(void) const;
/**
* Searches for faces from a video image.
* This is the result of a normal operation. @n
* @since 2.0
*/
- result ExtractFaceComponents(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution,
- const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Point& eyeRight,
- Tizen::Graphics::Point& eyeLeft, Tizen::Graphics::Rectangle& mouthRect);
+ result ExtractFaceComponents(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Point& eyeRight, Tizen::Graphics::Point& eyeLeft, Tizen::Graphics::Rectangle& mouthRect);
/**
* Tracks the interest region.
void ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height);
void ConvertRgb565ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height);
- int GetFaceRectsN(face_h& faceHandel, unsigned char* pImageBuffer, int width, int height,
- face_image_type_e mode, face_image_colorspace_e faceImageColorspace, face_rect_s** pFaceRects);
- void ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, face_rect_s* pFaceRects);
+ void ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, Tizen::Graphics::Rectangle* pRect);
+ result Initilize(int initMode, FaceDetectionOption detectMode);
+ result Release(void);
+ bool ToBeInitialized(FaceDetectMode currMode);
+ bool ReleaseFaceEngine();
friend class _FaceRecognizerImpl;
long __scaleVideo;
long __maxFacesImage;
long __scaleImage;
- face_h __faceHandleVideoMode;
bool __isTrackingMode;
+ FaceEngineInfo* __pFaceEngineInfo;
+ _FaceUtil* __pFaceUtil;
+ FaceDetectMode __prevDetectMode;
};
} } } //Tizen::Uix::Vision
static const int _FR_SCALE_VIDEO_MIN = 1;
static const int _FR_SCALE_IMAGE_MIN = 1;
+static const int _FT_INTERVAL_DEFAULT = 20;
+static const int _FACEENGINE_INIT_SUCCESS = 1;
+static const int _FACEENGINE_RETURN_SUCCESS = 1;
+static char _FACE_ENGINE_BIN_PATH[] = "/usr/share/face-engine/data/";
+
class _RectHashCodeProvider
- : public IHashCodeProviderT <Tizen::Graphics::Rectangle>
+ : public IHashCodeProviderT< Tizen::Graphics::Rectangle >
{
public:
_RectHashCodeProvider(void) {}
};
class _RectComparerT
- : public virtual IComparerT <Tizen::Graphics::Rectangle>
+ : public virtual IComparerT< Tizen::Graphics::Rectangle >
, public Object
{
public:
long max = 0;
long steppingDelta = 0;
result res = E_SUCCESS;
- int engineError = 0;
-
- engineError = face_create(&__faceHandleVideoMode);
- SysTryReturn(NID_UIX, engineError == FACE_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
- , GetErrorMessage(E_OUT_OF_MEMORY));
GetRange(FACERECOGNIZER_MAXNUMBER_VIDEO, min, max, steppingDelta, __maxFacesVideo);
GetRange(FACERECOGNIZER_MAXNUMBER_IMAGE, min, max, steppingDelta, __maxFacesImage);
GetRange(FACERECOGNIZER_SCALE_VIDEO, min, max, steppingDelta, __scaleVideo);
GetRange(FACERECOGNIZER_SCALE_IMAGE, min, max, steppingDelta, __scaleImage);
+
+ std::unique_ptr< FaceEngineInfo > pFaceEngineInfo(new (std::nothrow) FaceEngineInfo);
+ SysTryReturn(NID_UIX, pFaceEngineInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pFaceEngineInfo = pFaceEngineInfo.release();
+
+ //int retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLo_YAWo, FD_SIZE_COVERAGE_HIGH,__maxFacesImage, _FT_INTERVAL_DEFAULT);
+ //SysTryReturn(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, E_FAILURE, E_FAILURE, "[%s] Face Engine Init failed.", GetErrorMessage(E_FAILURE));
+
+ std::unique_ptr< _FaceUtil > pFaceUtil(new (std::nothrow) _FaceUtil);
+ SysTryReturn(NID_UIX, pFaceUtil != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pFaceUtil = pFaceUtil.release();
+
return res;
}
, __scaleImage(0)
, __maxFacesVideo(0)
, __maxFacesImage(0)
- , __faceHandleVideoMode(null)
+ , __pFaceEngineInfo(null)
+ , __pFaceUtil(null)
+ , __prevRecognizeMode(__FACERECOGNIZE_MODE_UNINITIALIZED)
{
+
}
_FaceRecognizerImpl::~_FaceRecognizerImpl(void)
{
- face_destroy(__faceHandleVideoMode);
+ ReleaseFaceEngine();
+
+ delete __pFaceEngineInfo;
+ delete __pFaceUtil;
+}
+
+bool
+_FaceRecognizerImpl::ToBeInitialized(FaceRecognizeMode currMode)
+{
+ if (__prevRecognizeMode == currMode)
+ {
+ return false;
+ }
+
+ ReleaseFaceEngine();
+
+ __prevRecognizeMode = currMode;
+
+ return true;
+}
+
+bool
+_FaceRecognizerImpl::ReleaseFaceEngine()
+{
+ if (__prevRecognizeMode != __FACERECOGNIZE_MODE_UNINITIALIZED)
+ {
+ int retValue = caApp_FaceEngineRelease(__pFaceEngineInfo);
+ SysTryReturn(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, false, E_FAILURE,
+ "[%s] Failed to release face engine", GetErrorMessage(E_FAILURE));
+ }
+
+ __prevRecognizeMode = __FACERECOGNIZE_MODE_UNINITIALIZED;
+
+ return true;
}
result
switch (configProperty)
{
case FACERECOGNIZER_MAXNUMBER_VIDEO:
- {
- min = _FR_MAXNUM_VIDEO_MIN;
- max = _FR_MAXNUM_VIDEO_MAX;
- steppingDelta = 1;
- defaultVal = _FR_MAXNUM_VIDEO_DEFAULT;
- }
- break;
+ {
+ min = _FR_MAXNUM_VIDEO_MIN;
+ max = _FR_MAXNUM_VIDEO_MAX;
+ steppingDelta = 1;
+ defaultVal = _FR_MAXNUM_VIDEO_DEFAULT;
+ }
+ break;
case FACERECOGNIZER_MAXNUMBER_IMAGE:
- {
- min = _FR_MAXNUM_IMAGE_MIN;
- max = _FR_MAXNUM_IMAGE_MAX;
- steppingDelta = 1;
- defaultVal = _FR_MAXNUM_IMAGE_DEFAULT;
- }
- break;
+ {
+ min = _FR_MAXNUM_IMAGE_MIN;
+ max = _FR_MAXNUM_IMAGE_MAX;
+ steppingDelta = 1;
+ defaultVal = _FR_MAXNUM_IMAGE_DEFAULT;
+ }
+ break;
case FACERECOGNIZER_SCALE_VIDEO:
- {
- min = _FR_SCALE_VIDEO_MIN;
- max = _FR_SCALE_VIDEO_MAX;
- defaultVal = _FR_SCALE_VIDEO_DEFAULT;
- steppingDelta = 1;
- }
- break;
+ {
+ min = _FR_SCALE_VIDEO_MIN;
+ max = _FR_SCALE_VIDEO_MAX;
+ defaultVal = _FR_SCALE_VIDEO_DEFAULT;
+ steppingDelta = 1;
+ }
+ break;
case FACERECOGNIZER_SCALE_IMAGE:
- {
- min = _FR_SCALE_IMAGE_MIN;
- max = _FR_SCALE_IMAGE_MAX;
- defaultVal = _FR_SCALE_IMAGE_DEFAULT;
- steppingDelta = 1;
- }
- break;
+ {
+ min = _FR_SCALE_IMAGE_MIN;
+ max = _FR_SCALE_IMAGE_MAX;
+ defaultVal = _FR_SCALE_IMAGE_DEFAULT;
+ steppingDelta = 1;
+ }
+ break;
default:
- {
- min = 0;
- max = 0;
- steppingDelta = 1;
- defaultVal = 0;
- SysLogException(NID_UIX, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
- GetErrorMessage(E_UNSUPPORTED_OPERATION));
- return E_UNSUPPORTED_OPERATION;
- }
- break;
+ {
+ min = 0;
+ max = 0;
+ steppingDelta = 1;
+ defaultVal = 0;
+ SysLogException(NID_UIX, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
+ GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ return E_UNSUPPORTED_OPERATION;
+ }
+ break;
}
return res;
return __scaleImage;
default:
- {
- SysLogException(NID_UIX, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
- GetErrorMessage(E_UNSUPPORTED_OPERATION));
- }
- break;
+ {
+ SysLogException(NID_UIX, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
+ GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ }
+ break;
}
return long(-1);
}
//configProperty is always available. Becuase this is checked before calling this function.
res = GetRange(configProperty, min, max, steppingDelta, defaultVal);
SysTryReturn(NID_UIX, value >= min && value <= max && value % steppingDelta == 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[%s] The specified value (%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), value);
+ "[%s] The specified value (%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), value);
switch (configProperty)
{
default:
SysLogException(NID_UIX, E_UNSUPPORTED_OPERATION, "[%s] The device does not support this property.",
- GetErrorMessage(E_UNSUPPORTED_OPERATION));
+ GetErrorMessage(E_UNSUPPORTED_OPERATION));
return E_UNSUPPORTED_OPERATION;
}
return res;
}
-Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>*
+Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >*
_FaceRecognizerImpl::GetSupportedFormatListN(void) const
{
- std::unique_ptr<Tizen::Base::Collection::LinkedListT <Tizen::Graphics::PixelFormat>, CollectionAllElementDeleter>
- pFormatList(new (std::nothrow) Tizen::Base::Collection::LinkedListT <Tizen::Graphics::PixelFormat>);
+ std::unique_ptr< Tizen::Base::Collection::LinkedListT< Tizen::Graphics::PixelFormat >, CollectionAllElementDeleter >
+ pFormatList(new (std::nothrow) Tizen::Base::Collection::LinkedListT< Tizen::Graphics::PixelFormat >);
SysTryReturn(NID_UIX, pFormatList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
- GetErrorMessage(E_OUT_OF_MEMORY));
+ GetErrorMessage(E_OUT_OF_MEMORY));
pFormatList->InsertAt(Tizen::Graphics::PIXEL_FORMAT_RGB565, 0);
pFormatList->InsertAt(Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR, 0);
Tizen::Base::Collection::IList*
_FaceRecognizerImpl::ExtractFaceFeaturesFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- const Tizen::Graphics::PixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ const Tizen::Graphics::PixelFormat format)
{
ClearLastResult();
- result r = E_SUCCESS;
- int engineErr = 0;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_feature_h faceFeature = null;
- std::unique_ptr<FaceRecognitionInfo> pFaceInfo;
- unsigned char *pFeatureBuffer = null;
+ result r = E_SUCCESS;
+ int retValue = 0;
int featureLength = 0;
+ unsigned char* pImageBuffer = null;
+ ByteBuffer buffer;
+ int isValidFREngine = 0;
+
+ std::unique_ptr< FaceRecognitionInfo > pFaceInfo;
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
- GetErrorMessage(E_OUT_OF_MEMORY));
+ GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct();
SysTryReturn(NID_UIX, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
if (format == PIXEL_FORMAT_YCbCr420_PLANAR)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
+ pImageBuffer = (unsigned char*) byteBuffer.GetPointer();
}
else if (format == PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- engineErr = face_attr_set_max_number_faces(__faceHandleVideoMode, __maxFacesVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(__faceHandleVideoMode, __scaleVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_image_create(imageColorspace, (unsigned char*)byteBuffer.GetPointer(), resolution.width,
- resolution.height, (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_VIDEO_FACE))
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesVideo, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_detect_faces(__faceHandleVideoMode, FACE_IMAGE_TYPE_CONTINUOUS, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- for (int i = 0; i < faceCount; ++i)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- engineErr = face_extract_component(__faceHandleVideoMode, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- engineErr = face_extract_feature(__faceHandleVideoMode, faceImage, faceComponent, &faceFeature);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the feature.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunMouthDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- face_component_destroy(faceComponent);
+ //isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, "/usr/share/face-engine/data/");
+ isValidFREngine = caApp_FtsExInit(FR_MODE_MPL2, _FACE_ENGINE_BIN_PATH);
- engineErr = face_feature_get_data(faceFeature, &pFeatureBuffer, &featureLength);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to get the feature data.", GetErrorMessage(E_FAILURE));
+ //SysTryCatch(NID_UIX, isValidFREngine == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
- ByteBuffer buffer;
- r = buffer.Construct(featureLength * sizeof(unsigned char));
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(E_FAILURE));
+ featureLength = caApp_FtsExVecLength();
+ SysTryCatch(NID_UIX, featureLength > 0, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
+
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
+ {
+ long* pFaceData = caApp_FtsExGetFeatureVector(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, pFaceData != null, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
- r = buffer.SetArray((byte*)pFeatureBuffer, 0, featureLength * sizeof(unsigned char));
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to set the array.", GetErrorMessage(E_FAILURE));
+ r = buffer.Construct(featureLength * sizeof(long));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(r));
- pFaceInfo = std::unique_ptr<FaceRecognitionInfo>(new (std::nothrow) FaceRecognitionInfo);
+ r = buffer.SetArray((byte*) pFaceData, 0, featureLength * sizeof(long));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to set the array.", GetErrorMessage(r));
+
+ pFaceInfo = std::unique_ptr< FaceRecognitionInfo >(new (std::nothrow) FaceRecognitionInfo);
SysTryCatch(NID_UIX, pFaceInfo != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to allocate Memory.", GetErrorMessage(E_OUT_OF_MEMORY));
+
r = pFaceInfo->Construct(buffer);
- SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct the FaceRecognitionInfo.", GetErrorMessage(E_FAILURE));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct the FaceRecognitionInfo.", GetErrorMessage(r));
+
+ pFaceInfo->SetFacePosition(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
- pFaceInfo->SetFacePosition(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
r = pDetectList->Add(*(pFaceInfo.release()));
SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to add the FaceRecognitionInfo.", GetErrorMessage(E_FAILURE));
-
- face_feature_destroy(faceFeature);
-
}
- free(pFaceRects);
- face_image_destroy(faceImage);
+
+ caApp_FtsExRelease();
return pDetectList.release();
CATCH:
-
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_component_destroy(faceComponent);
- face_feature_destroy(faceFeature);
-
SetLastResult(r);
- return null;
+ caApp_FtsExRelease();
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
Tizen::Base::Collection::IList*
_FaceRecognizerImpl::ExtractFaceFeaturesFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- Tizen::Graphics::BitmapPixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ Tizen::Graphics::BitmapPixelFormat format)
{
ClearLastResult();
+
result r = E_SUCCESS;
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_feature_h faceFeature = null;
- std::unique_ptr<FaceRecognitionInfo> pFaceInfo;
- unsigned char *pFeatureBuffer = null;
- int featureLength;
unsigned char* pImageBuffer = null;
+ int retValue = 0;
+ int isValidFREngine = 0;
+ int featureLength = 0;
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ std::unique_ptr< FaceRecognitionInfo > pFaceInfo;
+
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
- GetErrorMessage(E_OUT_OF_MEMORY));
+ GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct();
SysTryReturn(NID_UIX, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.", GetErrorMessage(E_OUT_OF_MEMORY));
+
if (format == BITMAP_PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
- pImageBuffer = (unsigned char*)byteBuffer.GetPointer();
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height * 2), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
else if (format == BITMAP_PIXEL_FORMAT_ARGB8888)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- std::unique_ptr<unsigned char> pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
- SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- pImageBuffer = pBuffer.get();
- SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.", GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertArgb8888ToGray(*((unsigned char*)byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_IMAGE_FACE))
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- for (int i = 0; i < faceCount; ++i)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- engineErr = face_extract_component(faceHandle, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- engineErr = face_extract_feature(faceHandle, faceImage, faceComponent, &faceFeature);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the feature.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunMouthDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- face_component_destroy(faceComponent);
- faceComponent = null;
+ //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));
- engineErr = face_feature_get_data(faceFeature, &pFeatureBuffer, &featureLength);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to get the feature data.", GetErrorMessage(E_FAILURE));
+ featureLength = caApp_FtsExVecLength();
+ SysTryCatch(NID_UIX, featureLength > 0, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
+
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
+ {
+ long* pFaceData = caApp_FtsExGetFeatureVector(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, pFaceData != null, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
ByteBuffer buffer;
- r = buffer.Construct(featureLength * sizeof(unsigned char));
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(E_FAILURE));
+ r = buffer.Construct(featureLength * sizeof(long));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(r));
- r = buffer.SetArray((byte*)pFeatureBuffer, 0, featureLength * sizeof(unsigned char));
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to set the array.", GetErrorMessage(E_FAILURE));
+ r = buffer.SetArray((byte*) pFaceData, 0, featureLength * sizeof(long));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to set the array.", GetErrorMessage(r));
- pFaceInfo = std::unique_ptr<FaceRecognitionInfo>(new (std::nothrow) FaceRecognitionInfo);
+ pFaceInfo = std::unique_ptr< FaceRecognitionInfo >(new (std::nothrow) FaceRecognitionInfo);
SysTryCatch(NID_UIX, pFaceInfo != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pFaceInfo->Construct(buffer);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct the FaceRecognitionInfo.", GetErrorMessage(E_FAILURE));
- pFaceInfo->SetFacePosition(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+ pFaceInfo->SetFacePosition(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
r = pDetectList->Add(*(pFaceInfo.release()));
SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to add the FaceRecognitionInfo.", GetErrorMessage(E_FAILURE));
-
- face_feature_destroy(faceFeature);
- faceFeature = null;
-
}
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
+ caApp_FtsExRelease();
+ ReleaseFaceEngine();
return pDetectList.release();
CATCH:
-
- free(pFaceRects);
- face_image_destroy(faceImage);
- if (faceComponent != null)
- {
- face_component_destroy(faceComponent);
- }
- if (faceFeature != null)
- {
- face_feature_destroy(faceFeature);
- }
- face_destroy(faceHandle);
-
SetLastResult(r);
- return null;
+ caApp_FtsExRelease();
+ ReleaseFaceEngine();
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
Tizen::Base::Collection::IList*
{
ClearLastResult();
result r = E_SUCCESS;
-
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_feature_h faceFeature = null;
- std::unique_ptr<FaceRecognitionInfo> pFaceInfo;
- unsigned char *pFeatureBuffer = null;
- int featureLength;
unsigned char* pImageBuffer = null;
+ int retValue = 0;
+ int isValidFREngine = 0;
+ int featureLength = 0;
+ std::unique_ptr< FaceRecognitionInfo > pFaceInfo;
BufferInfo bitmapInfo;
- r = const_cast <Tizen::Graphics::Bitmap*>(&bitmap)->Lock(bitmapInfo);
+ r = const_cast< Tizen::Graphics::Bitmap* >(&bitmap)->Lock(bitmapInfo);
SysTryReturn(NID_UIX, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
- std::unique_ptr<Tizen::Base::Collection::ArrayList, AllElementsDeleter> pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pDetectList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct();
SysTryReturn(NID_UIX, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[bitmapInfo.width * bitmapInfo.height]);
+ SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pImageBuffer = pBuffer.get();
+
if (bitmapInfo.pixelFormat == PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
- pImageBuffer = (unsigned char*)bitmapInfo.pPixels;
- engineErr = face_image_create(imageColorspace, pImageBuffer, bitmapInfo.width, bitmapInfo.height,
- (bitmapInfo.width * bitmapInfo.height * 2), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) bitmapInfo.pPixels), pImageBuffer, bitmapInfo.width, bitmapInfo.height);
}
else if (bitmapInfo.pixelFormat == PIXEL_FORMAT_ARGB8888)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- std::unique_ptr<unsigned char> pBuffer(new (std::nothrow) unsigned char[bitmapInfo.width * bitmapInfo.height]);
- SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- pImageBuffer = pBuffer.get();
- SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.",
- GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertArgb8888ToGray(*((unsigned char*)bitmapInfo.pPixels), pImageBuffer, bitmapInfo.width, bitmapInfo.height);
- engineErr = face_image_create(imageColorspace, pImageBuffer, bitmapInfo.width, bitmapInfo.height,
- (bitmapInfo.width * bitmapInfo.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) bitmapInfo.pPixels), pImageBuffer, bitmapInfo.width, bitmapInfo.height);
}
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_IMAGE_FACE))
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunFaceDetection(pImageBuffer, bitmapInfo.width, bitmapInfo.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- for (int i = 0; i < faceCount; ++i)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- engineErr = face_extract_component(faceHandle, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunEyeDetection(pImageBuffer, bitmapInfo.width, bitmapInfo.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+
+ retValue = caApp_RunMouthDetection(pImageBuffer, bitmapInfo.width, bitmapInfo.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_extract_feature(faceHandle, faceImage, faceComponent, &faceFeature);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the feature.", 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));
- face_component_destroy(faceComponent);
- faceComponent = null;
+ featureLength = caApp_FtsExVecLength();
+ SysTryCatch(NID_UIX, featureLength > 0, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
- engineErr = face_feature_get_data(faceFeature, &pFeatureBuffer, &featureLength);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to get the feature data.", GetErrorMessage(E_FAILURE));
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
+ {
+ long* pFaceData = caApp_FtsExGetFeatureVector(pImageBuffer, bitmapInfo.width, bitmapInfo.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, pFaceData != null, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
ByteBuffer buffer;
- r = buffer.Construct(featureLength * sizeof(unsigned char));
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(E_FAILURE));
+ r = buffer.Construct(featureLength * sizeof(long));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(r));
- r = buffer.SetArray((byte*)pFeatureBuffer, 0, featureLength * sizeof(unsigned char));
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to set the array.", GetErrorMessage(E_FAILURE));
+ r = buffer.SetArray((byte*) pFaceData, 0, featureLength * sizeof(long));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to set the array.", GetErrorMessage(r));
- pFaceInfo = std::unique_ptr<FaceRecognitionInfo>(new (std::nothrow) FaceRecognitionInfo);
- SysTryCatch(NID_UIX, pFaceInfo != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pFaceInfo = std::unique_ptr< FaceRecognitionInfo >(new (std::nothrow) FaceRecognitionInfo);
+ SysTryCatch(NID_UIX, pFaceInfo != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pFaceInfo->Construct(buffer);
- SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct the FaceRecognitionInfo.", GetErrorMessage(E_FAILURE));
+ SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Failed to construct the FaceRecognitionInfo.", GetErrorMessage(r));
+
+ Tizen::Graphics::Rectangle* pRect =
+ new (std::nothrow) Tizen::Graphics::Rectangle(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
+ SysTryCatch(NID_UIX, pRect != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertVirtualToPhysicalCoordinates(bitmap.GetWidth(), bitmap.GetHeight(), bitmapInfo.width, bitmapInfo.height, &pFaceRects[i]);
- pFaceInfo->SetFacePosition(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+ __pFaceUtil->ConvertVirtualToPhysicalCoordinates(bitmap.GetWidth(), bitmap.GetHeight(), bitmapInfo.width, bitmapInfo.height, pRect);
+
+ pFaceInfo->SetFacePosition(pRect->x, pRect->y, pRect->width, pRect->height);
r = pDetectList->Add(*(pFaceInfo.release()));
SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to add the FaceRecognitionInfo.", GetErrorMessage(E_FAILURE));
- face_feature_destroy(faceFeature);
- faceFeature = null;
-
+ delete pRect;
}
- r = const_cast <Tizen::Graphics::Bitmap*>(&bitmap)->Unlock();
- SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
+ caApp_FtsExRelease();
- return pDetectList.release();
+ r = const_cast< Tizen::Graphics::Bitmap* >(&bitmap)->Unlock();
+ SysTryCatch(NID_UIX, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
+ ReleaseFaceEngine();
+ return pDetectList.release();
CATCH:
-
- free(pFaceRects);
- face_image_destroy(faceImage);
- if (faceComponent != null)
- {
- face_component_destroy(faceComponent);
- }
- if (faceFeature != null)
- {
- face_feature_destroy(faceFeature);
- }
- face_destroy(faceHandle);
-
SetLastResult(r);
- return null;
+ caApp_FtsExRelease();
+ ReleaseFaceEngine();
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
int
_FaceRecognizerImpl::MeasureSimilarity(const Tizen::Base::ByteBuffer& face1, const Tizen::Base::ByteBuffer& face2)
{
ClearLastResult();
- result r = E_SUCCESS;
- face_feature_h faceFeature1 = null;
- face_feature_h faceFeature2 = null;
- int engineErr = 0;
- float similarity = 0;
- int length1 = face1.GetCapacity();
- int length2 = face2.GetCapacity();
-
- engineErr = face_feature_create(&faceFeature1);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the feature data.", GetErrorMessage(E_FAILURE));
- engineErr = face_feature_create(&faceFeature2);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the feature data.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_feature_set_data(faceFeature1, (unsigned char*)face1.GetPointer(), length1);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the feature data.", GetErrorMessage(E_FAILURE));
- engineErr = face_feature_set_data(faceFeature2, (unsigned char*)face2.GetPointer(), length2);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the feature data.", GetErrorMessage(E_FAILURE));
+ caApp_FtsExInit(FR_MODE_MPL2, _FACE_ENGINE_BIN_PATH);
- engineErr = face_compare_feature(faceFeature1, faceFeature2, &similarity);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to compare the feature data.", GetErrorMessage(E_FAILURE));
+ long similarityVal = caApp_FtsExCompareFeatureVector((long*) face1.GetPointer(), (long*) face2.GetPointer());
- if (faceFeature1 != null)
- {
- face_feature_destroy(faceFeature1);
- faceFeature1 = null;
- }
- if (faceFeature2 != null)
- {
- face_feature_destroy(faceFeature2);
- faceFeature2 = null;
- }
-
- SetLastResult(r);
- return (int)(similarity * 100);
-
-CATCH:
- if (faceFeature1 != null)
- {
- face_feature_destroy(faceFeature1);
- }
- if (faceFeature2 != null)
- {
- face_feature_destroy(faceFeature2);
- }
- SetLastResult(r);
- return 0;
+ caApp_FtsExRelease();
+ return (int) (((float) similarityVal / 1023) * 100);
}
bool
}
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >*
_FaceRecognizerImpl::DetectBlinksFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- Tizen::Graphics::BitmapPixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ Tizen::Graphics::BitmapPixelFormat format)
{
ClearLastResult();
result r = E_SUCCESS;
-
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
unsigned char* pImageBuffer = null;
- face_eye_state_e leftEye;
- face_eye_state_e rightEye;
+ int retVal = 0;
- IHashCodeProviderT <Tizen::Graphics::Rectangle>* pRectProvider = null;
- std::unique_ptr<_RectHashCodeProvider> pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
+ IHashCodeProviderT< Tizen::Graphics::Rectangle >* pRectProvider = null;
+ std::unique_ptr< _RectHashCodeProvider > pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
SysTryReturn(NID_UIX, pUniqRectProvider != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- IComparerT <Tizen::Graphics::Rectangle>* pRectComparer = null;
- std::unique_ptr<_RectComparerT> pUniqRectComparer(new (std::nothrow) _RectComparerT);
+ IComparerT< Tizen::Graphics::Rectangle >* pRectComparer = null;
+ std::unique_ptr< _RectComparerT > pUniqRectComparer(new (std::nothrow) _RectComparerT);
SysTryReturn(NID_UIX, pUniqRectComparer != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create _RectComparerT.", GetErrorMessage(E_OUT_OF_MEMORY));
- std::unique_ptr<Tizen::Base::Collection::HashMapT <Tizen::Graphics::Rectangle,EyeState>, CollectionAllElementDeleter>
- pDetectList (new (std::nothrow) HashMapT <Tizen::Graphics::Rectangle, EyeState>);
+ std::unique_ptr< Tizen::Base::Collection::HashMapT< Tizen::Graphics::Rectangle, EyeState >, CollectionAllElementDeleter >
+ pDetectList(new (std::nothrow) HashMapT< Tizen::Graphics::Rectangle, EyeState >);
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ std::unique_ptr< unsigned char > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.",
+ GetErrorMessage(E_OUT_OF_MEMORY));
+
pRectProvider = pUniqRectProvider.get();
SysTryCatch(NID_UIX, pRectProvider != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
pRectComparer = pUniqRectComparer.get();
SysTryCatch(NID_UIX, pRectComparer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct(0, 0, *pRectProvider, *pRectComparer);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
if (format == BITMAP_PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
- pImageBuffer = (unsigned char*)byteBuffer.GetPointer();
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height * 2), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
else if (format == BITMAP_PIXEL_FORMAT_ARGB8888)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- std::unique_ptr<unsigned char[]> pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
- SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- pImageBuffer = pBuffer.get();
- SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.",
- GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertArgb8888ToGray(*((unsigned char*)byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_IMAGE_FACE))
+ {
+ retVal = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- for (int i = 0; i < faceCount; ++i)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- engineErr = face_extract_component(faceHandle, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- engineErr = face_recognize_blink(faceHandle, faceImage, faceComponent, &leftEye, &rightEye);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to recognize the eye state.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunMouthDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+
+ retVal = caApp_RunBlinkDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, true);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
EyeState eyeState;
- if((leftEye == FACE_EYE_STATE_OPENED) && (rightEye == FACE_EYE_STATE_OPENED))
+
+ if (*(__pFaceEngineInfo->g_Blink[i]) == 0)
{
eyeState = EYE_STATE_BOTH_OPEN;
}
- else if((leftEye == FACE_EYE_STATE_CLOSED) && (rightEye == FACE_EYE_STATE_CLOSED))
+ else if (*(__pFaceEngineInfo->g_Blink[i]) == 3)
{
eyeState = EYE_STATE_BOTH_CLOSED;
}
eyeState = EYE_STATE_NONE;
}
- Rectangle rect(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+ Rectangle rect(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y, __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
r = pDetectList->Add(rect, eyeState);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- face_component_destroy(faceComponent);
- faceComponent = null;
}
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
+
+ ReleaseFaceEngine();
return pDetectList.release();
CATCH:
- if (faceComponent != null)
- {
- face_component_destroy(faceComponent);
- }
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - CATCH _FaceRecognizerImpl::DetectBlinksFromBitmapN-");
SetLastResult(r);
- return null;
+ ReleaseFaceEngine();
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >*
_FaceRecognizerImpl::RecognizeExpressionsFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- Tizen::Graphics::BitmapPixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ Tizen::Graphics::BitmapPixelFormat format)
{
ClearLastResult();
result r = E_SUCCESS;
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
+ int retVal = 0;
unsigned char* pImageBuffer = null;
- face_expression_e faceExpr;
- IHashCodeProviderT <Tizen::Graphics::Rectangle>* pRectProvider = null;
- std::unique_ptr<_RectHashCodeProvider> pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
+ IHashCodeProviderT< Tizen::Graphics::Rectangle >* pRectProvider = null;
+ std::unique_ptr< _RectHashCodeProvider > pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
SysTryReturn(NID_UIX, pUniqRectProvider != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- IComparerT <Tizen::Graphics::Rectangle>* pRectComparer = null;
- std::unique_ptr<_RectComparerT> pUniqRectComparer(new (std::nothrow) _RectComparerT);
+ IComparerT< Tizen::Graphics::Rectangle >* pRectComparer = null;
+ std::unique_ptr< _RectComparerT > pUniqRectComparer(new (std::nothrow) _RectComparerT);
SysTryReturn(NID_UIX, pUniqRectComparer != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- std::unique_ptr<Tizen::Base::Collection::HashMapT <Tizen::Graphics::Rectangle,FacialExpression>, CollectionAllElementDeleter>
- pDetectList (new (std::nothrow) HashMapT <Tizen::Graphics::Rectangle, FacialExpression>);
+ std::unique_ptr< Tizen::Base::Collection::HashMapT< Tizen::Graphics::Rectangle, FacialExpression >, CollectionAllElementDeleter >
+ pDetectList(new (std::nothrow) HashMapT< Tizen::Graphics::Rectangle, FacialExpression >);
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ std::unique_ptr< unsigned char > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.",
+ GetErrorMessage(E_OUT_OF_MEMORY));
+
pRectProvider = pUniqRectProvider.get();
SysTryCatch(NID_UIX, pRectProvider != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
pRectComparer = pUniqRectComparer.get();
SysTryCatch(NID_UIX, pRectComparer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct(0, 0, *pRectProvider, *pRectComparer);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
if (format == BITMAP_PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
- pImageBuffer = (unsigned char*)byteBuffer.GetPointer();
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height * 2), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
else if (format == BITMAP_PIXEL_FORMAT_ARGB8888)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- std::unique_ptr<unsigned char[]> pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
- SysTryCatch(NID_UIX, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- pImageBuffer = pBuffer.get();
- SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer.",
- GetErrorMessage(E_OUT_OF_MEMORY));
- ConvertArgb8888ToGray(*((unsigned char*)byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
- engineErr = face_image_create(imageColorspace, pImageBuffer, resolution.width, resolution.height,
- (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceUtil->ConvertArgb8888ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, __maxFacesImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, __scaleImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_IMAGE_FACE))
+ {
+ retVal = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- for (int i = 0; i < faceCount; ++i)
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- engineErr = face_extract_component(faceHandle, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+
+ retVal = caApp_RunMouthDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- engineErr = face_recognize_expression(faceHandle, faceImage, faceComponent, &faceExpr);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to recognize the expression.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunFERDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, true);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
FacialExpression expression = FACIAL_EXPRESSION_NONE;
- switch(faceExpr)
+ switch (*(__pFaceEngineInfo->g_Expression[i]))
{
case FACE_EXPRESSION_NUETRAL:
expression = FACIAL_EXPRESSION_NEUTRAL;
break;
+
case FACE_EXPRESSION_ANGRY:
expression = FACIAL_EXPRESSION_ANGRY;
break;
+
case FACE_EXPRESSION_SMILE:
expression = FACIAL_EXPRESSION_HAPPY;
break;
+
case FACE_EXPRESSION_SURPRISE:
expression = FACIAL_EXPRESSION_SURPRISED;
break;
+
case FACE_EXPRESSION_UNKNOWN:
expression = FACIAL_EXPRESSION_NONE;
break;
+
default:
break;
}
- Rectangle rect(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+ Rectangle rect(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y, __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
r = pDetectList->Add(rect, expression);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- face_component_destroy(faceComponent);
- faceComponent = null;
}
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
+
+ ReleaseFaceEngine();
return pDetectList.release();
CATCH:
- if (faceComponent != null)
- {
- face_component_destroy(faceComponent);
- }
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - CATCH _FaceRecognizerImpl::RecognizeExpressionsFromBitmapN-");
+ ReleaseFaceEngine();
SetLastResult(r);
- return null;
+ pDetectList->RemoveAll();
+ return pDetectList.release();
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >*
_FaceRecognizerImpl::DetectBlinksFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- const Tizen::Graphics::PixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ const Tizen::Graphics::PixelFormat format)
{
ClearLastResult();
result r = E_SUCCESS;
+ int retValue = 0;
+ unsigned char* pImageBuffer = null;
- int engineErr = 0;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_eye_state_e leftEye;
- face_eye_state_e rightEye;
-
- IHashCodeProviderT <Tizen::Graphics::Rectangle>* pRectProvider = null;
- std::unique_ptr<_RectHashCodeProvider> pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
+ IHashCodeProviderT< Tizen::Graphics::Rectangle >* pRectProvider = null;
+ std::unique_ptr< _RectHashCodeProvider > pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
SysTryReturn(NID_UIX, pUniqRectProvider != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- IComparerT <Tizen::Graphics::Rectangle>* pRectComparer = null;
- std::unique_ptr<_RectComparerT> pUniqRectComparer(new (std::nothrow) _RectComparerT);
+ IComparerT< Tizen::Graphics::Rectangle >* pRectComparer = null;
+ std::unique_ptr< _RectComparerT > pUniqRectComparer(new (std::nothrow) _RectComparerT);
SysTryReturn(NID_UIX, pUniqRectComparer != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- std::unique_ptr<Tizen::Base::Collection::HashMapT <Tizen::Graphics::Rectangle,EyeState>, CollectionAllElementDeleter>
- pDetectList (new (std::nothrow) HashMapT <Tizen::Graphics::Rectangle, EyeState>);
+ std::unique_ptr< Tizen::Base::Collection::HashMapT< Tizen::Graphics::Rectangle, EyeState >, CollectionAllElementDeleter >
+ pDetectList(new (std::nothrow) HashMapT< Tizen::Graphics::Rectangle, EyeState >);
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+
pRectProvider = pUniqRectProvider.get();
SysTryCatch(NID_UIX, pRectProvider != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
pRectComparer = pUniqRectComparer.get();
SysTryCatch(NID_UIX, pRectComparer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct(0, 0, *pRectProvider, *pRectComparer);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
if (format == PIXEL_FORMAT_YCbCr420_PLANAR)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
+ pImageBuffer = (unsigned char*) byteBuffer.GetPointer();
}
else if (format == PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- engineErr = face_attr_set_max_number_faces(__faceHandleVideoMode, __maxFacesVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(__faceHandleVideoMode, __scaleVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_VIDEO_BLINK))
+ {
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesVideo, _FT_INTERVAL_DEFAULT);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ }
- engineErr = face_image_create(imageColorspace, (unsigned char*)byteBuffer.GetPointer(), resolution.width,
- resolution.height, (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - REACH 001");
- engineErr = face_detect_faces(__faceHandleVideoMode, FACE_IMAGE_TYPE_CONTINUOUS, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - REACH 002 __pFaceEngineInfo->g_iFaceDetectNum = %d", __pFaceEngineInfo->g_iFaceDetectNum);
- for (int i = 0; i < faceCount; ++i)
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
{
- engineErr = face_extract_component(__faceHandleVideoMode, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- engineErr = face_recognize_blink(__faceHandleVideoMode, faceImage, faceComponent, &leftEye, &rightEye);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to recognize the eye state.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunBlinkDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, true);
+ //retValue = caApp_RunBlinkDetectionSingleFace(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i, true);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
EyeState eyeState;
- if((leftEye == FACE_EYE_STATE_OPENED) && (rightEye == FACE_EYE_STATE_OPENED))
+
+ if (*(__pFaceEngineInfo->g_Blink[i]) == 0)
{
eyeState = EYE_STATE_BOTH_OPEN;
}
- else if((leftEye == FACE_EYE_STATE_CLOSED) && (rightEye == FACE_EYE_STATE_CLOSED))
+ else if (*(__pFaceEngineInfo->g_Blink[i]) == 3)
{
eyeState = EYE_STATE_BOTH_CLOSED;
}
eyeState = EYE_STATE_NONE;
}
- Rectangle rect(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+ Rectangle rect(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
r = pDetectList->Add(rect, eyeState);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- face_component_destroy(faceComponent);
}
- free(pFaceRects);
- face_image_destroy(faceImage);
return pDetectList.release();
CATCH:
- free(pFaceRects);
- face_image_destroy(faceImage);
-
+ pDetectList->RemoveAll();
SetLastResult(r);
- return null;
+ return pDetectList.release();
}
-Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>*
+Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >*
_FaceRecognizerImpl::RecognizeExpressionsFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer,
- const Tizen::Graphics::Dimension& resolution,
- const Tizen::Graphics::PixelFormat format)
+ const Tizen::Graphics::Dimension& resolution,
+ const Tizen::Graphics::PixelFormat format)
{
+ static bool ExpressionStateFirst = true;
ClearLastResult();
result r = E_SUCCESS;
+ int retValue = 0;
+ unsigned char* pImageBuffer = null;
- int engineErr = 0;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_expression_e faceExpr;
-
- IHashCodeProviderT <Tizen::Graphics::Rectangle>* pRectProvider = null;
- std::unique_ptr<_RectHashCodeProvider> pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
+ IHashCodeProviderT< Tizen::Graphics::Rectangle >* pRectProvider = null;
+ std::unique_ptr< _RectHashCodeProvider > pUniqRectProvider(new (std::nothrow) _RectHashCodeProvider);
SysTryReturn(NID_UIX, pUniqRectProvider != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- IComparerT <Tizen::Graphics::Rectangle>* pRectComparer = null;
- std::unique_ptr<_RectComparerT> pUniqRectComparer(new (std::nothrow) _RectComparerT);
+ IComparerT< Tizen::Graphics::Rectangle >* pRectComparer = null;
+ std::unique_ptr< _RectComparerT > pUniqRectComparer(new (std::nothrow) _RectComparerT);
SysTryReturn(NID_UIX, pUniqRectComparer != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- std::unique_ptr<Tizen::Base::Collection::HashMapT <Tizen::Graphics::Rectangle, FacialExpression>, CollectionAllElementDeleter>
- pDetectList (new (std::nothrow) HashMapT <Tizen::Graphics::Rectangle, FacialExpression>);
+ std::unique_ptr< Tizen::Base::Collection::HashMapT< Tizen::Graphics::Rectangle, FacialExpression >, CollectionAllElementDeleter >
+ pDetectList(new (std::nothrow) HashMapT< Tizen::Graphics::Rectangle, FacialExpression >);
SysTryReturn(NID_UIX, pDetectList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
- GetErrorMessage(E_OUT_OF_MEMORY));
+ GetErrorMessage(E_OUT_OF_MEMORY));
+
+ std::unique_ptr< unsigned char[] > pBuffer(new (std::nothrow) unsigned char[resolution.width * resolution.height]);
+ SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
pRectProvider = pUniqRectProvider.get();
SysTryCatch(NID_UIX, pRectProvider != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
pRectComparer = pUniqRectComparer.get();
SysTryCatch(NID_UIX, pRectComparer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Failed to create the IMapT.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pDetectList->Construct(0, 0, *pRectProvider, *pRectComparer);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
if (format == PIXEL_FORMAT_YCbCr420_PLANAR)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_YUV420;
+ pImageBuffer = (unsigned char*) byteBuffer.GetPointer();
}
else if (format == PIXEL_FORMAT_RGB565)
{
- imageColorspace = FACE_IMAGE_COLORSPACE_RGB565;
+ pImageBuffer = pBuffer.get();
+ SysTryCatch(NID_UIX, pImageBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_OUT_OF_MEMORY));
+ __pFaceUtil->ConvertRgb565ToGray(*((unsigned char*) byteBuffer.GetPointer()), pImageBuffer, resolution.width, resolution.height);
}
- engineErr = face_attr_set_max_number_faces(__faceHandleVideoMode, __maxFacesVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(__faceHandleVideoMode, __scaleVideo);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_image_create(imageColorspace, (unsigned char*)byteBuffer.GetPointer(), resolution.width,
- resolution.height, (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_detect_faces(__faceHandleVideoMode, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
-
- for (int i = 0; i < faceCount; ++i)
+ if (ToBeInitialized(__FACERECOGNIZE_MODE_VIDEO_BLINK))
{
- engineErr = face_extract_component(__faceHandleVideoMode, faceImage, &pFaceRects[i], &faceComponent);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfo, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesVideo, 25);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ ExpressionStateFirst = false;
+ }
- engineErr = face_recognize_expression(__faceHandleVideoMode, faceImage, faceComponent, &faceExpr);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to recognize the expression.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_RunFaceDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ //SysLogException(NID_UIX, E_SUCCESS, "XXXX - Entering RecognizeExpressionsFromBufferN faces= %d",__pFaceEngineInfo->g_iFaceDetectNum);
+ for (int i = 0; i < __pFaceEngineInfo->g_iFaceDetectNum; i++)
+ {
+ retValue = caApp_RunEyeDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - REACH 003");
+ retValue = caApp_RunMouthDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, i);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - REACH 004");
+
+ retValue = caApp_RunFERDetection(pImageBuffer, resolution.width, resolution.height, __pFaceEngineInfo, true);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - REACH 005");
FacialExpression expression = FACIAL_EXPRESSION_NONE;
- switch(faceExpr)
+ switch (*(__pFaceEngineInfo->g_Expression[i]))
{
- case FACE_EXPRESSION_NUETRAL:
+ case EXP_NUETRAL:
expression = FACIAL_EXPRESSION_NEUTRAL;
break;
- case FACE_EXPRESSION_ANGRY:
+ case EXP_ANGRY:
expression = FACIAL_EXPRESSION_ANGRY;
break;
- case FACE_EXPRESSION_SMILE:
+ case EXP_SMILE:
expression = FACIAL_EXPRESSION_HAPPY;
break;
- case FACE_EXPRESSION_SURPRISE:
+ case EXP_SURPRISE:
expression = FACIAL_EXPRESSION_SURPRISED;
break;
- case FACE_EXPRESSION_UNKNOWN:
- expression = FACIAL_EXPRESSION_NONE;
- break;
-
default:
+ expression = FACIAL_EXPRESSION_NONE;
break;
}
- Rectangle rect(pFaceRects[i].x, pFaceRects[i].y, pFaceRects[i].w, pFaceRects[i].h);
+
+ Rectangle rect(__pFaceEngineInfo->g_FaceROI[i].x, __pFaceEngineInfo->g_FaceROI[i].y,
+ __pFaceEngineInfo->g_FaceROI[i].width, __pFaceEngineInfo->g_FaceROI[i].height);
r = pDetectList->Add(rect, expression);
SysTryCatch(NID_UIX, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- face_component_destroy(faceComponent);
- faceComponent = null;
}
- free(pFaceRects);
- face_image_destroy(faceImage);
return pDetectList.release();
-CATCH:
- if (faceComponent != null)
- {
- face_component_destroy(faceComponent);
- faceComponent = null;
- }
-
- free(pFaceRects);
- face_image_destroy(faceImage);
+CATCH:
+ //SysLogException(NID_UIX, r, "XXXX -CATCH _FaceRecognizerImpl::RecognizeExpressionsFromBufferN-");
+ pDetectList->RemoveAll();
SetLastResult(r);
- return null;
+ return pDetectList.release();
}
Tizen::Base::ByteBuffer*
{
ClearLastResult();
result r = E_SUCCESS;
-
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- face_rect_s interestFaceRect;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_feature_h faceFeature = null;
- unsigned char *pFeatureBuffer = null;
int featureLength = 0;
+ int retValue = 0;
+ int isValidFREngine = 0;
+ long* pFaceData = null;
+ FaceEngineInfo* __pFaceEngineInfoTemp = null;
- std::unique_ptr<ByteBuffer> pBuffer(new (std::nothrow) Tizen::Base::ByteBuffer());
- SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
- GetErrorMessage(E_OUT_OF_MEMORY));
+ std::unique_ptr< ByteBuffer > pBuffer(new (std::nothrow) Tizen::Base::ByteBuffer());
+ SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- interestFaceRect.x = faceRect.x;
- interestFaceRect.y = faceRect.y;
- interestFaceRect.w = faceRect.width;
- interestFaceRect.h = faceRect.height;
+ std::unique_ptr< FaceEngineInfo > pFaceEngineInfo(new (std::nothrow) FaceEngineInfo);
- engineErr = face_image_create(imageColorspace, (unsigned char*)grayBuffer.GetPointer(), resolution.width,
- resolution.height, (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ __pFaceEngineInfoTemp = pFaceEngineInfo.release();
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
+ retValue = caApp_FaceEngineInit(__pFaceEngineInfoTemp, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, 20);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_max_number_faces(faceHandle, _FaceDetectorImpl::__maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, _FaceDetectorImpl::__scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ __pFaceEngineInfoTemp->g_FaceROI[0].x = faceRect.x;
+ __pFaceEngineInfoTemp->g_FaceROI[0].y = faceRect.y;
+ __pFaceEngineInfoTemp->g_FaceROI[0].width = faceRect.width;
+ __pFaceEngineInfoTemp->g_FaceROI[0].height = faceRect.height;
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
+ //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));
- engineErr = face_extract_component(faceHandle, faceImage, &interestFaceRect, &faceComponent);
+ featureLength = caApp_FtsExVecLength();
+ SysTryCatch(NID_UIX, featureLength > 0, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
- if(engineErr != FACE_ERROR_NONE)
- {
- engineErr = face_attr_set_detect_mode(faceHandle, FACE_DETECT_MODE_ROBUST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to ROBUST",
- GetErrorMessage(E_FAILURE));
-
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face at ROBUST mode",
- GetErrorMessage(E_FAILURE));
-
- engineErr = face_extract_component(faceHandle, faceImage, &interestFaceRect, &faceComponent);
- }
+ pFaceData = caApp_FtsExGetFeatureVector((unsigned char*) grayBuffer.GetPointer(), resolution.width, resolution.height, __pFaceEngineInfoTemp, 0);
+ SysTryCatch(NID_UIX, pFaceData != null, r = E_FAILURE, E_FAILURE, "[%s] Failed caApp_FtsExInit", GetErrorMessage(E_FAILURE));
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_extract_feature(faceHandle, faceImage, faceComponent, &faceFeature);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the feature.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_feature_get_data(faceFeature, &pFeatureBuffer, &featureLength);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to get the feature data.", GetErrorMessage(E_FAILURE));
-
- r = pBuffer->Construct(featureLength * sizeof(unsigned char));
+ r = pBuffer->Construct(featureLength * sizeof(long));
SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to construct Bytebuffer.", GetErrorMessage(E_FAILURE));
- r = pBuffer->SetArray((byte*)pFeatureBuffer, 0, featureLength * sizeof(unsigned char));
+ r = pBuffer->SetArray((byte*) pFaceData, 0, featureLength * sizeof(long));
SysTryCatch(NID_UIX, r == E_SUCCESS, r = E_FAILURE, r, "[%s] Failed to set the array.", GetErrorMessage(E_FAILURE));
- face_component_destroy(faceComponent);
- face_feature_destroy(faceFeature);
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
+ caApp_FtsExRelease();
- return pBuffer.release();
+ retValue = caApp_FaceEngineRelease(__pFaceEngineInfoTemp);
+ SysTryCatch(NID_UIX, retValue == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to delete FaceEngine.", GetErrorMessage(E_FAILURE));
+ return pBuffer.release();
CATCH:
- face_component_destroy(faceComponent);
- face_feature_destroy(faceFeature);
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - CATCH _FaceRecognizerImpl::ExtractFeatureN-");
+ caApp_FtsExRelease();
+ caApp_FaceEngineRelease(__pFaceEngineInfoTemp);
SetLastResult(r);
return null;
}
EyeState
_FaceRecognizerImpl::DetectEyeState(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;
EyeState eyeState = EYE_STATE_NONE;
+ int retVal = 0;
+ FaceEngineInfo* __pFaceEngineInfoTemp = null;
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- face_rect_s interestFaceRect;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_eye_state_e leftEye;
- face_eye_state_e rightEye;
-
- interestFaceRect.x = faceRect.x;
- interestFaceRect.y = faceRect.y;
- interestFaceRect.w = faceRect.width;
- interestFaceRect.h = faceRect.height;
-
- engineErr = face_image_create(imageColorspace, (unsigned char*)grayBuffer.GetPointer(), resolution.width,
- resolution.height, (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
+ //Way to get the index is to loop for all rects and get the index..
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
+ std::unique_ptr< FaceEngineInfo > pFaceEngineInfo(new (std::nothrow) FaceEngineInfo);
+ __pFaceEngineInfoTemp = pFaceEngineInfo.release();
- engineErr = face_attr_set_max_number_faces(faceHandle, _FaceDetectorImpl::__maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, _FaceDetectorImpl::__scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
+ caApp_FaceEngineInit(__pFaceEngineInfoTemp, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, 20);
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_extract_component(faceHandle, faceImage, &interestFaceRect, &faceComponent);
-
- if(engineErr != FACE_ERROR_NONE)
- {
- engineErr = face_attr_set_detect_mode(faceHandle, FACE_DETECT_MODE_ROBUST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to ROBUST",
- GetErrorMessage(E_FAILURE));
-
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face at ROBUST mode",
- GetErrorMessage(E_FAILURE));
-
- engineErr = face_extract_component(faceHandle, faceImage, &interestFaceRect, &faceComponent);
- }
+ __pFaceEngineInfoTemp->g_FaceROI[0].x = faceRect.x;
+ __pFaceEngineInfoTemp->g_FaceROI[0].y = faceRect.y;
+ __pFaceEngineInfoTemp->g_FaceROI[0].width = faceRect.width;
+ __pFaceEngineInfoTemp->g_FaceROI[0].height = faceRect.height;
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ __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;
- engineErr = face_recognize_blink(faceHandle, faceImage, faceComponent, &leftEye, &rightEye);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to recognize the eye state.", GetErrorMessage(E_FAILURE));
+ retVal = caApp_RunBlinkDetection((unsigned char*) grayBuffer.GetPointer(), resolution.width, resolution.height, __pFaceEngineInfoTemp, true);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
- if((leftEye == FACE_EYE_STATE_OPENED) && (rightEye == FACE_EYE_STATE_OPENED))
+ if (*(__pFaceEngineInfoTemp->g_Blink[0]) == 0)
{
eyeState = EYE_STATE_BOTH_OPEN;
}
- else if((leftEye == FACE_EYE_STATE_CLOSED) && (rightEye == FACE_EYE_STATE_CLOSED))
+ else if (*(__pFaceEngineInfoTemp->g_Blink[0]) == 3)
{
eyeState = EYE_STATE_BOTH_CLOSED;
}
{
eyeState = EYE_STATE_NONE;
}
- face_component_destroy(faceComponent);
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
- return eyeState;
+ retVal = caApp_FaceEngineRelease(__pFaceEngineInfoTemp);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to delete FaceEngine.", GetErrorMessage(E_FAILURE));
+ return eyeState;
CATCH:
- face_component_destroy(faceComponent);
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX - CATCH _FaceRecognizerImpl::DetectEyeState");
+ caApp_FaceEngineRelease(__pFaceEngineInfoTemp);
SetLastResult(r);
- return eyeState;
+ return EYE_STATE_NONE;
}
FacialExpression
_FaceRecognizerImpl::RecognizeExpression(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution,
- const Tizen::Graphics::Rectangle& faceRect)
+ const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Rectangle& mouthRect)
{
ClearLastResult();
result r = E_SUCCESS;
+ int retVal = 0;
FacialExpression expression = FACIAL_EXPRESSION_NONE;
- int engineErr = 0;
- face_h faceHandle = null;
- face_image_colorspace_e imageColorspace = FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY;
- face_image_h faceImage = null;
- face_rect_s* pFaceRects = null;
- face_rect_s interestFaceRect;
- int faceCount = 0;
- face_component_h faceComponent = null;
- face_expression_e faceExpr;
-
- interestFaceRect.x = faceRect.x;
- interestFaceRect.y = faceRect.y;
- interestFaceRect.w = faceRect.width;
- interestFaceRect.h = faceRect.height;
-
- engineErr = face_image_create(imageColorspace, (unsigned char*)grayBuffer.GetPointer(), resolution.width,
- resolution.height, (resolution.width * resolution.height), &faceImage);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceImage.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_create(&faceHandle);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the faceHandle.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_attr_set_max_number_faces(faceHandle, _FaceDetectorImpl::__maxFacesAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
- engineErr = face_attr_set_scale_factor(faceHandle, _FaceDetectorImpl::__scaleAtomic);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set the property.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face.", GetErrorMessage(E_FAILURE));
-
- engineErr = face_extract_component(faceHandle, faceImage, &interestFaceRect, &faceComponent);
-
- if(engineErr != FACE_ERROR_NONE)
- {
- engineErr = face_attr_set_detect_mode(faceHandle, FACE_DETECT_MODE_ROBUST);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to set detect mode to ROBUST",
- GetErrorMessage(E_FAILURE));
-
- engineErr = face_detect_faces(faceHandle, FACE_IMAGE_TYPE_SINGLE, faceImage, &pFaceRects, &faceCount);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to detect the Face at ROBUST mode",
- GetErrorMessage(E_FAILURE));
-
- engineErr = face_extract_component(faceHandle, faceImage, &interestFaceRect, &faceComponent);
- }
-
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to extract the components.", GetErrorMessage(E_FAILURE));
+ FaceEngineInfo* __pFaceEngineInfoTemp = null;
+
+ std::unique_ptr< FaceEngineInfo > pFaceEngineInfo(new (std::nothrow) FaceEngineInfo);
+
+ __pFaceEngineInfoTemp = pFaceEngineInfo.release();
+
+ caApp_FaceEngineInit(__pFaceEngineInfoTemp, FD_MODE_ROLx_YAWx, FD_SIZE_COVERAGE_HIGH, __maxFacesImage, 20);
- engineErr = face_recognize_expression(faceHandle, faceImage, faceComponent, &faceExpr);
- SysTryCatch(NID_UIX, engineErr == FACE_ERROR_NONE, r = E_FAILURE, E_FAILURE, "[%s] Failed to recognize the eye state.", GetErrorMessage(E_FAILURE));
+ __pFaceEngineInfoTemp->g_FaceROI[0].x = faceRect.x;
+ __pFaceEngineInfoTemp->g_FaceROI[0].y = faceRect.y;
+ __pFaceEngineInfoTemp->g_FaceROI[0].width = faceRect.width;
+ __pFaceEngineInfoTemp->g_FaceROI[0].height = faceRect.height;
- switch(faceExpr)
+ __pFaceEngineInfoTemp->g_MouthROI[0].x = mouthRect.x;
+ __pFaceEngineInfoTemp->g_MouthROI[0].y = mouthRect.y;
+ __pFaceEngineInfoTemp->g_MouthROI[0].width = mouthRect.width;
+ __pFaceEngineInfoTemp->g_MouthROI[0].height = mouthRect.height;
+
+ retVal = caApp_RunFERDetection((unsigned char*) grayBuffer.GetPointer(), resolution.width, resolution.height, __pFaceEngineInfoTemp, true);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_RETURN_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to create the Buffer."
+ , GetErrorMessage(E_FAILURE));
+
+ switch (*(__pFaceEngineInfoTemp->g_Expression[0]))
{
case FACE_EXPRESSION_NUETRAL:
expression = FACIAL_EXPRESSION_NEUTRAL;
break;
}
- face_component_destroy(faceComponent);
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
+ retVal = caApp_FaceEngineRelease(__pFaceEngineInfoTemp);
+ SysTryCatch(NID_UIX, retVal == _FACEENGINE_INIT_SUCCESS, r = E_FAILURE, E_FAILURE, "[%s] Failed to delete FaceEngine.", GetErrorMessage(E_FAILURE));
return expression;
-
CATCH:
- face_component_destroy(faceComponent);
- free(pFaceRects);
- face_image_destroy(faceImage);
- face_destroy(faceHandle);
-
+ SysLogException(NID_UIX, E_SUCCESS, "XXXX -CATCH _FaceRecognizerImpl::RecognizeExpression");
+ caApp_FaceEngineRelease(__pFaceEngineInfoTemp);
SetLastResult(r);
- return expression;
-}
-
-void
-_FaceRecognizerImpl::ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height)
-{
- SysAssert(pGrayBuf != null);
- if (pGrayBuf == null)
- {
- return;
- }
- unsigned long* pSrc = (unsigned long*) &buf;
- unsigned char* pDSt = (unsigned char*) pGrayBuf;
- unsigned char* pEnd = pDSt + height * width;
-
- while (pDSt < pEnd)
- {
- unsigned long r = (*pSrc >> 16) & 0xFF;
- unsigned long g = (*pSrc >> 8) & 0xFF;
- unsigned long b = (*pSrc++) & 0xFF;
-
- *pDSt++ = (308 * r + 600 * g + 116 * b) >> 10;
- }
+ return FACIAL_EXPRESSION_NONE;
}
-void
-_FaceRecognizerImpl::ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, face_rect_s* pFaceRects)
-{
- // no need to convert if both are same
- if (bufferWidth == bitmapWidth || bufferHeight == bitmapHeight)
- {
- return;
- }
-
- // Avoid 'division by zero'
- if (bufferWidth <= 0 || bufferHeight <= 0)
- {
- return;
- }
-
- // convert physical coordinate to virtual coordinate
- int x1 = pFaceRects->x;
- int x2 = x1 + pFaceRects->w;
- int y1 = pFaceRects->y;
- int y2 = y1 + pFaceRects->h;
-
- x1 = x1 * bitmapWidth / bufferWidth;
- x2 = x2 * bitmapWidth / bufferWidth;
- y1 = y1 * bitmapHeight / bufferHeight;
- y2 = y2 * bitmapHeight / bufferHeight;
-
- pFaceRects->x = x1;
- pFaceRects->y = y1;
- pFaceRects->w = x2 - x1;
- pFaceRects->h = y2 - y1;
-
- return;
-}
_FaceRecognizerImpl*
_FaceRecognizerImpl::GetInstance(FaceRecognizer* pFaceRecognizer)
#include <FGrpRectangle.h>
#include <FUixVisionFaceTypes.h>
#include <FUixVisionFaceRecognizer.h>
-#include <face.h>
+#include "caFaceAPP_interface.h"
+#include "FUixVision_FaceUtil.h"
struct CollectionAllElementDeleter
{
- template<typename Collection>
- void operator()(Collection* c)
- {
+ template< typename Collection >
+ void operator ()(Collection* c)
+ {
c->RemoveAll();
delete c;
- }
+ }
};
namespace Tizen { namespace Uix { namespace Vision
{
+typedef enum
+{
+ __FACERECOGNIZE_MODE_UNINITIALIZED = 0x100,
+ __FACERECOGNIZE_MODE_IMAGE_FACE,
+ __FACERECOGNIZE_MODE_VIDEO_FACE,
+ __FACERECOGNIZE_MODE_VIDEO_BLINK,
+ __FACERECOGNIZE_MODE_VIDEO_EXPRESSION
+}FaceRecognizeMode;
+
class _FaceRecognizerImpl
: public Tizen::Base::Object
{
* @exception E_SUCCESS - This method is successful.
* @exception E_OUT_OF_MEMORY - Failed to allocate required/requested memory.
*/
- Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* GetSupportedFormatListN(void) const;
+ Tizen::Base::Collection::IListT< Tizen::Graphics::PixelFormat >* GetSupportedFormatListN(void) const;
/**
* Extracts the facial template that represents the face from the video image.
* @exception E_FAILURE A system error occurred.
* @see EyeState
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>* DetectBlinksFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, Tizen::Graphics::BitmapPixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >* DetectBlinksFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, Tizen::Graphics::BitmapPixelFormat format);
/**
* @exception E_FAILURE A system error occurred.
* @see EyeState
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, EyeState>* DetectBlinksFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::PixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, EyeState >* DetectBlinksFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::PixelFormat format);
/**
* Extracts the facial expression the face from the still image.
* @exception E_FAILURE A system error occurred.
* @see FacialExpression
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>* RecognizeExpressionsFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, Tizen::Graphics::BitmapPixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >* RecognizeExpressionsFromBitmapN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, Tizen::Graphics::BitmapPixelFormat format);
/**
* Extracts the facial expression from the video image.
* @exception E_FAILURE A system error occurred.
* @see EyeState
*/
- Tizen::Base::Collection::IMapT <Tizen::Graphics::Rectangle, FacialExpression>* RecognizeExpressionsFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::PixelFormat format);
+ Tizen::Base::Collection::IMapT< Tizen::Graphics::Rectangle, FacialExpression >* RecognizeExpressionsFromBufferN(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::PixelFormat format);
/**
* Extracts the facial template that represents the face
* This is the result of a normal operation. @n
* @see EyeState
*/
- EyeState DetectEyeState(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect);
+ EyeState DetectEyeState(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 facial expression.
* This is the result of a normal operation. @n
* @see FacialExpression
*/
- FacialExpression RecognizeExpression(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect);
+ FacialExpression RecognizeExpression(const Tizen::Base::ByteBuffer& grayBuffer, const Tizen::Graphics::Dimension& resolution, const Tizen::Graphics::Rectangle& faceRect, Tizen::Graphics::Rectangle& mouthRect);
static _FaceRecognizerImpl* GetInstance(FaceRecognizer* pFaceRecognizer);
static const _FaceRecognizerImpl* GetInstance(const FaceRecognizer* pFaceRecognizer);
*/
_FaceRecognizerImpl(const _FaceRecognizerImpl& faceImpl);
+ void ConvertRgb565ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height);
void ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height);
- void ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, face_rect_s* pFaceRects);
-
+ void ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, Tizen::Graphics::Rectangle* pRect);
+ bool ToBeInitialized(FaceRecognizeMode currMode);
+ bool ReleaseFaceEngine();
private:
long __scaleVideo;
long __scaleImage;
long __maxFacesVideo;
long __maxFacesImage;
- face_h __faceHandleVideoMode;
+ FaceEngineInfo* __pFaceEngineInfo;
+ _FaceUtil* __pFaceUtil;
+ FaceRecognizeMode __prevRecognizeMode;
};
} } } //Tizen::Uix::Vision
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FUixVision_FaceUtil.cpp
+ * @brief This file contains internal implementation of FaceUtil Implementation class.
+ *
+ *
+ * This file contains internal implementation of FaceUtil Implementation class.
+ */
+
+#include <FBaseColLinkedList.h>
+#include <FBaseColHashMapT.h>
+#include <FUixVisionFaceRecognitionInfo.h>
+#include <FBaseSysLog.h>
+#include "FUixVision_FaceUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Uix { namespace Vision
+{
+
+result
+_FaceUtil::Construct(void)
+{
+ return E_SUCCESS;
+}
+
+_FaceUtil::_FaceUtil(void)
+{
+}
+
+_FaceUtil::~_FaceUtil(void)
+{
+
+}
+
+void
+_FaceUtil::ConvertRgb565ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height)
+{
+ unsigned char* pDst = null;
+ unsigned char* pEnd = null;
+ unsigned short* pSrc = null;
+
+ unsigned short r = 0;
+ unsigned short g = 0;
+ unsigned short b = 0;
+ long lt = 0;
+
+ SysAssert(pGrayBuf != null);
+ if (pGrayBuf == null)
+ {
+ return;
+ }
+
+ pSrc = (unsigned short*) &buf;
+ pDst = (unsigned char*) pGrayBuf;
+ pEnd = (unsigned char*) ((unsigned char*) pGrayBuf + height * width);
+
+ while (pDst < pEnd)
+ {
+ r = (unsigned char) ((*pSrc >> 11) << 3); // R
+ g = (unsigned char) ((*pSrc & 0x07e0) >> 3); // +G
+ b = (unsigned char) ((*pSrc++ & 0x001f) << 3); // +B
+
+ // Y = 0.299 R + 0.587 G + 0.114 B
+ lt = (306L * (long) r + 601L * (long) g + 117L * (long) b);
+ *pDst++ = (unsigned char) (lt >> 10);
+ //(BYTE)(((int)R+(int)G+(int)B) /3);
+ }
+}
+
+void
+_FaceUtil::ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height)
+{
+ SysAssert(pGrayBuf != null);
+ if (pGrayBuf == null)
+ {
+ return;
+ }
+ unsigned long* pSrc = (unsigned long*) &buf;
+ unsigned char* pDSt = (unsigned char*) pGrayBuf;
+ unsigned char* pEnd = pDSt + height * width;
+
+ while (pDSt < pEnd)
+ {
+ unsigned long r = (*pSrc >> 16) & 0xFF;
+ unsigned long g = (*pSrc >> 8) & 0xFF;
+ unsigned long b = (*pSrc++) & 0xFF;
+
+ *pDSt++ = (308 * r + 600 * g + 116 * b) >> 10;
+ }
+}
+
+void
+_FaceUtil::ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, Tizen::Graphics::Rectangle* pRect)
+{
+ // no need to convert if both are same
+ if (bufferWidth == bitmapWidth || bufferHeight == bitmapHeight)
+ {
+ return;
+ }
+
+ // Avoid 'division by zero'
+ if (bufferWidth <= 0 || bufferHeight <= 0)
+ {
+ return;
+ }
+
+ // convert physical coordinate to virtual coordinate
+ int x1 = pRect->x;
+ int x2 = x1 + pRect->width;
+ int y1 = pRect->y;
+ int y2 = y1 + pRect->height;
+
+ x1 = x1 * bitmapWidth / bufferWidth;
+ x2 = x2 * bitmapWidth / bufferWidth;
+ y1 = y1 * bitmapHeight / bufferHeight;
+ y2 = y2 * bitmapHeight / bufferHeight;
+
+ pRect->x = x1;
+ pRect->y = y1;
+ pRect->width = x2 - x1;
+ pRect->height = y2 - y1;
+
+ return;
+}
+
+} } } //Tizen::Uix::Vision
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FUixVision_FaceUtil.h
+ * @brief This file contains declaration of the FUixVision_FaceUtil class.
+ *
+ *
+ * This header file contains the declarations of the FUixVision_FaceUtil class.
+ */
+
+#ifndef _FUIX_VISION_INTERNAL_FACE_UTIL_H_
+#define _FUIX_VISION_INTERNAL_FACE_UTIL_H_
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FGrpBitmap.h>
+#include <FGrpBitmapCommon.h>
+#include <FGrpPixelFormat.h>
+#include <FGrpDimension.h>
+#include <FGrpPoint.h>
+#include <FGrpRectangle.h>
+
+namespace Tizen { namespace Uix { namespace Vision
+{
+
+typedef enum
+{
+ FACE_EXPRESSION_UNKNOWN,
+ FACE_EXPRESSION_NUETRAL, /**< Normal expression */
+ FACE_EXPRESSION_ANGRY, /**< Angry expression */
+ FACE_EXPRESSION_SMILE, /**< Cheerful expression */
+ FACE_EXPRESSION_SURPRISE, /**< Suprised expression */
+} face_engine_expression;
+
+/**
+ * @brief Enumerations of the eye state for the FacialEngine API.
+ */
+typedef enum
+{
+ FACE_EYE_UNKNOWN, /**< The no eye state, when the eye detect fails */
+ FACE_EYE_OPENED, /**< The state when eye is opened */
+ FACE_EYE_CLOSED, /**< The state when eye is closed */
+} face_engine_eye;
+
+class _FaceUtil
+ : public Tizen::Base::Object
+{
+
+public:
+ /**
+ * This is the default constructor for this class.
+ * The object is not fully constructed after this constructor is called.
+ * For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ */
+ _FaceUtil(void);
+
+ /**
+ * This is the destructor for this class.
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~_FaceUtil(void);
+
+ result Construct(void);
+
+ /**
+ * Extracts the facial template that represents the face
+ *
+ * @return The facial template that represents the face
+ * @c null, if an exception occurs. @n
+ * @param[in] grayBuffer The buffer containing the input image data
+ * @param[in] resolution The width and height of the input image @n
+ * @param[in] eyeRight The right eye position
+ * @param[in] eyeLeft The left eye position
+ * @exception E_SUCCESS This method is successful.
+ * @exception E_OUT_OF_MEMORY Failed to allocate required/requested memory.
+ * @exception E_FAILURE A system error occurred.
+ * @exception E_OPERATION_FAILED There are no extracted facial information. But there is no error @n
+ * 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
+ */
+ void ConvertRgb565ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height);
+ void ConvertArgb8888ToGray(const unsigned char& buf, unsigned char* pGrayBuf, int width, int height);
+ void ConvertVirtualToPhysicalCoordinates(int bitmapWidth, int bitmapHeight, int bufferWidth, int bufferHeight, Tizen::Graphics::Rectangle* pRect);
+
+private:
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ _FaceUtil& operator =(const _FaceUtil& faceImpl);
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ _FaceUtil(const _FaceUtil& faceImpl);
+
+};
+
+} } } //Tizen::Uix::Vision
+#endif
--- /dev/null
+#ifndef _CA_BASIC_INFO_DEF_H_\r
+#define _CA_BASIC_INFO_DEF_H_\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <math.h>\r
+\r
+#include "caBasicDef_ENUM.h"\r
+\r
+#if !defined(TRUE) || !defined(FALSE)\r
+#define TRUE 1\r
+#define FALSE 0\r
+#endif\r
+\r
+#define caMacro_MIN(v1, v2) (((v1) > (v2)) ? (v2) : (v1))\r
+#define caMacro_MAX(v1, v2) (((v1) < (v2)) ? (v2) : (v1))\r
+#define caMacro_ABS(v) (((v) < 0) ? -(v) : (v))\r
+#define caMacro_SQR(v) ((v) * (v))\r
+#define caMacro_ROUND(v) ((int) ((v) + 0.5))\r
+#define caMacro_TRUNC(v) ((int) (v))\r
+#define caMacro_CLIP255(v) ((v) > 255 ? 255 : (v))\r
+#define caMacro_CLIP0(v) ((v) < 0 ? 0 : (v))\r
+#define caMacro_CLIP0_255(v) (SMCLIP255(SMCLIP0(v)))\r
+#define DIST_L2(x1, y1, x2, y2) (sqrt((double) SQR((x1) - (x2)) + (double) SQR((y1) - (y2))))\r
+\r
+typedef float smSingle, smFloat;\r
+typedef unsigned char smUInt8, smByte, BYTE, smUChar;\r
+typedef unsigned short smUInt16;\r
+typedef short smInt16;\r
+typedef unsigned long smUInt32;\r
+typedef long smInt32;\r
+typedef int smInt;\r
+typedef unsigned int smUInt;\r
+typedef int smBool;\r
+typedef smBool smBOOL;\r
+typedef float smReal;\r
+\r
+#ifndef BOOL\r
+typedef int BOOL;\r
+#endif\r
+\r
+#ifndef true\r
+#define true 1\r
+#endif\r
+\r
+#ifndef false\r
+#define false 0\r
+#endif\r
+\r
+typedef struct caPoint\r
+{\r
+ int x, y;\r
+} caPoint;\r
+typedef caPoint SMyPoint;\r
+\r
+typedef struct caFaceROI\r
+{\r
+ int x, y;\r
+ int width, height;\r
+} caFaceROI;\r
+typedef caFaceROI smFaceRect;\r
+\r
+typedef struct caEyeROI\r
+{\r
+ int lx, ly;\r
+ int rx, ry;\r
+} caEyeROI;\r
+typedef caEyeROI smEyePos;\r
+\r
+typedef struct caMouthROI\r
+{\r
+ int x, y;\r
+ int width, height;\r
+} caMouthROI;\r
+typedef caMouthROI smMouthRect;\r
+\r
+typedef struct caMouthPOS\r
+{\r
+ int lx, ly;\r
+ int rx, ry;\r
+} caMouthPOS;\r
+typedef caMouthPOS smMouthPOS;\r
+\r
+typedef struct caNoseTipPOS\r
+{\r
+ int x, y;\r
+} caNoseTipPOS;\r
+\r
+typedef struct\r
+{\r
+ int x, y;\r
+}SMyPoint2;\r
+\r
+typedef struct\r
+{\r
+ int left, top, right, bottom;\r
+}SMyRect2;\r
+\r
+typedef struct\r
+{\r
+ int w;\r
+ int h;\r
+ int c;\r
+ unsigned char* pData;\r
+} caByteImage;\r
+\r
+typedef struct\r
+{\r
+ int nData[4];\r
+} caVec4i;\r
+\r
+typedef struct\r
+{\r
+ int x, y;\r
+} caVec2i;\r
+\r
+typedef struct\r
+{\r
+ double x, y;\r
+} caVec2f;\r
+\r
+typedef struct\r
+{\r
+ PreviewMode RunMode;\r
+ int FrameOrder;\r
+ unsigned char* pFrameBuf;\r
+}FrameMgr;\r
+\r
+typedef struct\r
+{\r
+ caPoint* faceCenterPt;\r
+ int* iResourceIndex;\r
+ int iFaceDetectedNum;\r
+ int* iSelected;\r
+ caPoint* mouthPt;\r
+ caEyeROI* eyePt;\r
+}FaceSyncInfo;\r
+\r
+typedef struct\r
+{\r
+ BEAUTY_MODE btMode;\r
+ BEAUTY_LEVEL btLevel;\r
+}AppFaceBeautyInfo;\r
+\r
+typedef struct\r
+{\r
+ int iMaxPicNum;\r
+ int* iValidFaceNum;\r
+ int* bp_Blur;\r
+ int** bp_Blink;\r
+ int** bp_Exp;\r
+}AppBestPicInfo;\r
+\r
+typedef struct\r
+{\r
+ int g_SeqMax;\r
+ caEyeROI* g_SeqEye;\r
+ int g_SeqCount;\r
+ int g_SeqIsFixed;\r
+}SequenceInfo;\r
+\r
+typedef struct\r
+{\r
+ int g_iFaceDetectInterval;\r
+ int g_iFaceLimitNum;\r
+ int g_iFaceSize;\r
+ caFDMode g_iFDMode;\r
+ int g_iFaceDetectNum;\r
+\r
+ int* g_FaceConfidence;\r
+ int* g_FaceRIPAngle;\r
+ int* g_FacePyramidLevel;\r
+ int* g_IsValidFace;\r
+ caFaceROI* g_FaceROI;\r
+ caEyeROI* g_EyeROI;\r
+ caMouthROI* g_MouthROI;\r
+ caMouthPOS* g_MouthPOS;\r
+ caPoint* g_MouthPt;\r
+ int** g_Expression;\r
+ int** g_Blink;\r
+\r
+ int* g_coreNeedToContinued;\r
+ int* g_coreFaceIndex;\r
+\r
+ SequenceInfo* g_SequenceInfo;\r
+\r
+ AppFaceBeautyInfo g_AppFBT_Info;\r
+}FaceEngineInfo;\r
+\r
+#define DETECT_PARTIAL_FACE_BOTTOM 1\r
+#define DETECT_PARTIAL_FACE_RIGHT 1\r
+#define DETECT_PARTIAL_FACE_LEFT 1\r
+#define DETECT_PARTIAL_FACE_LEFTDOWN 1\r
+#define DETECT_PARTIAL_FACE_RIGHTDOWN 1\r
+#define DETECT_PARTIAL_FACE_UPPER 1\r
+#define DETECT_PARTIAL_FACE_CENTER 1\r
+#define DETECT_EXTENDED_BUFFER 0\r
+\r
+#define PLATFORM_WINDOW 0\r
+#define PLATFORM_SLP 1\r
+#define PLATFORM_ANDROID 0\r
+#define PLATFORM_BADA 0\r
+\r
+#define SLP_SPEEDVERSION 0\r
+#define ANIMATIONTHEME_ON 1\r
+#define SISO_SUPPORT 0\r
+\r
+#define SUPPORT_VD 0\r
+\r
+#define ANIMATION_INFINITE 999999\r
+#define DET_SEQUENCE 7\r
+#define WINK_RATIO 1.4\r
+#define WINK_MIN_THRESHOLD 13000\r
+#define WINK_MAX_THRESHOLD 14000\r
+#endif\r
--- /dev/null
+#ifndef _CA_BASIC_INFO_DEF_ENUM_H_\r
+#define _CA_BASIC_INFO_DEF_ENUM_H_\r
+\r
+typedef enum\r
+{\r
+ FD_MODE_ROLx_YAWx = 0x01,\r
+ FD_MODE_ROLx_YAWo = 0x02,\r
+ FD_MODE_ROLo_YAWo = 0x03,\r
+ FD_MODE_ROLo_YAWx = 0x04,\r
+}caFDMode;\r
+\r
+typedef enum\r
+{\r
+ FD_SIZE_COVERAGE_VT_CALL = 0x00,\r
+ FD_SIZE_COVERAGE_LOW = 0x01,\r
+ FD_SIZE_COVERAGE_MID = 0x02,\r
+ FD_SIZE_COVERAGE_HIGH = 0x03,\r
+}caFDSizeCoverage;\r
+\r
+typedef enum\r
+{\r
+ FR_MODE_CGL = 0x01,\r
+ FR_MODE_GBL = 0x02,\r
+ FR_MODE_MSL = 0x03,\r
+ FR_MODE_CGL_MSL = 0x04,\r
+ FR_MODE_GBL_MSL = 0x05,\r
+ FR_MODE_MPL2 = 0x06,\r
+ FR_MODE_MPL2_MSL = 0x07,\r
+ FR_MODE_ULBP = 0x08,\r
+}caFRMode;\r
+\r
+typedef enum\r
+{\r
+ RM_FD_FAIL = 0x0001,\r
+ RM_ED_FAIL = 0x0002,\r
+ RM_ET_FAIL = 0x0003,\r
+ RM_FT_FAIL = 0x0004,\r
+ RM_MD_FAIL = 0x0005,\r
+\r
+ RM_FD_SUCCESS = 0x0010,\r
+ RM_ED_SUCCESS = 0x0020,\r
+ RM_FT_SUCCESS = 0x0030,\r
+ RM_MD_SUCCESS = 0x0040,\r
+\r
+ RM_FER_VIEW_MODE = 0x0000,\r
+ RM_FD_INIT_FAIL = 0x1000,\r
+ RM_ED_INIT_FAIL = 0x2000,\r
+\r
+ RM_BACK_NORMAL = 0x0100,\r
+ RM_BACK_VERYHIGH = 0x0200,\r
+ RM_BACK_HIGH = 0x0300,\r
+ RM_BACK_LOW = 0x0400,\r
+ RM_BACK_VERYLOW = 0x0500,\r
+}RetMessage;\r
+\r
+\r
+typedef enum\r
+{\r
+ PREV_MODE_FACE_DETECTION,\r
+ PREV_MODE_FACE_TRACKING,\r
+ PREV_MODE_FACE_EXTRACTION,\r
+ PREV_MODE_EYE_DETECTION,\r
+ PREV_MODE_EYE_TRACKING,\r
+ PREV_MODE_BYPASS,\r
+}PreviewMode;\r
+\r
+typedef enum\r
+{\r
+ FDT_INIT = 0x00,\r
+ FDT_SAME = 0x01,\r
+ FDT_INCREASE = 0x02,\r
+ FDT_DECREASE = 0x03\r
+}FaceDetectTrend;\r
+\r
+typedef enum\r
+{\r
+ ETM_FACEDETECTED = 0x10,\r
+ ETM_EYEDETECTED = 0x20,\r
+ ETM_NONEDETECTED = 0x30,\r
+}EyeTraceMode;\r
+typedef enum\r
+{\r
+ MSG_FT_SUCCESS = 0x01,\r
+ MSG_FT_ALL_FACE_MISS = 0x02,\r
+ MSG_FT_SOME_FACE_MISS = 0x03,\r
+\r
+ MSG_FD_SUCCESS_FIRST = 0x11,\r
+ MSG_FD_SUCCESS = 0x12,\r
+ MSG_FD_FAIL = 0x13,\r
+ MSG_FD_ONGOING = 0x14,\r
+}PreviewStateMsg;\r
+\r
+typedef enum\r
+{\r
+ MD_MODE_RECT = 0x01,\r
+ MD_MODE_POINT = 0x02,\r
+ MD_MODE_BOTH = 0x03,\r
+}MD_DETECTION_MODE;\r
+\r
+typedef enum\r
+{\r
+ FT_MODE_1_DIRECTION = 0x00,\r
+ FT_MODE_3_DIRECTION = 0x02,\r
+ FT_MODE_4_DIRECTION = 0x03,\r
+}FACE_TRACKING_MODE;\r
+\r
+typedef enum\r
+{\r
+ FBT_MODE_SOFTEN = 0x01,\r
+ FBT_MODE_SLENDER = 0x02,\r
+ FBT_MODE_BOTH = 0x03,\r
+}BEAUTY_MODE;\r
+\r
+typedef enum\r
+{\r
+ FBT_LEVEL_VERY_STRONG = 0x05,\r
+ FBT_LEVEL_STRONG = 0x04,\r
+ FBT_LEVEL_MEDIUM = 0x03,\r
+ FBT_LEVEL_WEAK = 0x02,\r
+ FBT_LEVEL_VERY_WEAK = 0x01,\r
+}BEAUTY_LEVEL;\r
+\r
+typedef enum\r
+{\r
+ IMG_FORMAT_RGB24 = 0x001,\r
+ IMG_FORMAT_RGB16 = 0x002,\r
+ IMG_FORMAT_ARGB = 0x003,\r
+\r
+ IMG_FORMAT_YUV422_YUYV = 0x010,\r
+ IMG_FORMAT_YUV422_YVYU = 0x020,\r
+\r
+ IMG_FORMAT_YUV420_PL = 0x100,\r
+ IMG_FORMAT_YUV420_SP_UV = 0x200,\r
+ IMG_FORMAT_YUV420_SP_VU = 0x300,\r
+}IMAGE_DATE_FORMAT;\r
+\r
+\r
+typedef enum\r
+{\r
+ EXP_NUETRAL = 0x000,\r
+ EXP_ANGRY = 0x001,\r
+ EXP_SMILE = 0x002,\r
+ EXP_SURPRISE = 0x003,\r
+}EXPRESSIONMODE;\r
+\r
+typedef enum\r
+{\r
+ BD_OPEN = 0x000,\r
+ BD_LEFT = 0x001,\r
+ BD_RIGHT = 0x002,\r
+ BD_CLOSE = 0x003,\r
+}BLINKMODE;\r
+\r
+typedef enum\r
+{\r
+ DT_FACE = 0x0001,\r
+ DT_FACEEYE = 0x0010,\r
+ DT_FACEEYEMOUTH1 = 0x0100,\r
+ DT_FACEEYEMOUTH2 = 0x0200,\r
+}DTMODE;\r
+\r
+typedef enum\r
+{\r
+ DIRECTION_NONE = 0x0000,\r
+ DIRECTION_UP = 0x0001,\r
+ DIRECTION_RIGHT = 0x0002,\r
+ DIRECTION_LEFT = 0x0003,\r
+ DIRECTION_DOWN = 0x0004,\r
+}DIRMODE;\r
+\r
+typedef enum\r
+{\r
+ PARTIAL_FD_CENTER = 0x0000,\r
+ PARTIAL_FD_LEFT = 0x0001,\r
+ PARTIAL_FD_LEFTBOTTOM = 0x0002,\r
+ PARTIAL_FD_RIGHT = 0x0003,\r
+ PARTIAL_FD_RIGHTBOTTOM = 0x0004,\r
+ PARTIAL_FD_BOTTOM = 0x0005,\r
+ PARTIAL_FD_TOP = 0x0006,\r
+}PFDMODE;\r
+#endif\r
--- /dev/null
+#ifndef _CA_FACE_APP_INTERFACE_H_\r
+#define _CA_FACE_APP_INTERFACE_H_\r
+\r
+#include "caBasicDef.h"\r
+#include "caBasicDef_ENUM.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+extern double g_DiffValue;\r
+extern int g_cand_left;\r
+extern int g_cand_right;\r
+extern int g_previous_direction;\r
+extern int g_isBlink;\r
+extern int g_bMemoryAllocSuccess;\r
+\r
+extern caFaceROI g_FBTCandidateROI;\r
+int caApp_FaceEngineInit(FaceEngineInfo* fe, caFDMode FDMode, caFDSizeCoverage coverage, int iFaceMaxNum, int iInterval);\r
+int caApp_FaceEngineCoreInit(FaceEngineInfo* fe, int nFaceLimit);\r
+\r
+int caApp_FaceEngineReInit(FaceEngineInfo* fe);\r
+int caApp_FaceEngineCoreReInit(FaceEngineInfo* fe);\r
+\r
+int caApp_FaceEngineRelease(FaceEngineInfo* fe);\r
+int caApp_FaceEngineCoreRelease(FaceEngineInfo* fe);\r
+\r
+int caApp_RunFERDetection(unsigned char* pSrc, int wd, int ht, FaceEngineInfo* coreFE, BOOL bSingleImage);\r
+int caApp_RunBlinkDetection(unsigned char* pSrc, int wd, int ht, FaceEngineInfo* coreFE, BOOL bSingleImage);\r
+int caApp_RunWinkDetection(unsigned char* pSrc, int wd, int ht, FaceEngineInfo* coreFE, BOOL bSingleImage);\r
+int caApp_RunFERDetectionSingleFace(unsigned char* pSrc, int wd, int ht, FaceEngineInfo* coreFE, int faceidx, BOOL bSingleImage);\r
+int caApp_RunBlinkDetectionSingleFace(unsigned char* pSrc, int wd, int ht, FaceEngineInfo* coreFE, int faceidx, BOOL bSingleImage);\r
+int caApp_RunWinkDetectionSingleFace(unsigned char* pSrc, int wd, int ht, FaceEngineInfo* coreFE, int faceidx, BOOL bSingleImage);\r
+\r
+int caApp_SetMouthForFER(unsigned char* pY, int wd, int ht, FaceEngineInfo* coreFE, EXPRESSIONMODE expression);\r
+PreviewStateMsg caApp_TraceFace(int iFrmCnt, unsigned char* pOldFrmBuf, unsigned char* pCurFrmBuf, int wd, int ht, FaceEngineInfo* fe, FaceEngineInfo* corefe, int iScenario, int iDTMode);\r
+\r
+\r
+int caApp_FinalArrageFaceEngineInfo(FaceEngineInfo* srcInfo, int nRatioSrcPerRsz, FaceEngineInfo* dstInfo);\r
+\r
+DIRMODE caApp_DetectFace4D(unsigned char* pY, int wd, int ht, FaceEngineInfo* fe, unsigned char* pRotbuf, DIRMODE dirmode, DTMODE dtmode);\r
+int caApp_DetectFaceEye4D(unsigned char* pY, int wd, int ht, FaceEngineInfo* fe, int bIncludingEye);\r
+\r
+int caApp_RunFaceDetection(unsigned char* pY, int wd, int ht, FaceEngineInfo* fe);\r
+int caApp_RunEyeDetection(unsigned char* pY, int wd, int ht, FaceEngineInfo* fe, int faceidx);\r
+int caApp_RunMouthDetection(unsigned char* pY, int wd, int ht, FaceEngineInfo* fe, int faceidx);\r
+\r
+int caApp_FtsExInit(caFRMode FRMode, char* binPath);\r
+void caApp_FtsExRelease();\r
+long* caApp_FtsExGetFeatureVector(unsigned char* pY, int wd, int ht, FaceEngineInfo* fe, int nFaceIndex);\r
+long caApp_FtsExCompareFeatureVector(long* enroll, long* test);\r
+int caApp_FtsExVecLength();\r
+\r
+int caApp_TraceRegion(unsigned char* pOldFrame, unsigned char* pNewFrame, caFaceROI mb, int frame_width, int frame_height, int* mv_w, int* mv_h);\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif
\ No newline at end of file