|
@@ -414,11 +414,15 @@ int main(int argc, char* argv[]) {
|
|
|
<< alarm_max_sec << "秒/重新武装" << rearm_sec << "秒" << endl;
|
|
<< alarm_max_sec << "秒/重新武装" << rearm_sec << "秒" << endl;
|
|
|
cout << "========================================" << endl;
|
|
cout << "========================================" << endl;
|
|
|
|
|
|
|
|
|
|
+ // NPU 核心分配: 检测绑 Core0, 姿态绑 Core1, 两模型并行推理
|
|
|
|
|
+ int det_core = cfg.value("det_core_mask", 1); // 默认 Core0
|
|
|
|
|
+ int pose_core = cfg.value("pose_core_mask", 2); // 默认 Core1
|
|
|
YoloDetector detector;
|
|
YoloDetector detector;
|
|
|
- if (target_enabled && !detector.load(model_path, input_size, conf_thresh, nms_thresh)) {
|
|
|
|
|
|
|
+ if (target_enabled && !detector.load(model_path, input_size, conf_thresh, nms_thresh, det_core)) {
|
|
|
cerr << "RKNN模型加载失败!" << endl;
|
|
cerr << "RKNN模型加载失败!" << endl;
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
+ cout << "[RKNN] 检测核心掩码: " << det_core << endl;
|
|
|
|
|
|
|
|
PoseDetector poseDetector;
|
|
PoseDetector poseDetector;
|
|
|
FallAnalyzer fallAnalyzer;
|
|
FallAnalyzer fallAnalyzer;
|
|
@@ -426,9 +430,9 @@ int main(int argc, char* argv[]) {
|
|
|
bool pose_ok = false;
|
|
bool pose_ok = false;
|
|
|
if (pose_enabled) {
|
|
if (pose_enabled) {
|
|
|
if (poseDetector.load(pose_model_path, pose_input_size,
|
|
if (poseDetector.load(pose_model_path, pose_input_size,
|
|
|
- pose_conf_thresh, pose_nms_thresh)) {
|
|
|
|
|
|
|
+ pose_conf_thresh, pose_nms_thresh, pose_core)) {
|
|
|
pose_ok = true;
|
|
pose_ok = true;
|
|
|
- cout << "[Pose] 姿态模型加载成功, 跌倒检测已就绪" << endl;
|
|
|
|
|
|
|
+ cout << "[Pose] 姿态模型加载成功, 跌倒检测已就绪, 核心掩码: " << pose_core << endl;
|
|
|
} else {
|
|
} else {
|
|
|
cerr << "[Pose] 姿态模型加载失败: " << pose_model_path
|
|
cerr << "[Pose] 姿态模型加载失败: " << pose_model_path
|
|
|
<< " (继续使用纯围栏检测)" << endl;
|
|
<< " (继续使用纯围栏检测)" << endl;
|
|
@@ -1729,11 +1733,31 @@ int main(int argc, char* argv[]) {
|
|
|
if (ch->frame_count <= 4)
|
|
if (ch->frame_count <= 4)
|
|
|
cout << "[CH" << ch->id << "] infer frame=" << ch->frame_count
|
|
cout << "[CH" << ch->id << "] infer frame=" << ch->frame_count
|
|
|
<< " rgb=" << ch->rgb_buf.size() << endl;
|
|
<< " rgb=" << ch->rgb_buf.size() << endl;
|
|
|
|
|
+
|
|
|
|
|
+ // 检测与姿态并行推理(不同NPU核), 缩短单帧处理时间
|
|
|
vector<Detection> dets;
|
|
vector<Detection> dets;
|
|
|
- if (target_enabled)
|
|
|
|
|
|
|
+ vector<PersonPose> poses;
|
|
|
|
|
+ bool do_det = target_enabled;
|
|
|
|
|
+ bool do_pose = (pose_ok && ch->pose_running);
|
|
|
|
|
+ if (do_det && do_pose) {
|
|
|
|
|
+ std::thread tPose([&]() {
|
|
|
|
|
+ poses = poseDetector.detect(ch->rgb_buf.data(),
|
|
|
|
|
+ nv12.width, nv12.height,
|
|
|
|
|
+ scale, pad_x, pad_y);
|
|
|
|
|
+ });
|
|
|
dets = detector.detect(ch->rgb_buf.data(),
|
|
dets = detector.detect(ch->rgb_buf.data(),
|
|
|
nv12.width, nv12.height,
|
|
nv12.width, nv12.height,
|
|
|
scale, pad_x, pad_y);
|
|
scale, pad_x, pad_y);
|
|
|
|
|
+ tPose.join();
|
|
|
|
|
+ } else if (do_det) {
|
|
|
|
|
+ dets = detector.detect(ch->rgb_buf.data(),
|
|
|
|
|
+ nv12.width, nv12.height,
|
|
|
|
|
+ scale, pad_x, pad_y);
|
|
|
|
|
+ } else if (do_pose) {
|
|
|
|
|
+ poses = poseDetector.detect(ch->rgb_buf.data(),
|
|
|
|
|
+ nv12.width, nv12.height,
|
|
|
|
|
+ scale, pad_x, pad_y);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
vector<cv::Point2f> centers;
|
|
vector<cv::Point2f> centers;
|
|
|
vector<int> cids;
|
|
vector<int> cids;
|
|
@@ -1762,9 +1786,6 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
// ========== 姿态识别(跌倒检测) ==========
|
|
// ========== 姿态识别(跌倒检测) ==========
|
|
|
if (pose_ok && ch->pose_running) {
|
|
if (pose_ok && ch->pose_running) {
|
|
|
- auto poses = poseDetector.detect(ch->rgb_buf.data(),
|
|
|
|
|
- nv12.width, nv12.height,
|
|
|
|
|
- scale, pad_x, pad_y);
|
|
|
|
|
vector<PersonPose> falls;
|
|
vector<PersonPose> falls;
|
|
|
for (auto& p : poses) {
|
|
for (auto& p : poses) {
|
|
|
if (pose_alarm_classes.empty() ||
|
|
if (pose_alarm_classes.empty() ||
|