1 /*
2  * Copyright (C) 2020-2023 Alibaba Group Holding Limited
3  */
4 
5 #ifndef _UCLOUD_AI_COMMON_H_
6 #define _UCLOUD_AI_COMMON_H_
7 #include "model/common.h"
8 #include "oss_app.h"
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 
15 
16 #define FACE1_IMAGE "/data/ucloud_ai_image/face1.png"
17 #define FACE2_IMAGE "/data/ucloud_ai_image/face2.png"
18 #define ANIME_IMAGE "/data/ucloud_ai_image/expression.jpg"
19 #define EXPRESSION_IMAGE "/data/ucloud_ai_image/expression.jpg"
20 #define OBJECT_IMAGE "/data/ucloud_ai_image/object.jpg"
21 #define MAINBODY_IMAGE "/data/ucloud_ai_image/face1.png"
22 #define CARD_FACE_IMAGE "/data/ucloud_ai_image/card_face.jpg"
23 #define CARD_BACK_IMAGE "/data/ucloud_ai_image/card_back.jpg"
24 #define BANK_CARD_IMAGE "/data/ucloud_ai_image/bank_card.jpg"
25 #define CHARACTER_IMAGE "/data/ucloud_ai_image/character.jpg"
26 #define RUBBISH_IMAGE "/data/ucloud_ai_image/rubbish.jpg"
27 #define FRUITS_IMAGE "/data/ucloud_ai_image/fruits.jpg"
28 #define PERSON_ORG_IMAGE "/data/ucloud_ai_image/person_org.jpg"
29 #define STYLE_IMAGE "/data/ucloud_ai_image/person_org.jpg"
30 
31 // imageenhan style url
32 #define IMAGEENHAN_ERASE_PERSON_USERMASK_URL "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ErasePerson/ErasePerson6.jpg"
33 #define IMAGEENHAN_EXTEND_IMAGE_STYLE_URL "http://ivpd-demo.oss-cn-shanghai.aliyuncs.com/ivpd-demo/images/ExtendImageStyle/styleUrl.jpeg"
34 
35 typedef AIModelCBFunc ucloud_ai_cb_t;
36 typedef AIModelResultStruct ucloud_ai_result_t;
37 
38 typedef enum _ucloud_ai_model_t {
39     UCLOUD_AI_MODEL_COMPARING_FACEBODY, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.59.bc2e797dbbIyZQ&tagName=facebody&children=CompareFace
40     UCLOUD_AI_MODEL_GENERATE_HUMAN_ANIME_STYLE, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.15.54ca797dDKkjDk&tagName=facebody&children=GenerateHumanAnimeStyle
41     UCLOUD_AI_MODEL_RECOGNIZE_EXPRESSION, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.10.4e1a797dHZHzS5&tagName=facebody&children=RecognizeExpression
42     UCLOUD_AI_MODEL_DETECT_OBJECT, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.20.2074797dOvJ4L2&tagName=objectdet&children=DetectObject
43     UCLOUD_AI_MODEL_DETECT_MAIN_BODY, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.23.61df797dKC0yXR&tagName=objectdet&children=DetectMainBody
44     UCLOUD_AI_MODEL_SEGMENT_COMMON_IMAGE, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.6.7d9e797dL51BIO&tagName=imageseg&children=SegmentCommonImage
45     UCLOUD_AI_MODEL_SEGMENT_FACE, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.22.9e3a797deY528B&tagName=imageseg&children=SegmentFace
46     UCLOUD_AI_MODEL_RECOGNIZE_IDENTITY_CARD_FACE_SIDE, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.16.7d87797d2vHJJ9&tagName=ocr&children=RecognizeIdentityCard
47     UCLOUD_AI_MODEL_RECOGNIZE_IDENTITY_CARD_BACK_SIDE, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.16.7d87797d2vHJJ9&tagName=ocr&children=RecognizeIdentityCard
48     UCLOUD_AI_MODEL_RECOGNIZE_BANK_CARD, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.20.63cd797d7APYEE&tagName=ocr&children=RecognizeBankCard
49     UCLOUD_AI_MODEL_RECOGNIZE_CHARACTER, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14020179.J_7524944390.6.66cd608dJkkY48&tagName=ocr&children=RecognizeCharacter
50     UCLOUD_AI_MODEL_CLASSIFYING_RUBBISH, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.13.73f5797dHFaJxR&tagName=imagerecog&children=ClassifyingRubbish
51     UCLOUD_AI_MODEL_DETECT_FRUITS, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14020179.J_7524944390.44.66cd608dt39mQW&tagName=imagerecog&children=DetectFruits
52     UCLOUD_AI_MODEL_ERASE_PERSON, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.6.6c49797dKzzl8D&tagName=imageenhan&children=ErasePerson, have some unknown issue
53     UCLOUD_AI_MODEL_EXTEND_IMAGE_STYLE, // refer to https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.18.6c49797dKzzl8D&tagName=imageenhan&children=ExtendImageStyle
54     UCLOUD_AI_MODEL_MAX
55 } ucloud_ai_model_t;
56 
57 /** @defgroup ucloud_ai_aos_api ucloud_ai
58  * @{
59  */
60 
61 
62 /**
63  * Ucloud ai set key and secret.
64  * @param[in]  key    alibaba cloud key account.
65  * @param[in]  secret    alibaba cloud secret.
66  *
67  */
68 void ucloud_ai_set_key_secret(char *key, char *secret);
69 
70 /**
71  * Set oss bucket name.
72  *
73  * @param[in]  bucket    oss bucket name.
74  *
75  */
76 void ucloud_ai_set_oss_bucket(char *bucket);
77 
78 /**
79  * Set oss endpoint.
80  *
81  * @param[in]  endpoint    oss endpoint.
82  *
83  */
84 void ucloud_ai_set_oss_endpoint(char *endpoint);
85 
86 /**
87  * Upload file to oss bucket.
88  *
89  * @param[in]  path    local file path.
90  *
91  * @return oss url result.
92  */
93 uint8_t *ucloud_ai_upload_file(char *path);
94 
95 /**
96  * Initialize ucloud ai.
97  *
98  * @return  0 on success, negative error on failure.
99  */
100 int32_t ucloud_ai_init(void);
101 
102 /**
103  * Uninitialize ucloud ai.
104  *
105  * @return  0 on success, negative error on failure.
106  */
107 int32_t ucloud_ai_uninit(void);
108 
109 /**
110  * Connect to url server.
111  *
112  * @param[in]  url  url address.
113  *
114  * @return  0 on success, negative error on failure.
115  */
116 int32_t ucloud_ai_connect(char *url);
117 
118 /**
119  * Disconnect to url server.
120  *
121  */
122 void ucloud_ai_disconnect(void);
123 
124 /**
125  * Get stream by url address.
126  *
127  */
128 int32_t ucloud_ai_get_stream(char *url, char **stream);
129 /**
130  * Get token id by domain and region id.
131  *
132  */
133 
134 char *ucloud_ai_get_token_id(const char *domain, const char *region_id);
135 /**
136  * @}
137  */
138 #ifdef __cplusplus
139 }
140 #endif
141 #endif // _UCLOUD_AI_COMMON_H_
142