hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#ifndef __PANORAMA_STITCHINGAPP_H__
#define __PANORAMA_STITCHINGAPP_H__
 
#include <stdint.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
#if defined _WIN32 || defined __CYGWIN__
#ifdef BUILDING_DLL
#ifdef __GNUC__
#define DLL_PUBLIC __attribute__ ((dllexport))
#else
   // Note: actually gcc seems to also supports this syntax.
#define DLL_PUBLIC __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define DLL_PUBLIC __attribute__ ((dllimport))
#else
   // Note: actually gcc seems to also supports this syntax.
#define DLL_PUBLIC
#endif
#define DLL_LOCAL
#endif
#else
#if __GNUC__ >= 4
#define DLL_PUBLIC __attribute__ ((visibility ("default")))
#define DLL_LOCAL  __attribute__ ((visibility ("hidden")))
#else
#define DLL_PUBLIC
#define DLL_LOCAL
#endif
#endif
 
   /*
    * @enum    RK_PS_RETURN_STATUS
    * @brief   the return status of function
    */
   enum RK_PS_RETURN_STATUS
   {
       RK_PS_STATUS_EOF = -1,            /**< error of function inside */
       RK_PS_STATUS_OK = 0,            /**< run successfully */
       RK_PS_STATUS_FILE_READ_ERROR,    /**< error: fail to read file */
       RK_PS_STATUS_FILE_WRITE_ERROR,    /**< error: fail to write file */
       RK_PS_STATUS_INVALID_PARAM,        /**< error: invalid parameter */
       RK_PS_STATUS_ALLOC_FAILED,        /**< error: fail to alloc buffer */
       AVS_STATUS_BUTT                    /**< error: reserved fields */
   };
 
   /*
    * @enum    RK_PS_MESH_ALPHA_SAVE_OPTION
    * @brief   Specify the way of saving mesh and alpha data
    */
   enum RK_PS_MESH_ALPHA_SAVE_OPTION
   {
       WRITE_MESH_ALPHA_BUFFER = 0,            /**< write mesh and alpha in buffer */
       WRITE_MESH_ALPHA_BIN_FILE = 1,            /**< write mesh and alpha as bin file */
   };
 
   /*
    * @enum    RK_PS_LOW_FREQUENCY_LAYER_FUSE_WIDTH
    * @brief   Specify the low frequency layer fuse width
    */
   enum RK_PS_LOW_FREQUENCY_LAYER_FUSE_WIDTH
   {
       LOW_FREQUENCY_LAYER_FUSE_WIDTH_128 = 128,    /**< fuse_width = 128 */
       LOW_FREQUENCY_LAYER_FUSE_WIDTH_256 = 256,    /**< fuse_width = 256 */
       LOW_FREQUENCY_LAYER_FUSE_WIDTH_512 = 512,    /**< fuse_width = 512 */
   };
 
   /*
    * @enum    RK_PS_IMAGE_FORMAT
    * @brief   Specify the input images format
    */
   enum RK_PS_IMAGE_FORMAT
   {
       INPUT_FORMAT_TYPE_GRAY = 0,                /**< input gray images */
       INPUT_FORMAT_TYPE_RGB = 1,                /**< input rgb images */
       INPUT_FORMAT_TYPE_YUVNV12 = 2,            /**< input yuv_nv12 images */
   };
 
   /*
    * @enum    RK_PS_SAVE_MESH_ALPHA_TYPE
    * @brief   Specify the save mesh and alpha data type
    */
   enum RK_PS_SAVE_MESH_ALPHA_TYPE
   {
       SAVE_MESH_ALPHA_TYPE_GPU = 0,                /**< output rk mesh alpha data for gpu(3588) */
       SAVE_MESH_ALPHA_TYPE_CMODEL = 1,            /**< output rk mesh alpha data for cmodel */
       SAVE_MESH_ALPHA_TYPE_DEBUG = 2,                /**< output rk mesh alpha data for debug */
       SAVE_MESH_ALPHA_TYPE_FEC = 3,                /**< output rk mesh alpha data for FEC */
   };
 
   /*
    * @enum    RK_PS_CAMERA_TYPE
    * @brief   Specify the camera type
    */
   enum RK_PS_CAMERA_TYPE
   {
       RK_PS_CAMERA_TYPE_PINHOLE,                /**< camera pinhole type */
       RK_PS_CAMERA_TYPE_OMNI,                    /**< camera omnidirectional type */
       RK_PS_CAMERA_TYPE_FISH,                    /**< camera fisheye type */
   };
 
   /*
    * @enum    RK_PS_PROJECT_TYPE
    * @brief   Specify the project type
    */
   enum RK_PS_PROJECT_TYPE
   {
       RK_PS_PROJECTION_EQUIRECTANGULAR = 0,    /**< equirectangular */
       RK_PS_PROJECTION_RECTILINEAR = 1,        /**< rectilinear */
       RK_PS_PROJECTION_CYLINDRICAL = 2,        /**< cylindrical */
       RK_PS_PROJECTION_CUBE_MAP = 3,            /**< cube_map: currently unsupported */
   };
 
   /*
    * @enum    RK_PS_SrcOverlapPosition
    * @brief   Clockwise rotation angle of overlapping area from src image to dst image
    */
   enum RK_PS_SrcOverlapPosition
   {
       RK_PS_SrcOverlapPosition_0 = 0,            /**< clockwise rotation 0 degrees */
       RK_PS_SrcOverlapPosition_90 = 1,        /**< clockwise rotation 90 degrees */
       RK_PS_SrcOverlapPosition_180 = 2,        /**< clockwise rotation 180 degrees */
       RK_PS_SrcOverlapPosition_270 = 3,        /**< clockwise rotation 270 degrees */
   };
 
   /*
    * @struct  RK_PS_SrcOverlapMap
    * @brief   the overlap map data and position on src image
    */
   struct RK_PS_SrcOverlapMap
   {
       char versionInfo[64];
       RK_PS_SrcOverlapPosition srcOverlapPositon[8];
       unsigned char overlapMap[15 * 15 * 8];
   };
 
   struct RK_PS_MeshParams
   {
       int nonoverlap_num;
       int overlap_num;
       int nonoverlap_dst_startx[2];
       int nonoverlap_dst_width[2];
       int nonoverlap_mesh_width[2];
       int nonoverlap_mesh_height[2];
 
       int overlap_band_num;
       int overlap_dst_startx[2];
       int overlap_dst_width[2];
       int overlap_mesh_width[2];
       int overlap_mesh_height[2];
       int overlap_alpha_width[2];
       int overlap_alpha_height[2];
   };
   /*
    * @struct  RK_PS_MeshBuffer
    * @brief   output buffer for mesh
    */
   struct RK_PS_MeshBuffer
   {
       int src_width;
       int src_height;
       int dst_width;
       int dst_height;
       int mesh_step_x;
       int mesh_step_y;
       int camera_num;
       float* pmesh;
       RK_PS_MeshParams mesh_params[8];
   };
 
   /*
    * @struct  RK_PS_AlphaBuffer
    * @brief   output buffer for alpha
    */
   struct RK_PS_AlphaBuffer
   {
 
   };
 
   /*
    * @struct  RK_PS_Engine
    * @brief   the internal engine instance
    */
   struct RK_PS_Engine
   {
       RK_PS_MeshBuffer* mesh;                    /**< input/output-mesh buffer */
       RK_PS_AlphaBuffer* alpha;                /**< input/output-alpha buffer */
       void* p;
   };
 
   /*
    * @struct  RK_PS_InitParams
    * @brief   params for initialize calibration data
    */
   struct RK_PS_InitParams
   {
       RK_PS_MESH_ALPHA_SAVE_OPTION save_option;    /**< input-specify save option */
       int camera_num;                                /**< input-camera numbers */
       const char* input_calib_data_path;            /**< input-cameras calibration data path */
       const char* input_mask_data_path;            /**< input-mask image path */
       const char* input_lut_path;                    /**< input-specify src LUT file path */
       const char* output_mesh_alpha_data_path;    /**< output-mesh and alpha data path */
       const char* output_overlap_data_path;        /**< output-overlap data path */
       int mesh_step_x;                            /**< input-mesh step in horizontal direction */
       int mesh_step_y;                            /**< input-mesh step in vertical direction */
       int fuse_width;                                /**< input-min width of fuse band: 128 or 256 or 512 */
   };
 
   /*
    * @struct  RK_PS_Rotation
    * @brief   rotation angle
    */
   struct RK_PS_Rotation
   {
       int yaw100;                                /**< yaw data. yaw angle x 100 */
       int pitch100;                            /**< pitch data. pitch angle x 100 */
       int roll100;                            /**< roll data. roll angle x 100 */
   };
 
   /*
    * @struct  RK_PS_SetProjectParams
    * @brief   params for the specifications of the output image
    */
   struct RK_PS_SetProjectParams
   {
       int project_type;                        /**< input-project type */
       int camera_num;                            /**< input-cameras number */
       int src_width;                            /**< input-input_images width */
       int src_height;                            /**< input-input_images height */
       int dst_width;                            /**< input-output stitch image width */
       int dst_height;                            /**< input-output stitch image height */
       int fov_x100;                            /**< input-output stitch image fov_x */
       int fov_y100;                            /**< input-output stitch image fov_y */
       int center_x;                            /**< input-output stitch image center_y */
       int center_y;                            /**< input-output stitch image center_y */
       float stitch_distance;                    /**< input-best stitch distance */
       int save_mesh_alpha_type;                /**< input-output mesh and alpha type */
       RK_PS_Rotation ori_rotation;            /**< input-output stitch image ori rotation */
       RK_PS_Rotation rotation;                /**< input-output stitch image rotation */
   };
 
   /*
    * @struct  RK_PS_FineTuningParams
    * @brief   fine tuning params for every camera
    */
   struct RK_PS_FineTuningParams
   {
       int camera_num;
       int offset_h[8];
       int offset_w[8];
       int offset_z[8];
       RK_PS_Rotation rotation[8];
   };
 
   /*
    * @struct  RK_PS_Roi_Params
    * @brief   params for roi
    */
   struct RK_PS_RoiParams
   {
       int src_project_type;                    /**< input-project type */
       int src_width;                            /**< input-input_image width */
       int src_height;                            /**< input-input_image height */
       int src_fov_x100;                        /**< input-input_image fov_x */
       int src_fov_y100;                        /**< input-input_image fov_y */
       int src_center_x;
       int src_center_y;
 
       int dst_width;                            /**< input-output stitch image width */
       int dst_height;                            /**< input-output stitch image height */
       int dst_fov_x100;                        /**< input-output stitch image fov_x */
       int dst_fov_y100;                        /**< input-output stitch image fov_y */
       int dst_center_x;                        /**< input-output stitch image center_y */
       int dst_center_y;                        /**< input-output stitch image center_y */
   };
 
   /*
    * @struct  RK_PS_InitBlendedImages
    * @brief   params for initialize blended images
    */
   struct RK_PS_InitBlendedImages
   {
       int camera_num;                            /**< input-cameras number */
       int image_format;                        /**< input-images format */
       int use_gain;                            /**< input-use gain or not(0-not use,1-use) */
       int gain_stepx;                            /**< input-gian step_x */
       int gain_stepy;                            /**< input-gian step_y */
       int input_mesh_alpha_data_type;            /**< input-input mesh and alpha data type */
       const char* input_mesh_alpha_data_path;    /**< input-input mesh and alpha data path */
       unsigned char* output_blended_image;    /**< output-output blended image */
   };
 
   /* ´´½¨EngineµÄº¯Êý */
   DLL_PUBLIC int RK_PS_setEngine(struct RK_PS_Engine* engine);
 
   /* Éú³Émesh±íºÍalpha±íʱµÄ³õʼ»¯±ê¶¨²ÎÊýµÄº¯Êý */
   DLL_PUBLIC int RK_PS_initParams(struct RK_PS_Engine* engine, RK_PS_InitParams* params);
 
   /* Éú³Émesh±íºÍalpha±íʱÉèÖÃÊä³öͼÏñ¹æ¸ñµÄº¯Êý */
   DLL_PUBLIC int RK_PS_setProjectParams(struct RK_PS_Engine* engine, struct RK_PS_SetProjectParams* params);
 
   /* Éú³Émesh±íºÍalpha±íʱÉèÖÃÿ¸öÏà»ú×Ë̬¾«µ÷²ÎÊýµÄº¯Êý */
   DLL_PUBLIC int RK_PS_setFineTuningParams(struct RK_PS_Engine* engine, struct RK_PS_FineTuningParams* params);
 
   //»ñÈ¡GPUËùÐè²éÕÒ±íËùÐèµÄ×î´óbuffer
   DLL_PUBLIC int RK_PS_getMaxMeshBufferSize(struct RK_PS_Engine* engine, float* buffer_size);
 
   /* Í¨¹ý±ê¶¨ÎļþÉú³Émesh±íºÍalpha±íµÄº¯Êý */
   DLL_PUBLIC int RK_PS_mesh_alphaFromCalibration(struct RK_PS_Engine* engine);
   
   /* Í¨¹ý±ê¶¨Îļþ¼ÆËãÊäÈëͼÏñÖØµþÇøÓòmaskÐÅÏ¢ */
   DLL_PUBLIC int RK_PS_srcOverlapMaskFromCalibration(struct RK_PS_Engine* engine);
 
   /* Í¨¹ýÖмäLUT±íÉú³Émesh±íºÍalpha±íµÄº¯Êý */
   DLL_PUBLIC int RK_PS_mesh_alphaFromProjection(struct RK_PS_Engine* engine);
 
   /* Í¨¹ýÓû§Ö¸¶¨µÄROI²ÎÊýÉú³ÉrectilinearУÕýµÄmesh±íµÄº¯Êý */
   DLL_PUBLIC int RK_PS_meshForRoiRectilinear(struct RK_PS_Engine* engine, RK_PS_RoiParams* roi_parmas, const char* save_mesh_path);
 
   /* Æ´½ÓͼÏñµÄ³õʼ»¯º¯Êý */
   DLL_PUBLIC int RK_PS_initBlendedImages(struct RK_PS_Engine* engine, struct RK_PS_InitBlendedImages* params);
 
   /* Æ´½ÓͼÏñº¯ÊýÖ÷º¯Êý */
   DLL_PUBLIC int RK_PS_blendedImages(struct RK_PS_Engine* engine, unsigned char** pinput_image);
 
   /* Îö¹¹º¯Êý */
   DLL_PUBLIC int RK_PS_destroy(struct RK_PS_Engine* engine);
 
#ifdef __cplusplus
} /* extern "C" { */
#endif
 
 
 
 
#endif // !__PANORAMA_STITCHINGAPP_H__