#include "../nodes/vp_file_src_node.h"
|
#include "../nodes/infers/vp_yolo_detector_node.h"
|
#include "../nodes/osd/vp_osd_node.h"
|
#include "../nodes/vp_split_node.h"
|
#include "../nodes/vp_screen_des_node.h"
|
#include "../nodes/vp_rtsp_des_node.h"
|
#include "../nodes/broker/vp_json_kafka_broker_node.h"
|
|
#include "../utils/analysis_board/vp_analysis_board.h"
|
|
/*
|
* ## firesmoke_detect_sample ##
|
* detect firesmoke using yolo.
|
*/
|
|
int main(int argc, char* argv[]) {
|
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
VP_LOGGER_INIT();
|
|
std::vector<std::string> args(argv + 1, argv + argc);
|
// 默认的命令行参数
|
std::string video_path1 = "./vp_data/test_video/smoke2.mp4";
|
std::string video_path2 = "./vp_data/test_video/fire.mp4";
|
|
float resize_ratio = 0.5;
|
|
// 如果提供了第一个和第二个参数,则覆盖默认的路径
|
if (args.size() >= 2) {
|
video_path1 = args[0];
|
video_path2 = args[1];
|
if (args.size() >= 3){
|
resize_ratio = std::stof(args[2]);
|
}
|
} else {
|
std::cout << "Usage: " << argv[0] << " <video_path1> <video_path2> [resize_ratio]\n";
|
std::cout << "Example: " << argv[0] << " ./vp_data/test_video/smoke2.mp4 ./vp_data/test_video/fire.mp4 0.5\n";
|
return -1;
|
}
|
|
// create nodes
|
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, video_path1, resize_ratio);
|
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, video_path2, resize_ratio);
|
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("firesmoke_detector", "./vp_data/models/det_cls/firesmoke_yolov5s.onnx", "", "./vp_data/models/det_cls/firesmoke_3classes.txt", 640, 384);
|
auto json_kafka_broker_0 = std::make_shared<vp_nodes::vp_json_kafka_broker_node>("json_kafka_broker_0", "192.168.130.228:9092", "vp_tracking", vp_nodes::vp_broke_for::NORMAL);
|
auto osd = std::make_shared<vp_nodes::vp_osd_node>("osd");
|
auto split = std::make_shared<vp_nodes::vp_split_node>("split_by_channel", true);
|
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
auto srceen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
|
// construct pipeline
|
yolo_detector->attach_to({file_src_0, file_src_1});
|
json_kafka_broker_0->attach_to({yolo_detector});
|
osd->attach_to({json_kafka_broker_0});
|
split->attach_to({osd});
|
screen_des_0->attach_to({split});
|
srceen_des_1->attach_to({split});
|
|
file_src_0->start();
|
file_src_1->start();
|
|
// for debug purpose
|
vp_utils::vp_analysis_board board({file_src_0, file_src_1});
|
board.display(1, false);
|
|
std::string wait;
|
std::getline(std::cin, wait);
|
file_src_0->detach_recursively();
|
file_src_1->detach_recursively();
|
}
|