feat: add behavior event frame model
This commit is contained in:
parent
2a0a1470cb
commit
6f30513a73
42
include/behavior/behavior_event.h
Normal file
42
include/behavior/behavior_event.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "frame/rect.h"
|
||||
|
||||
namespace rk3588 {
|
||||
|
||||
enum class BehaviorEventType {
|
||||
Intrusion,
|
||||
Climb,
|
||||
Fall,
|
||||
Fight
|
||||
};
|
||||
|
||||
enum class BehaviorEventStatus {
|
||||
Pending,
|
||||
Active,
|
||||
Ended
|
||||
};
|
||||
|
||||
struct BehaviorEventItem {
|
||||
int event_id = -1;
|
||||
BehaviorEventType type = BehaviorEventType::Intrusion;
|
||||
BehaviorEventStatus status = BehaviorEventStatus::Pending;
|
||||
float score = 0.0f;
|
||||
Rect bbox{};
|
||||
std::vector<int> track_ids;
|
||||
uint64_t start_pts = 0;
|
||||
uint64_t last_pts = 0;
|
||||
uint64_t duration_ms = 0;
|
||||
std::string source;
|
||||
std::string region_id;
|
||||
};
|
||||
|
||||
struct BehaviorEventResult {
|
||||
std::vector<BehaviorEventItem> items;
|
||||
};
|
||||
|
||||
} // namespace rk3588
|
||||
@ -8,7 +8,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "behavior/behavior_event.h"
|
||||
#include "hw/frame_buffer.h"
|
||||
#include "frame/rect.h"
|
||||
|
||||
namespace rk3588 {
|
||||
|
||||
@ -23,13 +25,6 @@ enum class PixelFormat {
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float w = 0.0f;
|
||||
float h = 0.0f;
|
||||
};
|
||||
|
||||
struct Detection {
|
||||
int cls_id = -1;
|
||||
float score = 0.0f;
|
||||
@ -86,6 +81,7 @@ struct Frame {
|
||||
std::shared_ptr<FrameBuffer> buffer;
|
||||
|
||||
std::shared_ptr<DetectionResult> det;
|
||||
std::shared_ptr<BehaviorEventResult> behavior_events;
|
||||
// Face recognition pipeline meta (kept separate from user_meta to avoid conflicts with publish).
|
||||
std::shared_ptr<FaceDetResult> face_det;
|
||||
std::shared_ptr<FaceRecogResult> face_recog;
|
||||
|
||||
12
include/frame/rect.h
Normal file
12
include/frame/rect.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
namespace rk3588 {
|
||||
|
||||
struct Rect {
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float w = 0.0f;
|
||||
float h = 0.0f;
|
||||
};
|
||||
|
||||
} // namespace rk3588
|
||||
@ -37,6 +37,7 @@ add_executable(rk3588_gtests
|
||||
test_config_expand.cpp
|
||||
test_hw_factory.cpp
|
||||
test_frame_buffer.cpp
|
||||
test_behavior_event_model.cpp
|
||||
test_infer_backend.cpp
|
||||
test_image_processor.cpp
|
||||
test_codec_backend.cpp
|
||||
|
||||
33
tests/test_behavior_event_model.cpp
Normal file
33
tests/test_behavior_event_model.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "frame/frame.h"
|
||||
|
||||
namespace rk3588 {
|
||||
namespace {
|
||||
|
||||
TEST(BehaviorEventModelTest, FrameStoresBehaviorEventsSeparatelyFromDetections) {
|
||||
auto frame = std::make_shared<Frame>();
|
||||
frame->det = std::make_shared<DetectionResult>();
|
||||
frame->behavior_events = std::make_shared<BehaviorEventResult>();
|
||||
|
||||
BehaviorEventItem item;
|
||||
item.event_id = 7;
|
||||
item.type = BehaviorEventType::Fall;
|
||||
item.status = BehaviorEventStatus::Active;
|
||||
item.track_ids = {42};
|
||||
item.duration_ms = 1600;
|
||||
|
||||
frame->behavior_events->items.push_back(item);
|
||||
|
||||
ASSERT_NE(frame->det, nullptr);
|
||||
ASSERT_NE(frame->behavior_events, nullptr);
|
||||
ASSERT_EQ(frame->behavior_events->items.size(), 1u);
|
||||
ASSERT_EQ(frame->behavior_events->items[0].track_ids.size(), 1u);
|
||||
EXPECT_EQ(frame->behavior_events->items[0].track_ids[0], 42);
|
||||
EXPECT_EQ(frame->behavior_events->items[0].duration_ms, 1600u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace rk3588
|
||||
Loading…
Reference in New Issue
Block a user