1 #ifndef __DVS_APP_H__ 2 #define __DVS_APP_H__ 3 4 #include <stdint.h> 5 6 #include "rk_aiq_mems_sensor.h" 7 8 /* 9 * @enum rk_dvs_format_type_t 10 * @brief Specify the format of input image 11 */ 12 typedef enum { 13 RK_DVS_PIXEL_FMT_GRAY, /**< Gray */ 14 RK_DVS_PIXEL_FMT_NV21, /**< NV21 */ 15 RK_DVS_PIXEL_FMT_NV12, /**< NV12 */ 16 RK_DVS_PIXEL_FMT_NUM, 17 } rk_dvs_format_type_t; 18 19 #if 0 20 typedef struct sensor_vec_s { 21 union { 22 double v[3]; 23 struct { 24 double x; 25 double y; 26 double z; 27 }; 28 }; 29 } sensor_vec_t; 30 31 typedef struct uncalib_event_s { 32 union { 33 double uncalib[3]; 34 struct { 35 double x_uncalib; 36 double y_uncalib; 37 double z_uncalib; 38 }; 39 }; 40 union { 41 double bias[3]; 42 struct { 43 double x_bias; 44 double y_bias; 45 double z_bias; 46 }; 47 }; 48 } uncalib_event_t; 49 50 typedef sensor_vec_t gyro_data_t; 51 typedef sensor_vec_t accel_data_t; 52 typedef int temperature_data_t; 53 54 typedef struct sensor_vec_all_s { 55 gyro_data_t gyro; 56 accel_data_t accel; 57 temperature_data_t temperature; 58 } sensor_vec_all_t; 59 60 typedef struct mems_sensor_event_s { 61 uint64_t id; 62 uint64_t timestamp_us; 63 union { 64 double data[16]; 65 accel_data_t accel; 66 gyro_data_t gyro; 67 temperature_data_t temperature; 68 sensor_vec_all_t all; 69 70 uncalib_event_t uncalib_gyro; 71 uncalib_event_t uncalib_accel; 72 }; 73 } mems_sensor_event_t; 74 #endif 75 76 struct dvsImageSize { 77 int width; 78 int height; 79 }; 80 81 // initial params 82 struct initialParams { 83 rk_dvs_format_type_t image_format; // input image format 84 dvsImageSize input_image_size; // input image size 85 dvsImageSize output_image_size; // output image size 86 int image_buffer_number; // number of image buffer 87 int image_stride; // input image width width extra invalid pixels 88 int auto_scaling; // output image will be upscale 89 double clip_ratio_x; // clip ratio in x direction 90 double clip_ratio_y; // clip ratio in y direction 91 }; 92 93 struct dvsMetaData { 94 int iso_speed; // iso speed 95 double exp_time; // exposure time. unit: second. 96 double 97 rolling_shutter_skew; // unit: second. Duration between the start of exposure for the first 98 // row of the image sensor,and the start of exposure for one past the 99 double zoom_ratio; // zoom ratio 100 uint64_t timestamp_sof_us; // sof time 101 }; 102 103 // input image params 104 struct imageData { 105 int buffer_index; // image buffer index 106 int frame_index; // image index 107 int pyramid_number; // pyramid number,Range[0-4](1/2,1/4,1/8,1/16) 108 int* pyramid_stride; // pyramid image stride 109 uint8_t** pdata_pyramid; // pyramid image 110 uint8_t* pdata_original; // original image 111 dvsMetaData meta_data; // image meta data 112 }; 113 114 //输出结构体 115 struct meshxyFEC { 116 int mesh_buffer_index; // mesh index 117 int image_buffer_index; // mesh表对应图像buffer的index 118 int image_index; // mesh表对应图像的index 119 int is_skip; //是否跳帧,0:不跳帧;1:跳帧,跳帧时,输出的mesh表为上一帧的mesh表 120 unsigned long mesh_size; // mesh表的长度 121 // FEC所需的四个小表 122 unsigned short* pMeshXI; 123 unsigned char* pMeshXF; 124 unsigned short* pMeshYI; 125 unsigned char* pMeshYF; 126 }; 127 128 //接口结构体 129 struct dvsEngine { 130 void* private_data; // dvs库所需参数 131 }; 132 133 extern "C" { 134 135 typedef int (*dvsFrameCallBackFEC)(struct dvsEngine* engine, meshxyFEC* mesh_fec); 136 137 /************************************************************************************************* 138 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 139 * Function name : dvsRegisterRemap() 140 * Author: lmp 141 * Description: callback function 142 * Input: engine: Engine instance pointer 143 * callback: callback function 144 * Return: ?? 145 * History: 146 * <author> <time> <version> <desc> 147 * lmp 15/03/21 1.0 org 148 * 149 *************************************************************************************************/ 150 int dvsRegisterRemap(struct dvsEngine* engine, dvsFrameCallBackFEC callback); 151 152 /************************************************************************************************* 153 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 154 * Function name : dvsPrepare() 155 * Author: lmp 156 * Description: Prepare dvs engine environment 157 * Input: engine: Engine instance pointer 158 * Return: ?? 159 * History: 160 * <author> <time> <version> <desc> 161 * lmp 15/03/21 1.0 org 162 * 163 *************************************************************************************************/ 164 int dvsPrepare(struct dvsEngine* engine); 165 166 /************************************************************************************************* 167 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 168 * Function name : getMeshSize() 169 * Author: lmp 170 * Description: get mesh size 171 * Input: image_height: image height 172 * image_width: image width 173 * mesh_size: mesh size 174 * Return: ?? 175 * History: 176 * <author> <time> <version> <desc> 177 * lmp 15/03/21 1.0 org 178 * 179 *************************************************************************************************/ 180 void getMeshSize(int image_height, int image_width, int* mesh_size); 181 182 /************************************************************************************************* 183 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 184 * Function name : getOriginalMeshXY() 185 * Author: lmp 186 * Description: get original mesh 187 * Input: image_height: image height 188 * image_width: image width 189 * clip_ratio_x: 190 * clip_ratio_y: 191 * Output: meshxyFEC: mesh 192 * Return: ?? 193 * History: 194 * <author> <time> <version> <desc> 195 * lmp 15/04/08 1.0 org 196 * 197 *************************************************************************************************/ 198 void getOriginalMeshXY(int image_width, int image_height, double clip_ratio_x, double clip_ratio_y, 199 meshxyFEC* pmesh_fec); 200 201 /************************************************************************************************* 202 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 203 * Function name : dvsPutImageFrame() 204 * Author: lmp 205 * Description: put image in dvs 206 * Input: engine: Engine instance pointer 207 * pimage_data: image_data 208 * Return: ?? 209 * History: 210 * <author> <time> <version> <desc> 211 * lmp 15/03/21 1.0 org 212 * 213 *************************************************************************************************/ 214 int dvsPutImageFrame(struct dvsEngine* engine, struct imageData* pimage_data); 215 216 /************************************************************************************************* 217 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 218 * Function name : dvsPutImageFrame() 219 * Author: lmp 220 * Description: put image in dvs 221 * Input: engine: Engine instance pointer 222 * pmesh_fec: fec mesh 223 * Return: ?? 224 * History: 225 * <author> <time> <version> <desc> 226 * lmp 15/03/21 1.0 org 227 * 228 *************************************************************************************************/ 229 int dvsPutMesh(struct dvsEngine* engine, struct meshxyFEC* pmesh_fec); 230 231 /************************************************************************************************* 232 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 233 * Function name : dvsPutImuFrame() 234 * Author: lmp 235 * Description: put imu data in dvs 236 * Input: engine: Engine instance pointer 237 * pimu_data: imu data 238 * buff_number: imu buffer number 239 * Return: ?? 240 * History: 241 * <author> <time> <version> <desc> 242 * lmp 15/03/21 1.0 org 243 * 244 *************************************************************************************************/ 245 int dvsPutImuFrame(struct dvsEngine* engine, mems_sensor_event_s* pimu_data, int buff_number); 246 247 /************************************************************************************************* 248 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 249 * Function name : dvsInitFromXmlFile() 250 * Author: lmp 251 * Description: initialize dvs from xml 252 * Input: engine: Engine instance pointer 253 * path: xml path 254 * Return: ?? 255 * History: 256 * <author> <time> <version> <desc> 257 * lmp 15/03/21 1.0 org 258 * 259 *************************************************************************************************/ 260 int dvsInitFromXmlFile(struct dvsEngine* engine, const char* path); 261 262 /************************************************************************************************* 263 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 264 * Function name : dvsInitFromFile() 265 * Author: lmp 266 * Description: initialize dvs from struct 267 * Input: engine: Engine instance pointer 268 * init_params: initial params struct 269 * Return: ?? 270 * History: 271 * <author> <time> <version> <desc> 272 * lmp 17/03/31 2.0 org 273 * 274 *************************************************************************************************/ 275 int dvsInitParams(struct dvsEngine* engine, struct initialParams* init_params); 276 277 /************************************************************************************************* 278 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 279 * Function name : dvsStart() 280 * Author: lmp 281 * Description: start dvs 282 * Input: engine: Engine instance pointer 283 * Return: ?? 284 * History: 285 * <author> <time> <version> <desc> 286 * lmp 15/03/21 1.0 org 287 * 288 *************************************************************************************************/ 289 int dvsStart(struct dvsEngine* engine); 290 291 /************************************************************************************************* 292 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 293 * Function name : dvsRequestStop() 294 * Author: lmp 295 * Description: request dvs stop 296 * Input: engine: Engine instance pointer 297 * Return: ?? 298 * History: 299 * <author> <time> <version> <desc> 300 * lmp 15/03/21 1.0 org 301 * 302 *************************************************************************************************/ 303 int dvsRequestStop(struct dvsEngine* engine); 304 305 /************************************************************************************************* 306 * Copyright (C),2021, Fuzhou Rockchip Co.,Ltd. 307 * Function name : dvsDeinit() 308 * Author: lmp 309 * Description: finish dvs 310 * Input: engine: Engine instance pointer 311 * Return: ?? 312 * History: 313 * <author> <time> <version> <desc> 314 * lmp 15/03/21 1.0 org 315 * 316 *************************************************************************************************/ 317 int dvsDeinit(struct dvsEngine* engine); 318 } 319 320 #endif // __DVS_APP_H__ 321