From 63d598d4443f906b34bedaf49e870b7a2be1a5c8 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 06 四月 2017 12:14:30 +0800
Subject: [PATCH] bug fix for android device

---
 VisitFace/RtspNativeCodec/app/libs/st_face/include/cv_common.h |  220 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 179 insertions(+), 41 deletions(-)

diff --git a/VisitFace/RtspNativeCodec/app/libs/st_face/include/cv_common.h b/VisitFace/RtspNativeCodec/app/libs/st_face/include/cv_common.h
index a9bd3e6..21ce097 100644
--- a/VisitFace/RtspNativeCodec/app/libs/st_face/include/cv_common.h
+++ b/VisitFace/RtspNativeCodec/app/libs/st_face/include/cv_common.h
@@ -2,26 +2,10 @@
 #define CV_COMMON_H_
 
 /// @defgroup cv_common cv common
-/// @brief common definitions for cv libs
+/// @brief common definitions & API for cv libs
 /// @{
 
-#ifndef CV_SDK_API_
-#ifdef _MSC_VER
-#	ifdef CV_STATIC_LIB
-#		define CV_SDK_API_
-#	elif defined SDK_EXPORTS
-#		define CV_SDK_API_ __declspec(dllexport)
-#	else
-#		define CV_SDK_API_ __declspec(dllimport)
-#	endif
-#else /* _MSC_VER */
-#	ifdef SDK_EXPORTS
-#		define CV_SDK_API_ __attribute__((visibility ("default")))
-#	else
-#		define CV_SDK_API_
-#	endif
-#endif
-#endif
+#include <cv_utils.h>
 
 #ifdef __cplusplus
 #	define CV_SDK_API extern "C" CV_SDK_API_
@@ -33,26 +17,7 @@
 typedef void *cv_handle_t;
 
 /// cv result declearation
-typedef int   cv_result_t;
-
-#define CV_OK (0)			///< 姝e父杩愯
-#define CV_E_INVALIDARG (-1)		///< 鏃犳晥鍙傛暟
-#define CV_E_HANDLE (-2)		///< 鍙ユ焺閿欒
-#define CV_E_OUTOFMEMORY (-3)		///< 鍐呭瓨涓嶈冻
-#define CV_E_FAIL (-4)			///< 鍐呴儴閿欒
-#define CV_E_DELNOTFOUND (-5)		///< 瀹氫箟缂哄け
-#define CV_E_INVALID_PIXEL_FORMAT (-6)	///< 涓嶆敮鎸佺殑鍥惧儚鏍煎紡
-#define CV_E_FILE_NOT_FOUND (-10)	///< 妯″瀷鏂囦欢涓嶅瓨鍦�
-#define CV_E_INVALID_FILE_FORMAT (-11)	///< 妯″瀷鏍煎紡涓嶆纭�, 瀵艰嚧鍔犺浇澶辫触
-#define CV_E_INVALID_APPID (-12)	///< 鍖呭悕閿欒
-#define CV_E_INVALID_AUTH (-13)		///< 鍔犲瘑鐙楀姛鑳戒笉鏀寔
-#define CV_E_AUTH_EXPIRE (-14)		///< SDK杩囨湡
-#define CV_E_FILE_EXPIRE (-15)		///< 妯″瀷鏂囦欢杩囨湡
-#define CV_E_DONGLE_EXPIRE (-16)	///< 鍔犲瘑鐙楄繃鏈�
-#define CV_E_ONLINE_AUTH_FAIL (-17)	///< 鍦ㄧ嚎楠岃瘉澶辫触
-#define CV_E_ONLINE_AUTH_TIMEOUT (-18)	///< 鍦ㄧ嚎楠岃瘉瓒呮椂
-#define CV_E_UNSUPPORTED (-19)		///< 涓嶆敮鎸佺殑鍑芥暟璋冪敤鏂瑰紡
-
+typedef cv_errcode cv_result_t;
 
 /// cv rectangle definition
 typedef struct cv_rect_t {
@@ -86,6 +51,15 @@
 	int points_count;
 } cv_landmarks_t;
 
+/// @brief 鍏抽敭鐐硅窡韪粨鏋滅粨鏋勪綋
+typedef  struct cv_target_t {
+	cv_rect_t rect;			///< 浠h〃闈㈤儴鐨勭煩褰㈠尯鍩�
+	cv_pointf_t *points_array;	///< 鐩爣鍏抽敭鐐瑰潗鏍�
+	int points_count;		///< 鐩爣鍏抽敭鐐归暱搴�
+	float score;			///< 鐩爣缃俊搴�
+	int id;				///< 鐩爣ID, 鐢ㄤ簬琛ㄧず鍦ㄧ洰鏍囪窡韪腑鐨勭浉鍚岀洰鏍囧湪涓嶅悓甯у娆″嚭鐜�
+} cv_target_t;
+
 typedef struct cv_feature_header_t {
 	int ver;		///< 鐗堟湰淇℃伅
 	int idx;		///< 鏁扮粍涓嬫爣绱㈠紩
@@ -107,7 +81,7 @@
 
 /// cv pixel format definition
 typedef enum {
-	CV_PIX_FMT_GRAY8,	///< Y    1        8bpp ( 鍗曢�氶亾8bit鐏板害鍍忕礌 )
+	CV_PIX_FMT_GRAY8,	///< Y    1       8bpp ( 鍗曢�氶亾8bit鐏板害鍍忕礌 )
 	CV_PIX_FMT_YUV420P,	///< YUV  4:2:0   12bpp ( 3閫氶亾, 涓�涓寒搴﹂�氶亾, 鍙︿袱涓负U鍒嗛噺鍜孷鍒嗛噺閫氶亾, 鎵�鏈夐�氶亾閮芥槸杩炵画鐨� )
 	CV_PIX_FMT_NV12,	///< YUV  4:2:0   12bpp ( 2閫氶亾, 涓�涓�氶亾鏄繛缁殑浜害閫氶亾, 鍙︿竴閫氶亾涓篣V鍒嗛噺浜ら敊 )
 	CV_PIX_FMT_NV21,	///< YUV  4:2:0   12bpp ( 2閫氶亾, 涓�涓�氶亾鏄繛缁殑浜害閫氶亾, 鍙︿竴閫氶亾涓篤U鍒嗛噺浜ら敊 )
@@ -139,9 +113,173 @@
 
 /// @brief 鍥惧儚鍒嗙被鏍囩缁撴灉
 typedef struct cv_classifier_result_t {
-	int id;  ///鏍囩
-	float score;  /// 缃俊搴�
+	int id;				///鏍囩
+	float score;			/// 缃俊搴�
 } cv_classifier_result_t;
 
+// ====================== image utilities ========================
+
+/// @brief 鍒涘缓鍥惧儚鎸囬拡骞跺垎閰嶅唴瀛�
+/// @param[in] width 杈撳叆瀹藉害
+/// @param[in] height 杈撳叆楂樺害
+/// @param[in] pixel_format 杈撳叆鍍忕礌鏍煎紡
+/// @param[out] image 杈撳嚭鍥惧儚鎸囬拡鎵�鍦ㄥ湴鍧�
+/// @return 鎴愬姛杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒鐮�
+CV_SDK_API
+cv_result_t cv_image_allocate(
+	int width,
+	int height,
+	cv_pixel_format pixel_format,
+	cv_image ** image
+);
+
+/// @brief 閲婃斁鍥惧儚鏁版嵁
+/// @param[in] image 鍥惧儚鎸囬拡
+CV_SDK_API void
+cv_image_release(cv_image* image);
+
+/// @brief 杩涜棰滆壊鏍煎紡杞崲
+/// @param[in] image_src 鐢ㄤ簬寰呰浆鎹㈢殑鍥惧儚鏁版嵁
+/// @param[out] image_dst 杞崲鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭�, 鍍忕礌鍊煎垵濮嬪寲涓�0
+/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷
+CV_SDK_API cv_result_t
+cv_common_color_convert(
+	const cv_image* image_src,
+	cv_image* image_dst
+);
+
+/// @brief 杩涜浠垮皠鍙樻崲
+/// @param[in] image_src 鐢ㄤ簬寰呰浆鎹㈢殑鍥惧儚鏁版嵁
+/// @param[in] src_points_array 婧愬浘鐨勪豢灏勭偣鏁扮粍
+/// @param[in] src_points_count 婧愬浘浠垮皠鐐圭殑鏁扮洰
+/// @param[in] dst_points_array 鐩爣鍥剧殑浠垮皠鐐规暟缁�
+/// @param[in] dst_points_count 鐩爣鍥句豢灏勭偣鐨勬暟鐩�
+/// @param[out] image_dst 杞崲鍚庣殑鍥惧儚鏁版嵁, 蹇呴』鏄疊GR鏍煎紡鍥惧儚锛岀洰鏍囧浘鍍忛渶瑕佺敱鐢ㄦ埛鍒嗛厤鍐呭瓨, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭�
+/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷
+CV_SDK_API
+cv_result_t
+cv_common_image_affine_transfer(
+	const cv_image *image_src,
+	const cv_pointf_t *src_points_array,
+	const int src_points_count,
+	const cv_pointf_t *dst_points_array,
+	const int dst_points_count,
+	cv_image *image_dst
+);
+
+/// @brief 鍥剧墖璋冩暣鏂规硶
+typedef enum {
+       CV_IMAGE_RESIZE_BILINEAR,	///< 鍙岀嚎鎬ф彃鍊�
+       CV_IMAGE_RESIZE_AREA		///< 鍖哄煙鎻掑��
+} cv_image_resize_method;
+
+/// @brief 杩涜缂╂斁鍙樻崲
+/// @note 璇ュ嚱鏁扮洰鍓嶄笉鏀寔stride鍙傛暟, 鎵�浠tride鍙傛暟搴旂瓑浜� width * elemSize
+/// @param[in] image_src 鐢ㄤ簬寰呰浆鎹㈢殑鍥惧儚鏁版嵁
+/// @param[out] image_dst 杞崲鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭�
+/// @param[in] method 缂╂斁杞崲鐨勬柟娉�
+/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷
+CV_SDK_API
+cv_result_t
+cv_common_image_resize(
+       const cv_image *image_src,
+       cv_image *image_dst,
+       cv_image_resize_method method
+);
+
+/// @brief 杩涜鍥惧儚瑁佸壀
+/// @param[in] image_src 鐢ㄤ簬寰呰鍓殑鍥惧儚鏁版嵁
+/// @param[in] crop_area 鍥惧儚瑁佸壀鐨勫尯鍩�
+/// @param[out] image_dst 瑁佸壀鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭�
+/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷
+CV_SDK_API
+cv_result_t
+cv_common_image_crop(
+       const cv_image *image_src,
+       const cv_rect_t *crop_area,
+       cv_image *image_dst
+);
+
+/// @brief 杩涜鍥惧儚鏃嬭浆
+/// @note 璇ュ嚱鏁扮洰鍓嶄笉鏀寔stride鍙傛暟, 鎵�浠tride鍙傛暟搴旂瓑浜� width * elemSize
+/// @param[in] image_src 鐢ㄤ簬寰呮棆杞殑鍥惧儚鏁版嵁
+/// @param[out] image_dst 鏃嬭浆鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭�
+/// @param[in] rotate_degree 鍥惧儚椤烘椂閽堟棆杞殑瑙掑害, 鐜板湪鍙敮鎸�0, 90, 180, 270
+/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷
+CV_SDK_API
+cv_result_t
+cv_common_image_rotate(
+       const cv_image *image_src,
+       cv_image *image_dst,
+       unsigned int rotate_degree
+);
+
+
+// ====================== model loader ========================
+
+/// 妯″瀷鎸囬拡
+typedef void * cv_model_t;
+
+/// 缁勫悎妯″瀷鎸囬拡
+typedef void * cv_composite_model_t;
+
+/// @brief 鍔犺浇澶栭儴妯″瀷
+/// @param[in] file 杈撳叆妯″瀷鏂囦欢璺緞
+/// @param[out] model 杈撳嚭宸插垵濮嬪寲鐨勬ā鍨嬫寚閽�
+/// @return 鎴愬姛杩斿洖CV_OK
+CV_SDK_API cv_result_t
+cv_common_load_model(
+	const char *file,
+	cv_model_t *model
+);
+
+/// @brief 閿�姣佸凡鍔犺浇鐨勬ā鍨�
+/// @param[in] model 妯″瀷鎸囬拡
+CV_SDK_API
+void cv_common_unload_model(
+	cv_model_t model
+);
+
+/// @brief 鍔犺浇鍐呴儴妯″瀷
+/// @param[in] model_start 鍐呴儴妯″瀷鎸囬拡澶�
+/// @param[in] model_end 鍐呴儴妯″瀷鎸囬拡灏�
+/// @param[out] model 杈撳嚭宸插垵濮嬪寲鐨勬ā鍨嬫寚閽�
+/// @return 鎴愬姛杩斿洖CV_OK
+CV_SDK_API cv_result_t
+cv_common_load_resource(
+	const unsigned char *model_start,
+	const unsigned char *model_end,
+	cv_model_t *model
+);
+
+
+/// @brief 鍔犺浇缁勫悎妯″瀷
+/// @param[in] file 缁勫悎妯″瀷鏂囦欢璺緞锛� 鏂囦欢鏄敱澶氫釜瀛愭ā鍨嬫枃浠剁粍鎴恡ar鍖�
+/// @param[out] model 杈撳嚭宸插垵濮嬪寲鐨勭粍鍚堟ā鍨嬫寚閽�
+/// @return 鎴愬姛杩斿洖CV_OK
+CV_SDK_API cv_result_t
+cv_common_load_composite_model(
+	const char *file,
+	cv_composite_model_t *model
+);
+
+/// @brief 閿�姣佸凡鍔犺浇鐨勭粍鍚堟ā鍨�
+/// @param[in] model 灏嗛攢姣佺殑妯″瀷
+CV_SDK_API cv_result_t
+cv_common_unload_composite_model(
+       cv_composite_model_t model
+);
+
+/// @brief 鑾峰彇瀛愭ā鍨�
+/// @param[in] model 缁勫悎妯″瀷
+/// @param[in] name 瀛愭ā鍨嬪悕瀛�
+/// @param[in] 鎴愬姛杩斿洖CV_OK
+CV_SDK_API cv_result_t
+cv_common_composite_model_get_submodel(
+       cv_composite_model_t model,
+       const char *name,
+       cv_model_t *submodel
+);
+
 /// @}
 #endif  // INCLUDE_CV_COMMON_H_

--
Gitblit v1.8.0