wx_human_seg 3.0.0
wx_idphoto.h
Go to the documentation of this file.
1
7#ifndef WX_IDPHOTO_H_
8#define WX_IDPHOTO_H_
9
10#include <memory>
11#include <string>
12#include <vector>
13#include "wx_api.h"
14#include "wx_exception.h"
15#include "wx_image.h"
16
17namespace wonxai {
18
19class WXIDPhotoImpl;
20
24class WX_API WXIDPhotoConfig {
25public:
29 int width;
30
34 int height;
35
41 float faceRatio;
42
48 float eyesTop;
49
56 float topEmpty[2];
57
62 std::shared_ptr<WXImage> bgImage;
63
67 unsigned short dpi;
68
73 WXIDPhotoConfig(int w, int h):
74 width(w),
75 height(h),
76 faceRatio(0.5f),
77 eyesTop(0.4f),
78 dpi(300),
79 bgImage(nullptr) {
80 topEmpty[0] = .0f;
81 topEmpty[1] = .0f;
82 }
83
88 WXIDPhotoConfig(0, 0) {
89 }
90};
91
95class WX_API WXIDPhotoSettings {
96public:
100 static std::shared_ptr<WXIDPhotoSettings> create();
101
107
108 virtual ~WXIDPhotoSettings() = default;
109
111 virtual void setValue(const std::string &key, int value) = 0;
112
114 virtual void setValue(const std::string &key, float value) = 0;
115
117 virtual void setValue(const std::string &key, bool value) = 0;
118
120 virtual void setValue(const std::string &key, const std::string &data) = 0;
121
123 virtual void setValue(const std::string &key, const std::vector<int> &arr) = 0;
124
126 virtual void setValue(const std::string &key, const std::vector<float> &arr) = 0;
127
134 virtual int getIntValue(const std::string &key, int defValue=0) = 0;
135
142 virtual float getFloatValue(const std::string &key, float defValue=0) = 0;
143
150 virtual bool getBoolValue(const std::string &key, bool defValue=false) = 0;
151
158 virtual const std::string& getStringValue(const std::string &key) = 0;
159
166 virtual const std::vector<int> &getIntArray(const std::string &key) = 0;
167
174 virtual const std::vector<float> &getFloatArray(const std::string &key) = 0;
175
179 virtual bool hasKey(const std::string &key) = 0;
180
181};
182
191 DarkGlasses = 2
193
198public:
199 typedef enum WXGlassesType GlassesType;
200
201public:
203
207 virtual int faceCount() = 0;
208
212 virtual int upEmpty() = 0;
213
217 virtual int rightEmpty() = 0;
218
222 virtual int bottomEmpty() = 0;
223
227 virtual int leftEmpty() = 0;
228
232 virtual int sizeScore() = 0;
233
237 virtual int darkillum() = 0;
238
242 virtual int faceBlur() = 0;
243
247 virtual int faceUnbalance() = 0;
248
252 virtual GlassesType glasses() = 0;
253
257 virtual int eyesClose() = 0;
258
262 virtual int mouthClose() = 0;
263
267 virtual int faceOcclusion() = 0;
268
274 virtual const float* headPose() = 0;
275
279 virtual int gaze() = 0;
280
281protected:
283};
284
288class WX_API WXIDPhoto final {
289public:
297
298 ~WXIDPhoto();
299
307 const std::shared_ptr<WXImage>
308 makeIDPhoto(const std::shared_ptr<WXImage> &inImg,
309 const WXIDPhotoConfig &config);
310
316 const WXIDPhotoConfig &config);
317
332 const std::shared_ptr<WXImage>
333 makeIDPhoto(const std::shared_ptr<WXImage> &inImg,
334 const WXIDPhotoConfig &config,
335 const std::shared_ptr<WXIDPhotoPreDetectResult> &preResult);
336
341 WXImage *
342 makeIDPhoto(const WXImage *inImg,
343 const WXIDPhotoConfig &config,
344 const WXIDPhotoPreDetectResult *preResult);
345
352 std::shared_ptr<WXIDPhotoPreDetectResult>
353 preDetect(const std::shared_ptr<WXImage> &inImg);
354
360 preDetect(const WXImage *inImg);
361
367 void setSettings(const std::shared_ptr<WXIDPhotoSettings> &settings);
368
374 void setSettings(const WXIDPhotoSettings* settings);
375
376private:
377 std::unique_ptr<WXIDPhotoImpl> _impl;
378};
379
380} // end of namespace wonxai
381
382
383#endif //WX_IDPHOTO_H_
Definition: wx_idphoto.h:24
int height
Definition: wx_idphoto.h:34
unsigned short dpi
Definition: wx_idphoto.h:67
float faceRatio
Definition: wx_idphoto.h:41
int width
Definition: wx_idphoto.h:29
WXIDPhotoConfig()
Definition: wx_idphoto.h:87
std::shared_ptr< WXImage > bgImage
Definition: wx_idphoto.h:62
float eyesTop
Definition: wx_idphoto.h:48
WXIDPhotoConfig(int w, int h)
Definition: wx_idphoto.h:73
Definition: wx_idphoto.h:288
void setSettings(const std::shared_ptr< WXIDPhotoSettings > &settings)
证件照制作或者环境检测配置设置
WXImage * makeIDPhoto(const WXImage *inImg, const WXIDPhotoConfig &config, const WXIDPhotoPreDetectResult *preResult)
WXImage * makeIDPhoto(const WXImage *inImg, const WXIDPhotoConfig &config)
证件照制作接口
const std::shared_ptr< WXImage > makeIDPhoto(const std::shared_ptr< WXImage > &inImg, const WXIDPhotoConfig &config, const std::shared_ptr< WXIDPhotoPreDetectResult > &preResult)
证件照制作接口
const std::shared_ptr< WXImage > makeIDPhoto(const std::shared_ptr< WXImage > &inImg, const WXIDPhotoConfig &config)
证件照制作接口
std::shared_ptr< WXIDPhotoPreDetectResult > preDetect(const std::shared_ptr< WXImage > &inImg)
证件照环境检测接口
WXIDPhoto(WXDeviceType deviceType=kDeviceCPU)
WXIDPhoto构造函数
WXIDPhotoPreDetectResult * preDetect(const WXImage *inImg)
证件照环境检测接口
void setSettings(const WXIDPhotoSettings *settings)
证件照制作或者环境检测配置设置
Definition: wx_idphoto.h:197
virtual const float * headPose()=0
virtual GlassesType glasses()=0
Definition: wx_idphoto.h:95
virtual bool getBoolValue(const std::string &key, bool defValue=false)=0
virtual void setValue(const std::string &key, const std::vector< float > &arr)=0
virtual void setValue(const std::string &key, const std::vector< int > &arr)=0
static std::shared_ptr< WXIDPhotoSettings > create()
virtual void setValue(const std::string &key, const std::string &data)=0
static WXIDPhotoSettings * create2()
virtual const std::vector< float > & getFloatArray(const std::string &key)=0
virtual float getFloatValue(const std::string &key, float defValue=0)=0
virtual bool hasKey(const std::string &key)=0
virtual const std::vector< int > & getIntArray(const std::string &key)=0
virtual void setValue(const std::string &key, bool value)=0
virtual void setValue(const std::string &key, int value)=0
virtual void setValue(const std::string &key, float value)=0
virtual const std::string & getStringValue(const std::string &key)=0
virtual int getIntValue(const std::string &key, int defValue=0)=0
Definition: wx_image.h:15
WXDeviceType
Definition: wx_api.h:21
@ kDeviceCPU
Definition: wx_api.h:23
WXGlassesType
Definition: wx_idphoto.h:185
@ NoGlasses
Definition: wx_idphoto_c_api.h:135
@ DarkGlasses
Definition: wx_idphoto_c_api.h:139
@ NormalGlasses
Definition: wx_idphoto_c_api.h:137