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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef EPTZ_CONTROL_
#define EPTZ_CONTROL_
 
#define _API __attribute__((visibility("default")))
 
#include <rga/RockchipRga.h>
#if EPTZ_ENABLE
#include <rockx/rockx.h>
#endif
#include <easymedia/buffer.h>
#include <easymedia/flow.h>
#include <easymedia/image.h>
#include <easymedia/key_string.h>
#include <easymedia/media_config.h>
#include <easymedia/utils.h>
#include <math.h>
#include <memory>
 
extern struct eptz_frame_info eptz_info;
extern float *tempXY;
extern float *arrayXY;
extern float *lastXY;
extern bool last_focus_state;
extern bool current_focus_state;
 
struct eptz_frame_info {
  int src_width;
  int src_height;
  int dst_width;
  int dst_height;
  int threshold_x;
  int threshold_y;
  int iterate_x;
  int iterate_y;
};
 
// 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));
 
std::shared_ptr<easymedia::Flow> create_flow(const std::string &flow_name,
                                             const std::string &flow_param,
                                             const std::string &elem_param);
 
class DynamicClipFlow : public easymedia::Flow {
public:
  DynamicClipFlow(uint32_t dst_w, uint32_t dst_h);
  virtual ~DynamicClipFlow() {
    StopAllThread();
    fprintf(stderr, "~dynamic clip flow quit\n");
  }
  int dst_width;
  int dst_height;
  friend bool do_dynamic_clip(easymedia::Flow *f,
                              easymedia::MediaBufferVector &input_vector);
};
 
bool do_dynamic_clip(easymedia::Flow *f,
                     easymedia::MediaBufferVector &input_vector);
 
class RockxFlow : public easymedia::Flow {
public:
  RockxFlow();
  virtual ~RockxFlow() {
    StopAllThread();
    for (auto handle : rockx_handles) {
      rockx_destroy(handle);
    }
    fprintf(stderr, "~rockx flow quit\n");
  }
 
private:
  std::vector<rockx_handle_t> rockx_handles;
  friend bool do_rockx(easymedia::Flow *f,
                       easymedia::MediaBufferVector &input_vector);
};
 
bool do_rockx(easymedia::Flow *f, easymedia::MediaBufferVector &input_vector);
 
extern std::shared_ptr<easymedia::Flow> eptz_source;
extern std::shared_ptr<easymedia::Flow> rknn;
extern std::shared_ptr<DynamicClipFlow> dclip;
 
// zoom
int zoom_config(int stream_width, int stream_height);
int set_zoom(float val);
 
class ZoomFlow : public easymedia::Flow {
public:
  ZoomFlow(uint32_t dst_w, uint32_t dst_h);
  virtual ~ZoomFlow() {
    StopAllThread();
    fprintf(stderr, "~ZoomFlow flow quit\n");
  }
  int dst_width;
  int dst_height;
  friend bool do_zoom(easymedia::Flow *f,
                      easymedia::MediaBufferVector &input_vector);
};
 
bool do_zoom(easymedia::Flow *f, easymedia::MediaBufferVector &input_vector);
 
extern std::shared_ptr<ZoomFlow> zoom;
int eptz_config(int stream_width, int stream_height, int eptz_width,
                int eptz_height);
int get_env(const char *name, int *value, int default_value);
bool count_rectXY(std::shared_ptr<easymedia::MediaBuffer> output,
                  float *resultArray, float *lastXY, int src_w, int src_h,
                  int clip_w, int clip_h);
void output_result(ImageRect *src_rect, ImageRect *dst_rect);
 
#endif