wangrong
2025-03-19 291afb9c81aae1d15d9e3edcea618d0a2e1fc5a6
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
#pragma once
 
#include <map>
#include <algorithm>
#include "../vp_node.h"
#include "../../objects/shapes/vp_point.h"
#include "../../objects/shapes/vp_line.h"
#include "../../objects/vp_image_record_control_meta.h"
#include "../../objects/vp_video_record_control_meta.h"
 
namespace vp_nodes
{
    // behaviour analysis node for stop (support multi channels)
    class vp_ba_person_gathering_node : public vp_node
    {
    private:
        // channel -> status of targets (id -> num of hit frames)
        std::map<int, std::map<int, int>> all_person_gathering_checking_status;
 
        // channel -> jam status of channel (jam or not)
        std::map<int, bool> all_person_gathering_results;
 
        // channel -> last frame index to notify jam
        std::map<int, int> all_last_notifys;
 
        // record params
        bool need_record_image;
        bool need_record_video;
 
        bool isNearby(int p1_width, int p1_x, int p1_y, int p2_width, int p2_x, int p2_y, float factor);
 
        float person_gathering_distance_factor = 4.0f;
 
        // jam checking logic parameters which may be configed by constructor passed in by user
        const int check_interval_frames = 1;
        const int check_min_hit_frames = 1 * 1; // 25 fps * 2 seconds
 
        int min_gathering_person = 3;
 
        const int check_notify_interval = 10; // interval time (seconds) to notify (ensure not frequently)
    protected:
        virtual std::shared_ptr<vp_objects::vp_meta> handle_frame_meta(std::shared_ptr<vp_objects::vp_frame_meta> meta) override;
 
    public:
        vp_ba_person_gathering_node(std::string node_name,
                                    int min_gathering_person,
                                    bool need_record_image = true,
                                    bool need_record_video = true);
        ~vp_ba_person_gathering_node();
        std::string to_string() override;
    };
}