hc
2023-11-22 f743a7adbd6e230d66a6206fa115b59fec2d88eb
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
/*
 * Copyright (C) 2019 Hertz Wang 1989wanghang@163.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see http://www.gnu.org/licenses
 *
 * Any non-GPL usage of this software or parts of this software is strictly
 * forbidden.
 *
 */
 
#ifndef NPU_UVC_SHARED_H_
#define NPU_UVC_SHARED_H_
 
#include <stdint.h>
#include <rockx.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
enum RK_NN_OUTPUT_TYPE {
  TYPE_INVALID_NPU_OUTPUT = -1,
  TYPE_RK_NPU_OUTPUT = 0,
  TYPE_RK_ROCKX_OUTPUT,
  TYPE_RK_FACE_SDK_OUTPUT
};
 
// all types of output shoule be redefined with attribute packed
 
// rk npu output
struct aligned_npu_output {
  uint8_t want_float;
  uint8_t is_prealloc;
  uint32_t index;
  uint32_t size;
  uint8_t buf[0];
} __attribute__((packed));
 
// rockx output
struct aligned_rockx_face_rect {
  int32_t left;
  int32_t top;
  int32_t right;
  int32_t bottom;
  uint8_t score[4]; // assert(sizeof(float) == 4);
} __attribute__((packed));
 
struct aligned_rockx_face_landmark {
  uint8_t landmarks_count;
  rockx_face_landmark_t* marks;
} __attribute__((packed));
 
struct aligned_rockx_face_gender_age {
  int32_t left;
  int32_t top;
  int32_t right;
  int32_t bottom;
  uint8_t score[4]; // assert(sizeof(float) == 4);
  int32_t gender;
  int32_t age;
} __attribute__((packed));
 
// the width and height of npu processing image
struct npu_widthheight {
  uint32_t width;
  uint32_t height;
} __attribute__((packed));
 
// post process at host side
struct extra_jpeg_data {
  int64_t picture_timestamp;     // the time stamp of picture
  int64_t npu_outputs_timestamp; // the time stamp of npu outputs
  uint32_t npu_output_type;      // RK_NN_OUTPUT_TYPE
  int8_t model_identifier[64];
  struct npu_widthheight npuwh;
  uint32_t npu_output_size; // the length of follow outputs
  uint32_t npu_outputs_num; // the num of npu output
  uint8_t outputs[0];       // the buffer of npu outputs
} __attribute__((packed));
 
#ifdef __cplusplus
}
#endif
 
#endif