xref: /OK3568_Linux_fs/external/rockit/tgi/sdk/include/RTMediaRockx.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2020 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * author: hh@rock-chips.com
17  *   date: 2020-5-19
18  * module: video filter with rknn/rockx/rockface
19  */
20 #ifndef SRC_RT_MEDIA_AV_FILTER_INCLUDE_RTMEDIAROCKX_H_
21 #define SRC_RT_MEDIA_AV_FILTER_INCLUDE_RTMEDIAROCKX_H_
22 
23 #include "rt_type.h"                    // NOLINT
24 #include <string>
25 
26 #ifdef HAVE_ROCKX
27 #include <rockx/rockx.h>
28 #endif
29 
30 #define ROCKX_FACE_DETECT       "rockx_face_detect"
31 #define ROCKX_FACE_LANDMARK     "rockx_face_landmark"
32 #define ROCKX_POSE_BODY         "rockx_pose_body"
33 #define ROCKX_POSE_BODY_V2      "rockx_pose_body_v2"
34 #define ROCKX_POSE_FINGER       "rockx_pose_finger"
35 #define ROCKX_FACE_GENDER_AGE   "rockx_face_gender_age"
36 
37 
38 typedef struct _RTRockxCfg {
39     //  path of "librockx.so"
40     char *path;
41     //  model which is will be loaded by rknn
42     char *model;
43     //  format of input datas
44     char *format;
45     //  width of input datas
46     INT32 width;
47     //  width of input datas
48     INT32 height;
49 
50     // add more
51 } RTRockxCfg;
52 
53 typedef void (*RknnCallBack) (void* handler, int type, void *ptr, int size);
54 typedef void* RknnHandler;
55 
56 
57 typedef struct {
58 #ifdef HAVE_ROCKFACE
59     rockface_det_t base;
60     rockface_attribute_t attr;
61     rockface_landmark_t landmark;
62     rockface_angle_t angle;
63     rockface_feature_t feature;
64 #endif
65 
66 #ifdef HAVE_ROCKX
67     rockx_object_t object;
68 #endif
69 } RTFaceInfo;
70 
71 typedef struct {
72 #ifdef HAVE_ROCKX
73     rockx_face_landmark_t object;
74 #endif
75 } RTLandmarkInfo;
76 
77 typedef struct {
78 #ifdef HAVE_ROCKFACE
79     rockface_det_t base;
80 #endif
81 
82 #ifdef HAVE_ROCKX
83     rockx_keypoints_t object;
84 #endif
85 } RTBodyInfo;
86 
87 typedef struct {
88 #ifdef USE_ROCKX
89     rockx_keypoints_t object;
90 #endif
91 } RTFingerInfo;
92 
93 typedef enum {
94     RT_SUCCESS = 0,
95     RT_FAILURE,
96     RT_TIMEOUT,
97     RT_UNKNOW,
98 } RTAuthorizedStatus;
99 
100 typedef enum {
101     RT_RKNN_TYPE_NONE = -1,
102     RT_RKNN_TYPE_FACE = 0,
103     RT_RKNN_TYPE_BODY,
104     RT_RKNN_TYPE_FINGER,
105     RT_RKNN_TYPE_LANDMARK,
106     RT_RKNN_TYPE_AUTHORIZED_STATUS,
107 } RTRknnResultType;
108 
109 typedef struct {
110     INT32 index;
111     INT32 img_w;
112     INT32 img_h;
113     INT64 timeval;
114     RTRknnResultType type;
115     RTAuthorizedStatus status;
116     union {
117         RTBodyInfo body_info;
118         RTFaceInfo face_info;
119         RTLandmarkInfo landmark_info;
120         RTFingerInfo   finger_info;
121     };
122 } RTRknnResult;
123 
124 typedef struct {
125     // how many result in results poiont
126     INT32 counter;
127     // the results of rknn output
128     RTRknnResult* results;
129 } RTRknnAnalysisResults;
130 
131 typedef struct {
132     INT32 dataSize;
133     INT32 width;
134     INT32 height;
135     INT32 format;
136     INT32 angle;
137     INT32 mirror;
138     INT32 faceID;
139     unsigned char *feature;
140     INT32 featureLen;
141 } RTKKMattingFaceInfo;
142 
143 typedef struct {
144     INT32 faceCount;
145     RTKKMattingFaceInfo *faceInfo;
146 } RTKKAIMattingResult;
147 
148 #endif  // SRC_RT_MEDIA_AV_FILTER_INCLUDE_RTMEDIAROCKX_H_
149 
150