hc
2023-03-21 4b55d97acc464242bcd6a8ae77b8ff37c22dec58
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
#ifndef __DVS_APP_H__
#define __DVS_APP_H__
 
#include <stdint.h>
 
#include "rk_aiq_mems_sensor.h"
 
/*
 * @enum    rk_dvs_format_type_t
 * @brief   Specify the format of input image
 */
typedef enum {
    RK_DVS_PIXEL_FMT_GRAY, /**< Gray */
    RK_DVS_PIXEL_FMT_NV21, /**< NV21 */
    RK_DVS_PIXEL_FMT_NV12, /**< NV12 */
    RK_DVS_PIXEL_FMT_NUM,
} rk_dvs_format_type_t;
 
#if 0
typedef struct sensor_vec_s {
    union {
        double v[3];
        struct {
            double x;
            double y;
            double z;
        };
    };
} sensor_vec_t;
 
typedef struct uncalib_event_s {
    union {
        double uncalib[3];
        struct {
            double x_uncalib;
            double y_uncalib;
            double z_uncalib;
        };
    };
    union {
        double bias[3];
        struct {
            double x_bias;
            double y_bias;
            double z_bias;
        };
    };
} uncalib_event_t;
 
typedef sensor_vec_t gyro_data_t;
typedef sensor_vec_t accel_data_t;
typedef int temperature_data_t;
 
typedef struct sensor_vec_all_s {
    gyro_data_t gyro;
    accel_data_t accel;
    temperature_data_t temperature;
} sensor_vec_all_t;
 
typedef struct mems_sensor_event_s {
    uint64_t id;
    uint64_t timestamp_us;
    union {
        double data[16];
        accel_data_t accel;
        gyro_data_t gyro;
        temperature_data_t temperature;
        sensor_vec_all_t all;
 
        uncalib_event_t uncalib_gyro;
        uncalib_event_t uncalib_accel;
    };
} mems_sensor_event_t;
#endif
 
struct dvsImageSize {
    int width;
    int height;
};
 
// initial params
struct initialParams {
    rk_dvs_format_type_t image_format;  // input image format
    dvsImageSize input_image_size;      // input image size
    dvsImageSize output_image_size;     // output image size
    int image_buffer_number;            // number of image buffer
    int image_stride;                   // input image width width extra invalid pixels
    int auto_scaling;                   // output image will be upscale
    double clip_ratio_x;                // clip ratio in x direction
    double clip_ratio_y;                // clip ratio in y direction
};
 
struct dvsMetaData {
    int iso_speed;    // iso speed
    double exp_time;  // exposure time. unit: second.
    double
        rolling_shutter_skew;  // unit: second. Duration between the start of exposure for the first
                               // row of the image sensor,and the start of exposure for one past the
    double zoom_ratio;         // zoom ratio
    uint64_t timestamp_sof_us;  // sof time
};
 
// input image params
struct imageData {
    int buffer_index;         // image buffer index
    int frame_index;          // image index
    int pyramid_number;       // pyramid number,Range[0-4](1/2,1/4,1/8,1/16)
    int* pyramid_stride;      // pyramid image stride
    uint8_t** pdata_pyramid;  // pyramid image
    uint8_t* pdata_original;  // original image
    dvsMetaData meta_data;    // image meta data
};
 
//输出结构体
struct meshxyFEC {
    int mesh_buffer_index;   // mesh index
    int image_buffer_index;  // mesh表对应图像buffer的index
    int image_index;         // mesh表对应图像的index
    int is_skip;  //是否跳帧,0:不跳帧;1:跳帧,跳帧时,输出的mesh表为上一帧的mesh表
    unsigned long mesh_size;  // mesh表的长度
    // FEC所需的四个小表
    unsigned short* pMeshXI;
    unsigned char* pMeshXF;
    unsigned short* pMeshYI;
    unsigned char* pMeshYF;
};
 
//接口结构体
struct dvsEngine {
    void* private_data;  // dvs库所需参数
};
 
extern "C" {
 
typedef int (*dvsFrameCallBackFEC)(struct dvsEngine* engine, meshxyFEC* mesh_fec);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsRegisterRemap()
 *  Author:         lmp
 *  Description:    callback function
 *  Input:          engine: Engine instance pointer
 *                  callback: callback function
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsRegisterRemap(struct dvsEngine* engine, dvsFrameCallBackFEC callback);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsPrepare()
 *  Author:         lmp
 *  Description:    Prepare dvs engine environment
 *  Input:          engine: Engine instance pointer
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsPrepare(struct dvsEngine* engine);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : getMeshSize()
 *  Author:         lmp
 *  Description:    get mesh size
 *  Input:          image_height: image height
 *                  image_width:  image width
 *                  mesh_size: mesh size
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
void getMeshSize(int image_height, int image_width, int* mesh_size);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : getOriginalMeshXY()
 *  Author:         lmp
 *  Description:    get original mesh
 *  Input:          image_height: image height
 *                  image_width:  image width
 *                  clip_ratio_x:
 *                  clip_ratio_y:
 *  Output:         meshxyFEC: mesh
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/04/08      1.0            org
 *
 *************************************************************************************************/
void getOriginalMeshXY(int image_width, int image_height, double clip_ratio_x, double clip_ratio_y,
                       meshxyFEC* pmesh_fec);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsPutImageFrame()
 *  Author:         lmp
 *  Description:    put image in dvs
 *  Input:          engine:  Engine instance pointer
 *                  pimage_data: image_data
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsPutImageFrame(struct dvsEngine* engine, struct imageData* pimage_data);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsPutImageFrame()
 *  Author:         lmp
 *  Description:    put image in dvs
 *  Input:          engine: Engine instance pointer
 *                  pmesh_fec: fec mesh
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsPutMesh(struct dvsEngine* engine, struct meshxyFEC* pmesh_fec);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsPutImuFrame()
 *  Author:         lmp
 *  Description:    put imu data in dvs
 *  Input:          engine: Engine instance pointer
 *                  pimu_data: imu data
 *                  buff_number:  imu buffer number
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsPutImuFrame(struct dvsEngine* engine, mems_sensor_event_s* pimu_data, int buff_number);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsInitFromXmlFile()
 *  Author:         lmp
 *  Description:    initialize dvs from xml
 *  Input:          engine: Engine instance pointer
 *                  path:  xml path
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsInitFromXmlFile(struct dvsEngine* engine, const char* path);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsInitFromFile()
 *  Author:         lmp
 *  Description:    initialize dvs from struct
 *  Input:          engine: Engine instance pointer
 *                  init_params:  initial params struct
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         17/03/31      2.0            org
 *
 *************************************************************************************************/
int dvsInitParams(struct dvsEngine* engine, struct initialParams* init_params);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsStart()
 *  Author:         lmp
 *  Description:    start dvs
 *  Input:          engine: Engine instance pointer
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsStart(struct dvsEngine* engine);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsRequestStop()
 *  Author:         lmp
 *  Description:    request dvs stop
 *  Input:          engine: Engine instance pointer
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsRequestStop(struct dvsEngine* engine);
 
/*************************************************************************************************
 *  Copyright (C),2021, Fuzhou Rockchip Co.,Ltd.
 *  Function name : dvsDeinit()
 *  Author:         lmp
 *  Description:    finish dvs
 *  Input:          engine: Engine instance pointer
 *  Return:         ??
 *  History:
 *           <author>      <time>     <version>       <desc>
 *            lmp         15/03/21      1.0            org
 *
 *************************************************************************************************/
int dvsDeinit(struct dvsEngine* engine);
}
 
#endif  // __DVS_APP_H__