SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
counter.h
Go to the documentation of this file.
1 /*
2  * MIT License
3  * Copyright (c) 2024 lynnl4 Seeed Technology Co.,Ltd
4  *
5  */
6 
7 #ifndef _COUNTER_H_
8 #define _COUNTER_H_
9 
10 #include <stdint.h>
11 #include <unordered_map>
12 #include <vector>
13 
14 class Counter {
15 public:
16  Counter(int32_t frame_rate = 10);
17  ~Counter();
18  void update(int32_t id, int16_t x, int16_t y);
19  void clear();
20  struct object {
21  int32_t id;
22  int16_t x;
23  int16_t y;
24  int16_t side;
25  int32_t count;
26  };
27  void setSplitter(std::vector<int16_t> splitter);
28  std::vector<int16_t> getSplitter();
29  std::vector<int32_t> get();
30 
31 protected:
32  int getSide(int16_t x, int16_t y);
33 
34 private:
35  int32_t frame_rate;
36  int32_t countAB; // A -> B
37  int32_t countBA; // B -> A
38  std::vector<int16_t> splitter;
39  std::unordered_map<int32_t, object> objects;
40 };
41 
42 #endif
Definition: counter.h:14
void setSplitter(std::vector< int16_t > splitter)
Definition: counter.cpp:56
~Counter()
Definition: counter.cpp:9
void update(int32_t id, int16_t x, int16_t y)
Definition: counter.cpp:22
int getSide(int16_t x, int16_t y)
Definition: counter.cpp:11
std::vector< int16_t > getSplitter()
Definition: counter.cpp:83
Counter(int32_t frame_rate=10)
Definition: counter.cpp:7
std::vector< int32_t > get()
Definition: counter.cpp:64
void clear()
Definition: counter.cpp:50
Definition: counter.h:20
int16_t y
Definition: counter.h:23
int16_t side
Definition: counter.h:24
int32_t count
Definition: counter.h:25
int16_t x
Definition: counter.h:22
int32_t id
Definition: counter.h:21