first commit
This commit is contained in:
42
samples/1-1-1_sample.cpp
Normal file
42
samples/1-1-1_sample.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## 1-1-1 sample ##
|
||||
* 1 video input, 1 infer task, and 1 output.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
46
samples/1-1-N_sample.cpp
Normal file
46
samples/1-1-N_sample.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## 1-1-N sample ##
|
||||
* 1 video input, 1 infer task, and 2 outputs.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.8);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
|
||||
// auto split
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
53
samples/1-N-1_sample.cpp
Normal file
53
samples/1-N-1_sample.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_color_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_type_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_feature_encoder.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/vp_sync_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## 1-N-1_sample_sample ##
|
||||
* 1 input video, detect vehicles first,classify by colors and types in parallel, then sync data and output on screen.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes for 1-N-1 pipeline
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.6);
|
||||
auto trt_vehicle_detector_0 = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_detector_0", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", false, true); // split by deep-copy not by channel!
|
||||
auto trt_vehicle_color_classifier_0 = std::make_shared<vp_nodes::vp_trt_vehicle_color_classifier>("trt_color_cls_0", "./vp_data/models/trt/vehicle/vehicle_color_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto trt_vehicle_type_classifier_0 = std::make_shared<vp_nodes::vp_trt_vehicle_type_classifier>("trt_type_cls_0", "./vp_data/models/trt/vehicle/vehicle_type_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto sync = std::make_shared<vp_nodes::vp_sync_node>("sync", vp_nodes::vp_sync_mode::UPDATE, 160);
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct 1-N-1 pipeline
|
||||
trt_vehicle_detector_0->attach_to({file_src_0});
|
||||
split->attach_to({trt_vehicle_detector_0});
|
||||
trt_vehicle_color_classifier_0->attach_to({split});
|
||||
trt_vehicle_type_classifier_0->attach_to({split});
|
||||
sync->attach_to({trt_vehicle_color_classifier_0, trt_vehicle_type_classifier_0});
|
||||
osd_0->attach_to({sync});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
/*
|
||||
the format of pipeline:
|
||||
/ trt_vehicle_color_classifier_0 \
|
||||
file_src_0 -> trt_vehicle_detector_0 -> split -> -> sync -> osd_0 -> screen_des_0
|
||||
\ trt_vehicle_type_classifier_0 /
|
||||
*/
|
||||
|
||||
// start 1-N-1 pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipelines for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
54
samples/1-N-1_sample2.cpp
Normal file
54
samples/1-N-1_sample2.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_color_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_type_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_feature_encoder.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/vp_sync_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## 1-N-1_sample_sample ##
|
||||
* 1 input video, detect vehicles first,classify by colors and tracking vehicles in parallel, then sync data and output on screen.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::DEBUG);
|
||||
VP_SET_LOG_KEYWORDS_FOR_DEBUG({"sync"}); // only write debug log for sync node
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes for 1-N-1 pipeline
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/jam2.mp4");
|
||||
auto trt_vehicle_detector_0 = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_detector_0", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", false, true); // split by deep-copy not by channel!
|
||||
auto trt_vehicle_color_classifier_0 = std::make_shared<vp_nodes::vp_trt_vehicle_color_classifier>("trt_color_cls_0", "./vp_data/models/trt/vehicle/vehicle_color_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto track_0 = std::make_shared<vp_nodes::vp_sort_track_node>("track_0");
|
||||
auto sync = std::make_shared<vp_nodes::vp_sync_node>("sync", vp_nodes::vp_sync_mode::UPDATE, 160);
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct 1-N-1 pipeline
|
||||
trt_vehicle_detector_0->attach_to({file_src_0});
|
||||
split->attach_to({trt_vehicle_detector_0});
|
||||
trt_vehicle_color_classifier_0->attach_to({split});
|
||||
track_0->attach_to({split});
|
||||
sync->attach_to({trt_vehicle_color_classifier_0, track_0});
|
||||
osd_0->attach_to({sync});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
/*
|
||||
the format of pipeline:
|
||||
/ trt_vehicle_color_classifier_0 \
|
||||
file_src_0 -> trt_vehicle_detector_0 -> split -> -> sync -> osd_0 -> screen_des_0
|
||||
\ track_0 /
|
||||
*/
|
||||
|
||||
// start 1-N-1 pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipelines for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
55
samples/1-N-1_sample3.cpp
Normal file
55
samples/1-N-1_sample3.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_color_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_plate_detector_v2.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/vp_sync_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## 1-N-1_sample_sample ##
|
||||
* 1 input video, detect vehicles + classify by colors, detect license plate + track by sort, 2 tasks in parallel,then sync data and output on screen.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::DEBUG);
|
||||
VP_SET_LOG_KEYWORDS_FOR_DEBUG({"sync"}); // only write debug log for sync node
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes for 1-N-1 pipeline
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/plate2.mp4");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", false, true); // split by deep-copy not by channel!
|
||||
auto vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto vehicle_color_cls = std::make_shared<vp_nodes::vp_trt_vehicle_color_classifier>("vehicle_color_cls", "./vp_data/models/trt/vehicle/vehicle_color_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto plate_detector = std::make_shared<vp_nodes::vp_trt_vehicle_plate_detector_v2>("plate_detector", "./vp_data/models/trt/plate/det_v8.5.trt", "./vp_data/models/trt/plate/rec_v8.5.trt");
|
||||
auto plate_tracker = std::make_shared<vp_nodes::vp_sort_track_node>("plate_tracker");
|
||||
auto sync = std::make_shared<vp_nodes::vp_sync_node>("sync");
|
||||
auto osd = std::make_shared<vp_nodes::vp_osd_node>("osd", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct 1-N-1 pipeline
|
||||
split->attach_to({file_src_0});
|
||||
vehicle_detector->attach_to({split});
|
||||
plate_detector->attach_to({split});
|
||||
vehicle_color_cls->attach_to({vehicle_detector});
|
||||
plate_tracker->attach_to({plate_detector});
|
||||
sync->attach_to({vehicle_color_cls, plate_tracker});
|
||||
osd->attach_to({sync});
|
||||
screen_des_0->attach_to({osd});
|
||||
/*
|
||||
the format of pipeline:
|
||||
/ vehicle_detector -> vehicle_color_cls \
|
||||
file_src_0 -> split -> -> sync -> osd -> screen_des_0
|
||||
\ plate_detector -> plate_tracker /
|
||||
*/
|
||||
|
||||
// start 1-N-1 pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipelines for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
60
samples/1-N-N_sample.cpp
Normal file
60
samples/1-N-N_sample.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## 1-N-N sample ##
|
||||
* 1 video input and then split into 2 branches for different infer tasks, then 2 total outputs(no need to sync in such situations).
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", false, true); // split by deep-copy not by channel!
|
||||
|
||||
// branch a
|
||||
auto yunet_face_detector_a = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_a", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_a = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_a", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_a = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_a");
|
||||
auto screen_des_a = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_a", 0);
|
||||
|
||||
// branch b
|
||||
auto yunet_face_detector_b = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_b", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_b = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_b", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_b = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_b");
|
||||
auto screen_des_b = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_b", 0);
|
||||
|
||||
// construct pipeline
|
||||
split->attach_to({file_src_0});
|
||||
|
||||
// branch a
|
||||
yunet_face_detector_a->attach_to({split});
|
||||
sface_face_encoder_a->attach_to({yunet_face_detector_a});
|
||||
osd_a->attach_to({sface_face_encoder_a});
|
||||
screen_des_a->attach_to({osd_a});
|
||||
|
||||
// branch b
|
||||
yunet_face_detector_b->attach_to({split});
|
||||
sface_face_encoder_b->attach_to({yunet_face_detector_b});
|
||||
osd_b->attach_to({sface_face_encoder_b});
|
||||
screen_des_b->attach_to({osd_b});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
240
samples/CMakeLists.txt
Normal file
240
samples/CMakeLists.txt
Normal file
@@ -0,0 +1,240 @@
|
||||
# can ONLY be called by parent CMakeLists.txt, because no environment settings for this script.#
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
message(FATAL_ERROR "can ONLY be called by parent CMakeLists.txt.")
|
||||
endif()
|
||||
|
||||
message("start build for simple samples...")
|
||||
# save all exe to 'build/bin'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
add_executable(1-1-1_sample "1-1-1_sample.cpp")
|
||||
target_link_libraries(1-1-1_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(1-1-N_sample "1-1-N_sample.cpp")
|
||||
target_link_libraries(1-1-N_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(1-N-N_sample "1-N-N_sample.cpp")
|
||||
target_link_libraries(1-N-N_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(ba_crossline_sample "ba_crossline_sample.cpp")
|
||||
target_link_libraries(ba_crossline_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(enet_seg_sample "enet_seg_sample.cpp")
|
||||
target_link_libraries(enet_seg_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(face_tracking_sample "face_tracking_sample.cpp")
|
||||
target_link_libraries(face_tracking_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(image_des_sample "image_des_sample.cpp")
|
||||
target_link_libraries(image_des_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(image_src_sample "image_src_sample.cpp")
|
||||
target_link_libraries(image_src_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(interaction_with_pipe_sample "interaction_with_pipe_sample.cpp")
|
||||
target_link_libraries(interaction_with_pipe_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(mask_rcnn_sample "mask_rcnn_sample.cpp")
|
||||
target_link_libraries(mask_rcnn_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(message_broker_sample "message_broker_sample.cpp")
|
||||
target_link_libraries(message_broker_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(multi_detectors_and_classifiers_sample "multi_detectors_and_classifiers_sample.cpp")
|
||||
target_link_libraries(multi_detectors_and_classifiers_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(N-1-N_sample "N-1-N_sample.cpp")
|
||||
target_link_libraries(N-1-N_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(N-N_sample "N-N_sample.cpp")
|
||||
target_link_libraries(N-N_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(openpose_sample "openpose_sample.cpp")
|
||||
target_link_libraries(openpose_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(record_sample "record_sample.cpp")
|
||||
target_link_libraries(record_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(rtsp_des_sample "rtsp_des_sample.cpp")
|
||||
target_link_libraries(rtsp_des_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(rtsp_src_sample "rtsp_src_sample.cpp")
|
||||
target_link_libraries(rtsp_src_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(vp_logger_sample "vp_logger_sample.cpp")
|
||||
target_link_libraries(vp_logger_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(skip_sample "skip_sample.cpp")
|
||||
target_link_libraries(skip_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(obstacle_detect_sample "obstacle_detect_sample.cpp")
|
||||
target_link_libraries(obstacle_detect_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(multi_detectors_sample "multi_detectors_sample.cpp")
|
||||
target_link_libraries(multi_detectors_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(firesmoke_detect_sample "firesmoke_detect_sample.cpp")
|
||||
target_link_libraries(firesmoke_detect_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(face_swap_sample "face_swap_sample.cpp")
|
||||
target_link_libraries(face_swap_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(video_restoration_sample "video_restoration_sample.cpp")
|
||||
target_link_libraries(video_restoration_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(app_des_sample "app_des_sample.cpp")
|
||||
target_link_libraries(app_des_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(app_src_des_sample "app_src_des_sample.cpp")
|
||||
target_link_libraries(app_src_des_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(lane_detect_sample "lane_detect_sample.cpp")
|
||||
target_link_libraries(lane_detect_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(frame_fusion_sample "frame_fusion_sample.cpp")
|
||||
target_link_libraries(frame_fusion_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(yolov5_seg_sample "yolov5_seg_sample.cpp")
|
||||
target_link_libraries(yolov5_seg_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(vp_test "vp_test.cpp")
|
||||
target_link_libraries(vp_test ${PROJECT_NAME})
|
||||
|
||||
# samples depend on Kafka
|
||||
if(VP_WITH_KAFKA)
|
||||
add_executable(message_broker_kafka_sample "message_broker_kafka_sample.cpp")
|
||||
target_link_libraries(message_broker_kafka_sample ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
# samples depend on LLM
|
||||
if(VP_WITH_LLM)
|
||||
add_executable(mllm_analyse_sample "mllm_analyse_sample.cpp")
|
||||
target_link_libraries(mllm_analyse_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(mllm_analyse_sample_openai "mllm_analyse_sample_openai.cpp")
|
||||
target_link_libraries(mllm_analyse_sample_openai ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
# samples depend on FFmpeg
|
||||
if(VP_WITH_FFMPEG)
|
||||
add_executable(ffmpeg_src_des_sample "ffmpeg_src_des_sample.cpp")
|
||||
target_link_libraries(ffmpeg_src_des_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(ffmpeg_transcode_sample "ffmpeg_transcode_sample.cpp")
|
||||
target_link_libraries(ffmpeg_transcode_sample ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
# samples depend on PaddlePaddle
|
||||
if(VP_WITH_PADDLE)
|
||||
add_executable(app_src_sample "app_src_sample.cpp")
|
||||
target_link_libraries(app_src_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(paddle_infer_sample "paddle_infer_sample.cpp")
|
||||
target_link_libraries(paddle_infer_sample ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
# samples depend on CUDA(maybe other dependency required too)
|
||||
if(VP_WITH_CUDA)
|
||||
# nvdec & nvenc plugins required from DeepStream
|
||||
add_executable(nv_hard_codec_sample "nv_hard_codec_sample.cpp")
|
||||
target_link_libraries(nv_hard_codec_sample ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
# samples depend on TensorRT
|
||||
if(VP_WITH_TRT)
|
||||
add_executable(ba_jam_sample "ba_jam_sample.cpp")
|
||||
target_link_libraries(ba_jam_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(ba_stop_sample "ba_stop_sample.cpp")
|
||||
target_link_libraries(ba_stop_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(body_scan_and_plate_detect_sample "body_scan_and_plate_detect_sample.cpp")
|
||||
target_link_libraries(body_scan_and_plate_detect_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(dynamic_pipeline_sample "dynamic_pipeline_sample.cpp")
|
||||
target_link_libraries(dynamic_pipeline_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(dynamic_pipeline_sample2 "dynamic_pipeline_sample2.cpp")
|
||||
target_link_libraries(dynamic_pipeline_sample2 ${PROJECT_NAME})
|
||||
|
||||
add_executable(message_broker_sample2 "message_broker_sample2.cpp")
|
||||
target_link_libraries(message_broker_sample2 ${PROJECT_NAME})
|
||||
|
||||
add_executable(multi_trt_infer_nodes_sample "multi_trt_infer_nodes_sample.cpp")
|
||||
target_link_libraries(multi_trt_infer_nodes_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(plate_recognize_sample "plate_recognize_sample.cpp")
|
||||
target_link_libraries(plate_recognize_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(src_des_sample "src_des_sample.cpp")
|
||||
target_link_libraries(src_des_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(trt_infer_sample "trt_infer_sample.cpp")
|
||||
target_link_libraries(trt_infer_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(vehicle_body_scan_sample "vehicle_body_scan_sample.cpp")
|
||||
target_link_libraries(vehicle_body_scan_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(vehicle_cluster_based_on_classify_encoding_sample "vehicle_cluster_based_on_classify_encoding_sample.cpp")
|
||||
target_link_libraries(vehicle_cluster_based_on_classify_encoding_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(vehicle_tracking_sample "vehicle_tracking_sample.cpp")
|
||||
target_link_libraries(vehicle_tracking_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(1-N-1_sample "1-N-1_sample.cpp")
|
||||
target_link_libraries(1-N-1_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(1-N-1_sample2 "1-N-1_sample2.cpp")
|
||||
target_link_libraries(1-N-1_sample2 ${PROJECT_NAME})
|
||||
|
||||
add_executable(1-N-1_sample3 "1-N-1_sample3.cpp")
|
||||
target_link_libraries(1-N-1_sample3 ${PROJECT_NAME})
|
||||
|
||||
add_executable(trt_yolov8_sample "trt_yolov8_sample.cpp")
|
||||
target_link_libraries(trt_yolov8_sample ${PROJECT_NAME})
|
||||
|
||||
add_executable(trt_yolov8_sample2 "trt_yolov8_sample2.cpp")
|
||||
target_link_libraries(trt_yolov8_sample2 ${PROJECT_NAME})
|
||||
|
||||
add_executable(rtmp_src_sample "rtmp_src_sample.cpp")
|
||||
target_link_libraries(rtmp_src_sample ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
if(VP_BUILD_COMPLEX_SAMPLES)
|
||||
message("start build for complex sampels...")
|
||||
# save exe to 'face_recognize'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/face_recognize)
|
||||
add_executable(face_recognize_pipeline "face_recognize/face_recognize_pipeline.cpp")
|
||||
target_link_libraries(face_recognize_pipeline ${PROJECT_NAME})
|
||||
|
||||
if(VP_WITH_TRT) # samples depend on TensorRT
|
||||
# save exe to 'similiarity_search'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/similiarity_search)
|
||||
add_executable(face_encoding_pipeline "similiarity_search/face_encoding_pipeline.cpp")
|
||||
target_link_libraries(face_encoding_pipeline ${PROJECT_NAME})
|
||||
add_executable(vehicle_encoding_pipeline "similiarity_search/vehicle_encoding_pipeline.cpp")
|
||||
target_link_libraries(vehicle_encoding_pipeline ${PROJECT_NAME})
|
||||
|
||||
# save exe to 'vehicle_behaviour_analysis'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vehicle_behaviour_analysis)
|
||||
add_executable(vehicle_ba_pipeline "vehicle_behaviour_analysis/vehicle_ba_pipeline.cpp")
|
||||
target_link_libraries(vehicle_ba_pipeline ${PROJECT_NAME})
|
||||
|
||||
# save exe to 'vehicle_property_and_similiarity_search'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vehicle_property_and_similiarity_search)
|
||||
add_executable(vehicle_encoding_classify_pipeline "vehicle_property_and_similiarity_search/vehicle_encoding_classify_pipeline.cpp")
|
||||
target_link_libraries(vehicle_encoding_classify_pipeline ${PROJECT_NAME})
|
||||
|
||||
# save exe to 'lpr_camera'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lpr_camera)
|
||||
add_executable(plate_recognize_pipeline "lpr_camera/plate_recognize_pipeline.cpp")
|
||||
target_link_libraries(plate_recognize_pipeline ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
if(VP_WITH_PADDLE)
|
||||
# save exe to 'math_review'
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/math_review)
|
||||
add_executable(math_expression_check_pipeline "math_review/math_expression_check_pipeline.cpp")
|
||||
target_link_libraries(math_expression_check_pipeline ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
61
samples/N-1-N_sample.cpp
Normal file
61
samples/N-1-N_sample.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## N-1-N sample ##
|
||||
* 2 video input and merge into 1 branch automatically for 1 infer task, then resume to 2 branches for outputs again.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::WARN);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/face2.mp4", 0.6);
|
||||
auto yunet_face_detector = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true); // split by channel index
|
||||
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
auto osd_1 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_1");
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
auto rtmp_des_1 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_1", 1, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector->attach_to({file_src_0, file_src_1});
|
||||
sface_face_encoder->attach_to({yunet_face_detector});
|
||||
|
||||
split->attach_to({sface_face_encoder});
|
||||
|
||||
// split by vp_split_node
|
||||
osd_0->attach_to({split});
|
||||
osd_1->attach_to({split});
|
||||
|
||||
// auto split again on channel 0
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
|
||||
// auto split again on channel 1
|
||||
screen_des_1->attach_to({osd_1});
|
||||
rtmp_des_1->attach_to({osd_1});
|
||||
|
||||
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();
|
||||
}
|
||||
52
samples/N-N_sample.cpp
Normal file
52
samples/N-N_sample.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## N-N sample ##
|
||||
* multi pipe exist separately and each pipe is 1-1-1 (can be any structure like 1-1-N, 1-N-N)
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 0, "./vp_data/test_video/face2.mp4");
|
||||
auto yunet_face_detector_1 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_1", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_1 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_1", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_1 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_1");
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 0);
|
||||
|
||||
// construct pipeline
|
||||
// pipe 0
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// pipe 1
|
||||
yunet_face_detector_1->attach_to({file_src_1});
|
||||
sface_face_encoder_1->attach_to({yunet_face_detector_1});
|
||||
osd_1->attach_to({sface_face_encoder_1});
|
||||
screen_des_1->attach_to({osd_1});
|
||||
|
||||
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();
|
||||
}
|
||||
144
samples/README.md
Normal file
144
samples/README.md
Normal file
@@ -0,0 +1,144 @@
|
||||
|
||||
## 1-1-1_sample ##
|
||||
1 video input, 1 infer task, and 1 output.
|
||||

|
||||
|
||||
## 1-1-N_sample ##
|
||||
1 video input, 1 infer task, and 2 outputs.
|
||||

|
||||
|
||||
|
||||
## 1-N-N_sample ##
|
||||
1 video input and then split into 2 branches for different infer tasks, then 2 total outputs.
|
||||

|
||||
|
||||
|
||||
## N-1-N_sample ##
|
||||
2 video input and merge into 1 branch automatically for 1 infer task, then resume to 2 branches for outputs again.
|
||||

|
||||
|
||||
|
||||
## N-N_sample ##
|
||||
multi pipe exist separately and each pipe is 1-1-1 (can be any structure like 1-1-N, 1-N-N)
|
||||

|
||||
|
||||
|
||||
## paddle_infer_sample ##
|
||||
ocr based on paddle (install paddle_inference first!), 1 video input and 2 outputs (screen, rtmp)
|
||||

|
||||
|
||||
|
||||
## src_des_sample ##
|
||||
show how src nodes and des nodes work.
|
||||
3 (file, rtsp, udp) input and merge into 1 infer task, then resume to 3 branches for outputs (screen, rtmp, fake)
|
||||

|
||||
|
||||
|
||||
## trt_infer_sample ##
|
||||
vehicle and plate detector based on tensorrt (install tensorrt first!), 1 video input and 3 outputs (screen, file, rtmp)
|
||||

|
||||
|
||||
|
||||
## vp_logger_sample ##
|
||||
show how `vp_logger` works.
|
||||
|
||||
## face_tracking_sample ##
|
||||
tracking for multi faces.
|
||||

|
||||
|
||||
## vehicle_tracking_sample ##
|
||||
tracking for multi vehicles.
|
||||

|
||||
|
||||
## interaction_with_pipe_sample ##
|
||||
show how to interact with pipe, such as start/stop channel by calling api.
|
||||
|
||||
## record_sample ##
|
||||
show how `vp_record_node` works.
|
||||
|
||||
## message_broker_sample & message_broker_sample2 ##
|
||||
show how message broker nodes work.
|
||||

|
||||

|
||||
|
||||
## mask_rcnn_sample ##
|
||||
show image segmentation by mask-rcnn.
|
||||

|
||||
|
||||
## openpose_sample ##
|
||||
show pose estimation by openpose network.
|
||||

|
||||
|
||||
## enet_seg_sample ##
|
||||
show semantic segmentation by enet network.
|
||||

|
||||
|
||||
## multi_detectors_and_classifiers_sample ##
|
||||
show multi infer node work together.
|
||||

|
||||
|
||||
## image_des_sample ##
|
||||
show save/push image to local file or remote via udp.
|
||||

|
||||
|
||||
## image_src_sample ##
|
||||
show read/receive image from local file or remote via udp.
|
||||

|
||||
|
||||
## rtsp_des_sample ##
|
||||
show push video stream via rtsp, no rtsp server needed, you can visit it directly.
|
||||

|
||||
|
||||
## ba_crossline_sample ##
|
||||
count for vehicle based on tracking, the simplest one of behaviour analysis.
|
||||

|
||||
|
||||
## plate_recognize_sample ##
|
||||
vehicle plate detect and recognize on the whole frame (no need to detect vechile first)
|
||||

|
||||
|
||||
## vehicle_body_scan_sample ##
|
||||
detect parts of vehicle based on side view of body
|
||||

|
||||
|
||||
## body_scan_and_plate_detect_sample ##
|
||||
2 channels to detect parts of vehicle and detect vehicle plate, you can do something like data fusion later
|
||||

|
||||
|
||||
## app_src_sample ##
|
||||
send data to pipeline from host coda using app_src_node
|
||||

|
||||
|
||||
## vehicle_cluster_based_on_classify_encoding_sample ##
|
||||
vehicle cluster based on labels(classify) and encoding(feature extract), pipeline would display 3 windows (cluster by t-SNE, cluster by labels, detect result)
|
||||

|
||||
|
||||
## ba_stop_sample ##
|
||||
vehicle stop behaviour analysis
|
||||

|
||||
|
||||
## similiarity search ##
|
||||
flask demo for vehicle and face similiarity search <br/>
|
||||

|
||||
|
||||
## behaviour analysis ##
|
||||
flask demo for crossline and stop<br/>
|
||||

|
||||
|
||||
## property and similiarity search ##
|
||||
flask demo for vehicle search by similiarity and properties<br/>
|
||||

|
||||
|
||||
## ba_jam_sample ##
|
||||
traffic jam behaviour analysis<br/>
|
||||

|
||||
|
||||
## face recognize ##
|
||||
flask demo for face recognize<br/>
|
||||

|
||||
|
||||
## license plate recognize ##
|
||||
flask demo for license plate recognize<br/>
|
||||

|
||||
|
||||
[for more samples](../SAMPLES.md)
|
||||
55
samples/app_des_sample.cpp
Normal file
55
samples/app_des_sample.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node.h"
|
||||
#include "../nodes/vp_app_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## app_des_sample ##
|
||||
* 1. reading video from file
|
||||
* 2. detect faces and draw results
|
||||
* 3. display on screen in host code using cv::imshow(...)
|
||||
* using vp_app_des_node INSTEAD OF vp_screen_des_node for displaying.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4");
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node>("osd_0");
|
||||
auto app_des_0 = std::make_shared<vp_nodes::vp_app_des_node>("app_des_0", 0);
|
||||
|
||||
// register callback to display result
|
||||
std::string ori_win_title = "original frame using cv::imshow(...)";
|
||||
std::string osd_win_title = "osd frame using cv::imshow(...)";
|
||||
cv::namedWindow(ori_win_title,cv::WindowFlags::WINDOW_NORMAL);
|
||||
cv::namedWindow(osd_win_title,cv::WindowFlags::WINDOW_NORMAL);
|
||||
app_des_0->set_app_des_result_hooker([&](std::string node_name, std::shared_ptr<vp_objects::vp_meta> meta) {
|
||||
// only deal with frame meta
|
||||
if (meta->meta_type == vp_objects::vp_meta_type::FRAME) {
|
||||
auto frame_meta = std::dynamic_pointer_cast<vp_objects::vp_frame_meta>(meta);
|
||||
cv::imshow(ori_win_title, frame_meta->frame);
|
||||
|
||||
// osd frame may be empty
|
||||
if (!frame_meta->osd_frame.empty()) {
|
||||
cv::imshow(osd_win_title, frame_meta->osd_frame);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
osd_0->attach_to({yunet_face_detector_0});
|
||||
app_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
75
samples/app_src_des_sample.cpp
Normal file
75
samples/app_src_des_sample.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "../nodes/vp_app_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node.h"
|
||||
#include "../nodes/vp_app_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## app_src_des_sample ##
|
||||
* 1. receive images from host code, based on vp_app_src_node
|
||||
* 2. detect faces and draw results
|
||||
* 3. display on screen in host code again using cv::imshow(...) and print rectangles and keypoints of face, based on vp_app_des_node
|
||||
* we treat VideoPipe(pipeline) as a simple face detector tool in this sample.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto app_src_0 = std::make_shared<vp_nodes::vp_app_src_node>("app_src_0", 0);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node>("osd_0");
|
||||
auto app_des_0 = std::make_shared<vp_nodes::vp_app_des_node>("app_des_0", 0);
|
||||
|
||||
// register callback to display result
|
||||
std::string ori_win_title = "original frame using cv::imshow(...)";
|
||||
std::string osd_win_title = "osd frame using cv::imshow(...)";
|
||||
cv::namedWindow(ori_win_title,cv::WindowFlags::WINDOW_NORMAL);
|
||||
cv::namedWindow(osd_win_title,cv::WindowFlags::WINDOW_NORMAL);
|
||||
app_des_0->set_app_des_result_hooker([&](std::string node_name, std::shared_ptr<vp_objects::vp_meta> meta) {
|
||||
// only deal with frame meta
|
||||
if (meta->meta_type == vp_objects::vp_meta_type::FRAME) {
|
||||
auto frame_meta = std::dynamic_pointer_cast<vp_objects::vp_frame_meta>(meta);
|
||||
cv::imshow(ori_win_title, frame_meta->frame);
|
||||
|
||||
// osd frame may be empty
|
||||
if (!frame_meta->osd_frame.empty()) {
|
||||
cv::imshow(osd_win_title, frame_meta->osd_frame);
|
||||
}
|
||||
|
||||
// print rectangle and keypoints of face
|
||||
std::cout << "detected " << frame_meta->face_targets.size() << " faces:(print from host code)" << std::endl;
|
||||
for (int i = 0; i < frame_meta->face_targets.size(); ++i) {
|
||||
auto f = frame_meta->face_targets[i];
|
||||
std::cout << i << ": [" << f->x << "," << f->y << "," << f->width << "," << f->height << "] [";
|
||||
for (auto k: f->key_points) {
|
||||
std::cout << "(" << k.first << "," << k.second << ")";
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({app_src_0});
|
||||
osd_0->attach_to({yunet_face_detector_0});
|
||||
app_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
app_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({app_src_0});
|
||||
board.display(1, false); // no block
|
||||
|
||||
// read image in host code manually
|
||||
auto img = cv::imread("./vp_data/test_images/faces/swap/2mans.jpg");
|
||||
// push image to pipeline in host code manually
|
||||
app_src_0->push_frames({img});
|
||||
|
||||
// pipeline will process image asynchronously and display result here...
|
||||
std::string wait;
|
||||
std:getline(std::cin, wait);
|
||||
}
|
||||
80
samples/app_src_sample.cpp
Normal file
80
samples/app_src_sample.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "../nodes/vp_app_src_node.h"
|
||||
#include "../nodes/infers/vp_ppocr_text_detector_node.h"
|
||||
#include "../nodes/osd/vp_text_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## app src sample ##
|
||||
* receive frames(cv::Mat) from host code
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto app_src_0 = std::make_shared<vp_nodes::vp_app_src_node>("app_src_0", 0);
|
||||
auto ppocr_text_detector = std::make_shared<vp_nodes::vp_ppocr_text_detector_node>("ppocr_text_detector",
|
||||
"./vp_data/models/text/ppocr/ch_PP-OCRv3_det_infer",
|
||||
"./vp_data/models/text/ppocr/ch_ppocr_mobile_v2.0_cls_infer",
|
||||
"./vp_data/models/text/ppocr/ch_PP-OCRv3_rec_infer",
|
||||
"./vp_data/models/text/ppocr/ppocr_keys_v1.txt");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_text_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
ppocr_text_detector->attach_to({app_src_0});
|
||||
osd_0->attach_to({ppocr_text_detector});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
app_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({app_src_0});
|
||||
board.display(1, false); // no block since we need interactions from console later
|
||||
|
||||
// simulate push frame to pipeline regularly in a separate thread
|
||||
bool exit = false;
|
||||
auto simulate_run = [&]() {
|
||||
auto index = 0;
|
||||
auto count = 0;
|
||||
auto path = "./vp_data/test_images/text/";
|
||||
while (!exit) {
|
||||
auto frame = cv::imread(path + std::to_string(index) + ".jpg");
|
||||
assert(!frame.empty());
|
||||
|
||||
app_src_0->push_frames({frame}); // push frame to pipeline, return false means failed
|
||||
count++;
|
||||
std::cout << "main thread has pushed [" << count << "] frames into pipeline..." << std::endl;
|
||||
|
||||
index++;
|
||||
index = index % 3;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000)); // sleep for 2 seconds
|
||||
}
|
||||
};
|
||||
std::thread simulate_thread(simulate_run);
|
||||
|
||||
/* interact from console, start or stop the pipeline */
|
||||
/* no except check */
|
||||
std::string input;
|
||||
std::getline(std::cin, input);
|
||||
while (input != "quit") {
|
||||
if (input == "start") {
|
||||
app_src_0->start();
|
||||
}
|
||||
else if (input == "stop") {
|
||||
app_src_0->stop(); // app_src_0->push_frames(...) will print Warn message since it has stopped working
|
||||
}
|
||||
else {
|
||||
std::cout << "invalid command!" << std::endl;
|
||||
}
|
||||
std::getline(std::cin, input);
|
||||
}
|
||||
|
||||
std::cout << "app_src_sample sample exits..." << std::endl;
|
||||
exit = true;
|
||||
simulate_thread.join();
|
||||
app_src_0->detach_recursively();
|
||||
}
|
||||
51
samples/ba_crossline_sample.cpp
Normal file
51
samples/ba_crossline_sample.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yolo_detector_node.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/ba/vp_ba_crossline_node.h"
|
||||
#include "../nodes/osd/vp_ba_crossline_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## ba crossline sample ##
|
||||
* behaviour analysis for crossline.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.4);
|
||||
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("yolo_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt");
|
||||
auto tracker = std::make_shared<vp_nodes::vp_sort_track_node>("sort_tracker");
|
||||
|
||||
// define a line in frame for every channel (value MUST in the scope of frame'size)
|
||||
vp_objects::vp_point start(0, 250); // change to proper value
|
||||
vp_objects::vp_point end(700, 220); // change to proper value
|
||||
std::map<int, vp_objects::vp_line> lines = {{0, vp_objects::vp_line(start, end)}}; // channel0 -> line
|
||||
auto ba_crossline = std::make_shared<vp_nodes::vp_ba_crossline_node>("ba_crossline", lines);
|
||||
auto osd = std::make_shared<vp_nodes::vp_ba_crossline_osd_node>("osd");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/9000");
|
||||
|
||||
// construct pipeline
|
||||
yolo_detector->attach_to({file_src_0});
|
||||
tracker->attach_to({yolo_detector});
|
||||
ba_crossline->attach_to({tracker});
|
||||
osd->attach_to({ba_crossline});
|
||||
screen_des_0->attach_to({osd});
|
||||
rtmp_des_0->attach_to({osd});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
67
samples/ba_jam_sample.cpp
Normal file
67
samples/ba_jam_sample.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/ba/vp_ba_jam_node.h"
|
||||
#include "../nodes/osd/vp_ba_jam_osd_node.h"
|
||||
#include "../nodes/record/vp_record_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## ba jam sample ##
|
||||
* behaviour analysis for jam, single instance of ba node work on 2 channels.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/jam.mp4", 0.5);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/jam2.mp4");
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto tracker = std::make_shared<vp_nodes::vp_sort_track_node>("sort_tracker");
|
||||
|
||||
// define a region in frame for every channel (value MUST in the scope of frame'size)
|
||||
std::map<int, std::vector<vp_objects::vp_point>> regions = {
|
||||
{0, std::vector<vp_objects::vp_point>{vp_objects::vp_point(20, 360),
|
||||
vp_objects::vp_point(400, 250),
|
||||
vp_objects::vp_point(535, 250),
|
||||
vp_objects::vp_point(555, 560),
|
||||
vp_objects::vp_point(30, 550)}}, // channel0 -> region
|
||||
{1, std::vector<vp_objects::vp_point>{vp_objects::vp_point(20*0.6, 588*0.6),
|
||||
vp_objects::vp_point(786*0.6, 180*0.6),
|
||||
vp_objects::vp_point(968*0.6, 166*0.6),
|
||||
vp_objects::vp_point(1220*0.6, 665*0.6)}} // channel1 -> region
|
||||
};
|
||||
auto ba_jam = std::make_shared<vp_nodes::vp_ba_jam_node>("ba_jam", regions);
|
||||
auto osd = std::make_shared<vp_nodes::vp_ba_jam_osd_node>("jam_osd");
|
||||
auto recorder = std::make_shared<vp_nodes::vp_record_node>("recorder", "./record", "./record");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true);
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({file_src_0, file_src_1});
|
||||
tracker->attach_to({trt_vehicle_detector});
|
||||
ba_jam->attach_to({tracker});
|
||||
osd->attach_to({ba_jam});
|
||||
recorder->attach_to({osd});
|
||||
split->attach_to({recorder});
|
||||
screen_des_0->attach_to({split});
|
||||
screen_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();
|
||||
}
|
||||
52
samples/ba_stop_sample.cpp
Normal file
52
samples/ba_stop_sample.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/ba/vp_ba_stop_node.h"
|
||||
#include "../nodes/osd/vp_ba_stop_osd_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## ba stop sample ##
|
||||
* behaviour analysis for stop, single instance of ba node work on 2 channels.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_stop.mp4", 0.6);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/vehicle_stop.mp4", 0.6);
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data//models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto tracker = std::make_shared<vp_nodes::vp_sort_track_node>("sort_tracker");
|
||||
|
||||
// define a region in frame for every channel (value MUST in the scope of frame'size)
|
||||
std::map<int, std::vector<vp_objects::vp_point>> regions = {
|
||||
{0, std::vector<vp_objects::vp_point>{vp_objects::vp_point(20, 30), vp_objects::vp_point(600, 40), vp_objects::vp_point(600, 300), vp_objects::vp_point(10, 300)}}, // channel0 -> region
|
||||
{1, std::vector<vp_objects::vp_point>{vp_objects::vp_point(20, 30), vp_objects::vp_point(1000, 40), vp_objects::vp_point(1000, 600), vp_objects::vp_point(10, 600)}} // channel1 -> region
|
||||
};
|
||||
auto ba_stop = std::make_shared<vp_nodes::vp_ba_stop_node>("ba_stop", regions);
|
||||
auto osd = std::make_shared<vp_nodes::vp_ba_stop_osd_node>("osd");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true);
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({file_src_0, file_src_1});
|
||||
tracker->attach_to({trt_vehicle_detector});
|
||||
ba_stop->attach_to({tracker});
|
||||
osd->attach_to({ba_stop});
|
||||
split->attach_to({osd});
|
||||
screen_des_0->attach_to({split});
|
||||
screen_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();
|
||||
}
|
||||
52
samples/body_scan_and_plate_detect_sample.cpp
Normal file
52
samples/body_scan_and_plate_detect_sample.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_scanner.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_plate_detector_v2.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/osd/vp_plate_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## body_scan_and_plate_detect_sample ##
|
||||
* first channel detects wheels and vehicle type based on side view of vehicle
|
||||
* second channel detects plate based on head view of vehicle
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_src_0", 0, "./vp_data/test_images/body/%d.jpg");
|
||||
auto image_src_1 = std::make_shared<vp_nodes::vp_image_src_node>("image_src_1", 1, "./vp_data/test_images/plates/%d.jpg");
|
||||
auto vehicle_scanner = std::make_shared<vp_nodes::vp_trt_vehicle_scanner>("vehicle_scanner",
|
||||
"./vp_data/models/trt/vehicle/vehicle_scan_v8.5.trt");
|
||||
auto plate_detector = std::make_shared<vp_nodes::vp_trt_vehicle_plate_detector_v2>("plate_detector",
|
||||
"./vp_data/models/trt/plate/det_v8.5.trt",
|
||||
"./vp_data/models/trt/plate/rec_v8.5.trt");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0");
|
||||
auto osd_1 = std::make_shared<vp_nodes::vp_plate_osd_node>("osd_1", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
|
||||
// construct first pipeline
|
||||
vehicle_scanner->attach_to({image_src_0});
|
||||
osd_0->attach_to({vehicle_scanner});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
// construct second pipeline
|
||||
plate_detector->attach_to({image_src_1});
|
||||
osd_1->attach_to({plate_detector});
|
||||
screen_des_1->attach_to({osd_1});
|
||||
|
||||
image_src_0->start();
|
||||
image_src_1->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({image_src_0, image_src_1});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
image_src_0->detach_recursively();
|
||||
image_src_1->detach_recursively();
|
||||
}
|
||||
175
samples/dynamic_pipeline_sample.cpp
Normal file
175
samples/dynamic_pipeline_sample.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_color_classifier.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/broker/vp_json_console_broker_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## dynamic_pipeline_sample ##
|
||||
* 1. insert and remove channels(SRC & DES nodes) to/from existing pipeline.
|
||||
* 2. insert and remove MID nodes to/from existing pipeline.
|
||||
* 3. all nodes destroy and process exit normally after user press enter from console.
|
||||
* 4. no need to stop the pipeline and all operations in multi-threads, it works with hot-plug mode.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_stop.mp4", 0.4);
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto osd = std::make_shared<vp_nodes::vp_osd_node>("osd", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true);
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline the first time
|
||||
trt_vehicle_detector->attach_to({file_src_0});
|
||||
osd->attach_to({trt_vehicle_detector});
|
||||
split->attach_to({osd});
|
||||
screen_des_0->attach_to({split});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
// visualize pipeline for debug
|
||||
std::vector<std::shared_ptr<vp_nodes::vp_node>> src_nodes = {file_src_0};
|
||||
vp_utils::vp_analysis_board board(src_nodes);
|
||||
board.display(1, false); // no block
|
||||
/* the original format of pipeline is:
|
||||
file_src_0 -> trt_vehicle_detector -> osd -> split -> screen_des_0
|
||||
*/
|
||||
|
||||
// simulation function for dynamically operating on piepline
|
||||
bool exit = false;
|
||||
auto simulate_run = [&]() {
|
||||
while (!exit) {
|
||||
// 1. wait for 5 seconds then insert the 2nd channel(input and output) to pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/vehicle_stop.mp4", 0.4);
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
trt_vehicle_detector->attach_to({file_src_1});
|
||||
screen_des_1->attach_to({split});
|
||||
// start 2nd channel
|
||||
file_src_1->start();
|
||||
// reload board using 2 SRC nodes
|
||||
src_nodes.push_back(file_src_1);
|
||||
board.reload(src_nodes);
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 \ / screen_des_0
|
||||
-> trt_vehicle_detector -> osd -> split ->
|
||||
file_src_1 / \ screen_des_1
|
||||
*/
|
||||
|
||||
// 2. wait for 5 seconds then insert the 3rd channel(input and output) to pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
auto file_src_2 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_2", 2, "./vp_data/test_video/vehicle_stop.mp4", 0.4);
|
||||
auto screen_des_2 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_2", 2);
|
||||
trt_vehicle_detector->attach_to({file_src_2});
|
||||
screen_des_2->attach_to({split});
|
||||
// start 3rd channel
|
||||
file_src_2->start();
|
||||
// reload board using 3 SRC nodes
|
||||
src_nodes.push_back(file_src_2);
|
||||
board.reload(src_nodes);
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 \ / screen_des_0
|
||||
file_src_1 -> trt_vehicle_detector -> osd -> split -> screen_des_1
|
||||
file_src_2 / \ screen_des_2
|
||||
*/
|
||||
|
||||
// 3. wait for 5 seconds then remove the DES node(output) of 3rd channel from pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
screen_des_2->detach(); // call detach() since there is only 1 previous node for screen_des_2
|
||||
screen_des_2 = nullptr; // force call destructor immediately
|
||||
// reload board using previous SRC nodes
|
||||
board.reload();
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 \ / screen_des_0
|
||||
file_src_1 -> trt_vehicle_detector -> osd -> split -> screen_des_1
|
||||
file_src_2 /
|
||||
*/
|
||||
|
||||
// 4. wait for 5 seconds then remove the SRC node(input) of 3rd channel from pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
trt_vehicle_detector->detach_from({"file_src_2"}); // call detach_from(...) since there are many previous nodes for trt_vehicle_detector
|
||||
file_src_2->stop(); // call stop() on SRC node which is not reused later
|
||||
file_src_2 = nullptr; // force call destructor immediately
|
||||
// reload board using 2 SRC nodes
|
||||
src_nodes.pop_back();
|
||||
board.reload(src_nodes);
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 \ / screen_des_0
|
||||
-> trt_vehicle_detector -> osd -> split ->
|
||||
file_src_1 / \ screen_des_1
|
||||
*/
|
||||
|
||||
// 5. wait for 5 seconds then insert a secondary classifier node, track node and broker node into pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
auto trt_color_cls = std::make_shared<vp_nodes::vp_trt_vehicle_color_classifier>("trt_color_cls", "./vp_data/models/trt/vehicle/vehicle_color_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto track = std::make_shared<vp_nodes::vp_sort_track_node>("track");
|
||||
auto console_broker = std::make_shared<vp_nodes::vp_json_console_broker_node>("console_broker");
|
||||
osd->detach(); // first detach osd node from pipeline
|
||||
osd->attach_to({console_broker}); // then attach osd node to broker node
|
||||
console_broker->attach_to({track}); // attach broker node to track node
|
||||
track->attach_to({trt_color_cls}); // attach track node to classifier node
|
||||
trt_color_cls->attach_to({trt_vehicle_detector}); // attach classifier node into pipeline
|
||||
// reload board using previous SRC nodes
|
||||
board.reload();
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 \ / screen_des_0
|
||||
-> trt_vehicle_detector -> trt_color_cls -> track -> console_broker -> osd -> split ->
|
||||
file_src_1 / \ screen_des_1
|
||||
*/
|
||||
|
||||
// 6. wait for 10 seconds then remove the 2nd channel (both SRC node and DES node) from pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
screen_des_1->detach(); // call detach() since there is only 1 previous node for screen_des_1
|
||||
trt_vehicle_detector->detach_from({"file_src_1"}); // call detach_from(...) since there are many previous nodes for trt_vehicle_detector
|
||||
file_src_1->stop(); // call stop() on SRC node which is not reused later
|
||||
screen_des_1 = nullptr; // force call destructor immediately
|
||||
file_src_1 = nullptr; // force call destructor immediately
|
||||
// reload board using 1 SRC nodes
|
||||
src_nodes.pop_back();
|
||||
board.reload(src_nodes);
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 -> trt_vehicle_detector -> trt_color_cls -> track -> console_broker -> osd -> split -> screen_des_0
|
||||
*/
|
||||
|
||||
// 7. wait for 10 seconds then remove classifier node, track node and broker node from pipeline
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
osd->detach();
|
||||
console_broker->detach();
|
||||
track->detach();
|
||||
trt_color_cls->detach();
|
||||
osd->attach_to({trt_vehicle_detector}); // relink osd and trt_vehicle_detector
|
||||
|
||||
console_broker = nullptr;
|
||||
track = nullptr;
|
||||
trt_color_cls = nullptr;
|
||||
// reload board using previous SRC nodes
|
||||
board.reload();
|
||||
/* now the format of pipeline is:
|
||||
file_src_0 -> trt_vehicle_detector -> osd -> split -> screen_des_0
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
// start simulation thread
|
||||
std::thread simulator(simulate_run);
|
||||
|
||||
// enter to exit
|
||||
std::string input;
|
||||
std::getline(std::cin, input);
|
||||
exit = true;
|
||||
simulator.join();
|
||||
|
||||
// split pipeline into single nodes before process exit
|
||||
for (auto& n: src_nodes) {
|
||||
n->detach_recursively();
|
||||
}
|
||||
// pipeline destroyed and process exit normally
|
||||
}
|
||||
73
samples/dynamic_pipeline_sample2.cpp
Normal file
73
samples/dynamic_pipeline_sample2.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
#include "../nodes/record/vp_record_node.h"
|
||||
#include "../nodes/broker/vp_json_console_broker_node.h"
|
||||
#include "../nodes/vp_rtsp_src_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_type_classifier.h"
|
||||
/*
|
||||
* ## dynamic_pipeline_sample2 ##
|
||||
* insert/remove nodes to/from pipeline step by step, then process exits normally.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_stop.mp4", 0.4);
|
||||
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto osd = std::make_shared<vp_nodes::vp_osd_node>("osd", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto console_broker = std::make_shared<vp_nodes::vp_json_console_broker_node>("console_broker");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true);
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
trt_vehicle_detector->attach_to({file_src_0});
|
||||
osd->attach_to({trt_vehicle_detector});
|
||||
console_broker->attach_to({osd});
|
||||
split->attach_to({console_broker});
|
||||
screen_des_0->attach_to({split});
|
||||
file_src_0->start();
|
||||
|
||||
std::vector<std::shared_ptr<vp_nodes::vp_node>> src_nodes = {file_src_0};
|
||||
std::string wait;
|
||||
|
||||
std::cin >> wait; // display pipeline
|
||||
vp_utils::vp_analysis_board board(src_nodes);
|
||||
board.display(1, false); // no block
|
||||
|
||||
std::cin >> wait; // add rtsp input
|
||||
auto rtsp_src_1 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_1", 1, "rtsp://admin:admin12345@192.168.77.203", 0.4);
|
||||
trt_vehicle_detector->attach_to({rtsp_src_1});
|
||||
rtsp_src_1->start();
|
||||
src_nodes.push_back(rtsp_src_1);
|
||||
board.reload(src_nodes);
|
||||
|
||||
std::cin >> wait; // add rtmp output
|
||||
auto rtmp_des_1 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_1", 1, "rtmp://192.168.77.60/live/dynamic_pipeline_sample2");
|
||||
rtmp_des_1->attach_to({split});
|
||||
board.reload();
|
||||
|
||||
std::cin >> wait; // add classifier
|
||||
auto trt_vehicle_type_classifier = std::make_shared<vp_nodes::vp_trt_vehicle_type_classifier>("trt_type_cls", "./vp_data/models/trt/vehicle/vehicle_type_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
osd->detach();
|
||||
osd->attach_to({trt_vehicle_type_classifier});
|
||||
trt_vehicle_type_classifier->attach_to({trt_vehicle_detector});
|
||||
board.reload();
|
||||
|
||||
std::cin >> wait; // remove broker
|
||||
console_broker->detach();
|
||||
split->detach();
|
||||
split->attach_to({osd});
|
||||
board.reload();
|
||||
|
||||
std::cin >> wait; // destroy pipeline and process exit
|
||||
for(auto& n: src_nodes) {
|
||||
n->detach_recursively();
|
||||
}
|
||||
}
|
||||
36
samples/enet_seg_sample.cpp
Normal file
36
samples/enet_seg_sample.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_enet_seg_node.h"
|
||||
#include "../nodes/osd/vp_seg_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## enet seg sample ##
|
||||
* semantic segmentation based on ENet.
|
||||
* 1 input, 2 outputs including orignal frame and mask frame.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/enet_seg.mp4");
|
||||
auto enet_seg = std::make_shared<vp_nodes::vp_enet_seg_node>("enet_seg", "./vp_data/models/enet-cityscapes/enet-model.net");
|
||||
auto seg_osd_0 = std::make_shared<vp_nodes::vp_seg_osd_node>("seg_osd_0", "./vp_data/models/enet-cityscapes/enet-classes.txt", "./vp_data/models/enet-cityscapes/enet-colors.txt");
|
||||
auto screen_des_mask = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_mask", 0, true, vp_objects::vp_size(400, 225));
|
||||
auto screen_des_original = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_original", 0, false, vp_objects::vp_size(400, 225));
|
||||
|
||||
// construct pipeline
|
||||
enet_seg->attach_to({file_src_0});
|
||||
seg_osd_0->attach_to({enet_seg});
|
||||
screen_des_mask->attach_to({seg_osd_0});
|
||||
screen_des_original->attach_to({seg_osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
46
samples/face_swap_sample.cpp
Normal file
46
samples/face_swap_sample.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_face_swap_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_file_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## face_swap_sample ##
|
||||
* swap face for any video/images, no training need before running.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 1.0, true, "avdec_h264", 4);
|
||||
auto yunet_face_detector = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto face_swap = std::make_shared<vp_nodes::vp_face_swap_node>("face_swap", "./vp_data/models/face/face_detection_yunet_2022mar.onnx", "./vp_data/models/face/swap/w600k_r50.onnx", "./vp_data/models/face/swap/emap.txt", "./vp_data/models/face/swap/inswapper_128.onnx", "./github/inswapper/data/mans1.jpeg");
|
||||
//auto osd = std::make_shared<vp_nodes::vp_face_osd_node>("osd");
|
||||
auto screen_des_0_ori = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0_ori", 0, false);
|
||||
auto screen_des_0_osd = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0_osd", 0);
|
||||
auto file_des_node_0 = std::make_shared<vp_nodes::vp_file_des_node>("file_des_0", 0, ".", "", 1);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector->attach_to({file_src_0});
|
||||
face_swap->attach_to({yunet_face_detector});
|
||||
//osd->attach_to({face_swap});
|
||||
screen_des_0_ori->attach_to({face_swap});
|
||||
screen_des_0_osd->attach_to({face_swap});
|
||||
file_des_node_0->attach_to({face_swap}); // save swap result to file
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
41
samples/face_tracking_sample.cpp
Normal file
41
samples/face_tracking_sample.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## face tracking sample ##
|
||||
* track for multi faces using vp_sort_track_node.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4");
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto track_0 = std::make_shared<vp_nodes::vp_sort_track_node>("track_0", vp_nodes::vp_track_for::FACE); // track for face
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
track_0->attach_to({sface_face_encoder_0});
|
||||
osd_0->attach_to({track_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
56
samples/ffmpeg_src_des_sample.cpp
Normal file
56
samples/ffmpeg_src_des_sample.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "../nodes/ffio/vp_ff_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/ffio/vp_ff_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## ffmpeg_src_des_sample ##
|
||||
* reading & pushing stream based on ffmpeg (soft decode and encode using CPUs).
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
/*
|
||||
uri for vp_ff_src_node:
|
||||
1. rtmp://192.168.77.196/live/1000 --> reading rtmp live stream
|
||||
2. rtsp://192.168.77.213/live/mainstream --> reading rtsp live stream
|
||||
3. ./vp_data/test_video/face.mp4 --> reading video file
|
||||
|
||||
uri for vp_ff_des_node:
|
||||
1. rtmp://192.168.77.196/live/10000 --> pushing rtmp live stream
|
||||
2. ./output/records.mp4 --> saving to video file
|
||||
*/
|
||||
auto ff_src_0 = std::make_shared<vp_nodes::vp_ff_src_node>("ff_src_0", 0, "./vp_data/test_video/face.mp4", "h264", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto ff_des_0 = std::make_shared<vp_nodes::vp_ff_des_node>("ff_des_0", 0, "rtmp://192.168.77.60/live/20000");
|
||||
//auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.196/live/20000");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({ff_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
ff_des_0->attach_to({osd_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
ff_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({ff_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
ff_src_0->detach_recursively();
|
||||
}
|
||||
56
samples/ffmpeg_transcode_sample.cpp
Normal file
56
samples/ffmpeg_transcode_sample.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "../nodes/ffio/vp_ff_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/ffio/vp_ff_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## ffmpeg_transcode_sample ##
|
||||
* transcoding in parallel, modify codec & resolution & bitrate & add watermask in picture.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto ff_src_0 = std::make_shared<vp_nodes::vp_ff_src_node>("ff_src_0", 0, "rtmp://192.168.77.196/live/1000", "h264", 0.5);
|
||||
auto ff_des_0 = std::make_shared<vp_nodes::vp_ff_des_node>("ff_des_0", 0, "rtmp://192.168.77.196/live/0");
|
||||
|
||||
auto ff_src_1 = std::make_shared<vp_nodes::vp_ff_src_node>("ff_src_1", 0, "rtmp://192.168.77.196/live/1000", "h264", 0.5);
|
||||
auto ff_des_1 = std::make_shared<vp_nodes::vp_ff_des_node>("ff_des_1", 0, "rtmp://192.168.77.196/live/1");
|
||||
|
||||
auto ff_src_2 = std::make_shared<vp_nodes::vp_ff_src_node>("ff_src_2", 0, "rtsp://192.168.77.213/live/mainstream", "h264", 0.5);
|
||||
auto ff_des_2 = std::make_shared<vp_nodes::vp_ff_des_node>("ff_des_2", 0, "rtmp://192.168.77.196/live/2");
|
||||
|
||||
auto ff_src_3 = std::make_shared<vp_nodes::vp_ff_src_node>("ff_src_3", 0, "rtsp://192.168.77.213/live/mainstream", "h264", 0.5);
|
||||
auto ff_des_3 = std::make_shared<vp_nodes::vp_ff_des_node>("ff_des_3", 0, "rtmp://192.168.77.196/live/3");
|
||||
|
||||
// construct pipeline
|
||||
ff_des_0->attach_to({ff_src_0});
|
||||
ff_des_1->attach_to({ff_src_1});
|
||||
ff_des_2->attach_to({ff_src_2});
|
||||
ff_des_3->attach_to({ff_src_3});
|
||||
|
||||
// start pipelines
|
||||
ff_src_0->start();
|
||||
ff_src_1->start();
|
||||
ff_src_2->start();
|
||||
ff_src_3->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({ff_src_0, ff_src_1, ff_src_2, ff_src_3});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
ff_src_0->detach_recursively();
|
||||
ff_src_1->detach_recursively();
|
||||
ff_src_2->detach_recursively();
|
||||
ff_src_3->detach_recursively();
|
||||
}
|
||||
46
samples/firesmoke_detect_sample.cpp
Normal file
46
samples/firesmoke_detect_sample.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#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 "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## firesmoke_detect_sample ##
|
||||
* detect firesmoke using yolo.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/smoke2.mp4", 0.5);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/fire.mp4", 0.5);
|
||||
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 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});
|
||||
osd->attach_to({yolo_detector});
|
||||
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();
|
||||
}
|
||||
47
samples/frame_fusion_sample.cpp
Normal file
47
samples/frame_fusion_sample.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/proc/vp_frame_fusion_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/vp_placeholder_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## frame_fusion_sample ##
|
||||
* fuse frames of 2 channels, just merge adjacent frames from 2 channels directly without considering timestamp synchronization.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/infrared.mp4"); // source of fusion
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/rgb.mp4"); // destination of fusion
|
||||
// initialize calibration points manually
|
||||
std::vector<vp_objects::vp_point> src_cali_points = {vp_objects::vp_point(133, 111), vp_objects::vp_point(338, 110), vp_objects::vp_point(15, 330), vp_objects::vp_point(14, 214)};
|
||||
std::vector<vp_objects::vp_point> des_cali_points = {vp_objects::vp_point(1219, 365), vp_objects::vp_point(1787, 367), vp_objects::vp_point(891, 982), vp_objects::vp_point(892, 659)};
|
||||
auto fusion = std::make_shared<vp_nodes::vp_frame_fusion_node>("fusion", src_cali_points, des_cali_points);
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true);
|
||||
auto screen_des_0_ori = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0_ori", 0, false); // original frame for the first channel
|
||||
auto screen_des_1_osd = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1_osd", 1); // fusion result(osd frame) for the second channel
|
||||
|
||||
// construct pipeline
|
||||
fusion->attach_to({file_src_0, file_src_1});
|
||||
split->attach_to({fusion});
|
||||
screen_des_0_ori->attach_to({split});
|
||||
screen_des_1_osd->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();
|
||||
}
|
||||
44
samples/image_des_sample.cpp
Normal file
44
samples/image_des_sample.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_image_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## image_des_sample ##
|
||||
* show how vp_image_des_node works, save image to local file or push image to remote via udp.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
/* save to file, `%d` is placeholder for filename index */
|
||||
//auto image_des_0 = std::make_shared<vp_nodes::vp_image_des_node>("image_file_des_0", 0, "./images/%d.jpg", 3, vp_objects::vp_size(), false);
|
||||
|
||||
/* push via udp, receiving command for test: `gst-launch-1.0 udpsrc port=6000 ! application/x-rtp,encoding-name=jpeg ! rtpjpegdepay ! jpegparse ! jpegdec ! queue ! videoconvert ! autovideosink` */
|
||||
auto image_des_0 = std::make_shared<vp_nodes::vp_image_des_node>("image_udp_des_0", 0, "192.168.77.248:6000", 2, vp_objects::vp_size(600, 300));
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
image_des_0->attach_to({osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
41
samples/image_src_sample.cpp
Normal file
41
samples/image_src_sample.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "../nodes/vp_image_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 "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## image_des_sample ##
|
||||
* show how vp_image_src_node works, read image from local file or receive image from remote via udp.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_file_src_0", 0, "./vp_data/test_images/vehicle/%d.jpg", 1, 0.4); // read 1 image EVERY 1 second from local files, such as test_0.jpg,test_1.jpg
|
||||
/* sending command for test: `gst-launch-1.0 filesrc location=16.mp4 ! qtdemux ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=416,height=416 ! videorate ! video/x-raw,framerate=1/1 ! jpegenc ! rtpjpegpay ! udpsink host=ip port=6000` */
|
||||
auto image_src_1 = std::make_shared<vp_nodes::vp_image_src_node>("image_udp_src_1", 1, "6000", 3); // receive 1 image EVERY 3 seconds from remote via udp , such as 127.0.0.1:6000
|
||||
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("yolo_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt");
|
||||
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); // split by channel index (important!)
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
|
||||
// construct pipeline
|
||||
yolo_detector->attach_to({image_src_0, image_src_1});
|
||||
osd->attach_to({yolo_detector});
|
||||
split->attach_to({osd});
|
||||
screen_des_0->attach_to({split});
|
||||
screen_des_1->attach_to({split});
|
||||
|
||||
image_src_0->start(); // start read from local file
|
||||
image_src_1->start(); // start receive from remote via udp
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({image_src_0, image_src_1});
|
||||
board.display();
|
||||
}
|
||||
94
samples/interaction_with_pipe_sample.cpp
Normal file
94
samples/interaction_with_pipe_sample.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## interaction_with_pipe sample ##
|
||||
* show how to interact with pipe, start/stop/speak on src nodes independently.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_LOGGER_INIT();
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/face2.mp4", 0.6);
|
||||
auto yunet_face_detector = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true); // split by channel index
|
||||
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
auto osd_1 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_1");
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
auto rtmp_des_1 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_1", 1, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector->attach_to({file_src_0, file_src_1});
|
||||
sface_face_encoder->attach_to({yunet_face_detector});
|
||||
|
||||
split->attach_to({sface_face_encoder});
|
||||
|
||||
// split by vp_split_node
|
||||
osd_0->attach_to({split});
|
||||
osd_1->attach_to({split});
|
||||
|
||||
// auto split again on channel 0
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
|
||||
// auto split again on channel 1
|
||||
screen_des_1->attach_to({osd_1});
|
||||
rtmp_des_1->attach_to({osd_1});
|
||||
|
||||
// for debug purpose
|
||||
std::vector<std::shared_ptr<vp_nodes::vp_node>> src_nodes_in_pipe{file_src_0, file_src_1};
|
||||
vp_utils::vp_analysis_board board(src_nodes_in_pipe);
|
||||
board.display(1, false); // no block since we need interactions from console later
|
||||
|
||||
|
||||
/* interact from console */
|
||||
/* no except check */
|
||||
std::string input;
|
||||
std::getline(std::cin, input);
|
||||
// input format: `start channel`, like `start 0` means start channel 0
|
||||
auto inputs = vp_utils::string_split(input, ' ');
|
||||
while (inputs[0] != "quit") {
|
||||
// no except check
|
||||
auto command = inputs[0];
|
||||
auto index = std::stoi(inputs[1]);
|
||||
auto src_by_channel = std::dynamic_pointer_cast<vp_nodes::vp_src_node>(src_nodes_in_pipe[index]);
|
||||
if (command == "start") {
|
||||
src_by_channel->start();
|
||||
}
|
||||
else if (command == "stop") {
|
||||
src_by_channel->stop();
|
||||
}
|
||||
else if (command == "speak") {
|
||||
src_by_channel->speak();
|
||||
}
|
||||
else {
|
||||
std::cout << "invalid command!" << std::endl;
|
||||
}
|
||||
std::getline(std::cin, input);
|
||||
inputs = vp_utils::string_split(input, ' ');
|
||||
if (inputs.size() != 2) {
|
||||
std::cout << "invalid input!" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "interaction_with_pipe sample exits..." << std::endl;
|
||||
file_src_0->detach_recursively();
|
||||
file_src_1->detach_recursively();
|
||||
}
|
||||
40
samples/lane_detect_sample.cpp
Normal file
40
samples/lane_detect_sample.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_lane_detector_node.h"
|
||||
#include "../nodes/osd/vp_lane_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## lane_detect_sample ##
|
||||
* detect lanes on road.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.6, true, "avdec_h264", 4);
|
||||
auto lane_detector = std::make_shared<vp_nodes::vp_lane_detector_node>("lane_detector", "./vp_data/models/lane/lane_det.onnx");
|
||||
auto lane_osd = std::make_shared<vp_nodes::vp_lane_osd_node>("lane_osd");
|
||||
auto screen_des_0_osd = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0_osd", 0);
|
||||
auto srceen_des_0_ori = std::make_shared<vp_nodes::vp_screen_des_node>("srceen_des_0_ori", 0, false);
|
||||
|
||||
// construct pipeline
|
||||
lane_detector->attach_to({file_src_0});
|
||||
lane_osd->attach_to({lane_detector});
|
||||
screen_des_0_osd->attach_to({lane_osd});
|
||||
srceen_des_0_ori->attach_to({lane_osd});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
36
samples/mask_rcnn_sample.cpp
Normal file
36
samples/mask_rcnn_sample.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_mask_rcnn_detector_node.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/osd/vp_osd_node_v3.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## mask rcnn sample ##
|
||||
* image segmentation using mask rcnn.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/mask_rcnn.mp4", 0.6);
|
||||
auto mask_rcnn_detector = std::make_shared<vp_nodes::vp_mask_rcnn_detector_node>("mask_rcnn_detector", "./vp_data/models/mask_rcnn/frozen_inference_graph.pb", "./vp_data/models/mask_rcnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt", "./vp_data/models/coco_80classes.txt");
|
||||
auto track_0 = std::make_shared<vp_nodes::vp_sort_track_node>("sort_track_0");
|
||||
auto osd_v3_0 = std::make_shared<vp_nodes::vp_osd_node_v3>("osd_v3_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
mask_rcnn_detector->attach_to({file_src_0});
|
||||
track_0->attach_to({mask_rcnn_detector});
|
||||
osd_v3_0->attach_to({track_0});
|
||||
screen_des_0->attach_to({osd_v3_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
48
samples/message_broker_kafka_sample.cpp
Normal file
48
samples/message_broker_kafka_sample.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/broker/vp_json_kafka_broker_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## message_broker_kafka_sample ##
|
||||
* show how message broker node works.
|
||||
* serialize vp_frame_face_target objects to json and broke to kafka.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto json_kafka_broker_0 = std::make_shared<vp_nodes::vp_json_kafka_broker_node>("json_kafka_broker_0", "192.168.77.87:9092", "videopipe_topic", vp_nodes::vp_broke_for::FACE);
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
json_kafka_broker_0->attach_to({sface_face_encoder_0});
|
||||
osd_0->attach_to({json_kafka_broker_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
}
|
||||
44
samples/message_broker_sample.cpp
Normal file
44
samples/message_broker_sample.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/broker/vp_json_console_broker_node.h"
|
||||
#include "../nodes/broker/vp_xml_file_broker_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## message broker sample ##
|
||||
* show how message broker node works.
|
||||
* serialize vp_frame_face_target objects to json and broke to console.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto json_console_broker_0 = std::make_shared<vp_nodes::vp_json_console_broker_node>("json_console_broker_0", vp_nodes::vp_broke_for::FACE);
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
json_console_broker_0->attach_to({sface_face_encoder_0});
|
||||
osd_0->attach_to({json_console_broker_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
41
samples/message_broker_sample2.cpp
Normal file
41
samples/message_broker_sample2.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_plate_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/broker/vp_xml_socket_broker_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## message broker sample2 ##
|
||||
* show how message broker node works.
|
||||
* serialize vp_frame_target (vp_sub_target) objects to xml and broke to socket via udp.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/plate.mp4");
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto trt_vehicle_plate_detector = std::make_shared<vp_nodes::vp_trt_vehicle_plate_detector>("vehicle_plate_detector", "./vp_data/models/trt/plate/det_v8.5.trt", "./vp_data/models/trt/plate/rec_v8.5.trt");
|
||||
auto xml_socket_broker_0 = std::make_shared<vp_nodes::vp_xml_socket_broker_node>("xml_socket_broker_0", "192.168.77.68", 6666);
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node_v2>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0, true, vp_objects::vp_size{640, 360});
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({file_src_0});
|
||||
trt_vehicle_plate_detector->attach_to({trt_vehicle_detector});
|
||||
xml_socket_broker_0->attach_to({trt_vehicle_plate_detector});
|
||||
osd_0->attach_to({xml_socket_broker_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
56
samples/mllm_analyse_sample.cpp
Normal file
56
samples/mllm_analyse_sample.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_mllm_analyser_node.h"
|
||||
#include "../nodes/osd/vp_mllm_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## mllm_analyse_sample ##
|
||||
* image(frame) analyse based on Multimodal Large Language Model(from Ollama).
|
||||
* read images from disk and analyse the image using MLLM using the prepared prompt.
|
||||
*/
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_file_src_0", 0, "./vp_data/test_images/llm/writing/%d.jpg", 2, 0.5);
|
||||
auto understanding_prompt = "一句话描述图片内容,要求包含:\n"
|
||||
"1. 对天气的描述\n"
|
||||
"2. 对环境的描述\n"
|
||||
"3. 对位置的描述(如果可以从图片上的文字信息得出)\n"
|
||||
"4. 字数不超过50字"
|
||||
"你的输出结果是:";
|
||||
auto writing_prompt = "根据图片写一段故事,要求包含:\n"
|
||||
"1. 完整的故事结构\n"
|
||||
"2. 故事内容要包含时间、地点、人物等元素"
|
||||
"3. 字数不超过50字"
|
||||
"你的输出结果是:";
|
||||
auto mllm_analyser_0 = std::make_shared<vp_nodes::vp_mllm_analyser_node>("mllm_analyser_0", // node name
|
||||
"minicpm-v:8b", // mllm model name (support image as input)
|
||||
writing_prompt, // prompt
|
||||
"http://192.168.77.219:11434", // api base url
|
||||
"", // api key (not required by Ollama)
|
||||
llmlib::LLMBackendType::Ollama); // backend type, make sure Ollama is installed at 192.168.77.219
|
||||
auto mllm_osd_0 = std::make_shared<vp_nodes::vp_mllm_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
mllm_analyser_0->attach_to({image_src_0});
|
||||
mllm_osd_0->attach_to({mllm_analyser_0});
|
||||
screen_des_0->attach_to({mllm_osd_0});
|
||||
|
||||
image_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
image_src_0->detach_recursively();
|
||||
}
|
||||
50
samples/mllm_analyse_sample_openai.cpp
Normal file
50
samples/mllm_analyse_sample_openai.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_mllm_analyser_node.h"
|
||||
#include "../nodes/osd/vp_mllm_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## mllm_analyse_sample_openai ##
|
||||
* image(frame) analyse based on Multimodal Large Language Model(from aliyun or other OpenAI-compatible api services).
|
||||
* read images from disk and analyse the image using MLLM using the prepared prompt.
|
||||
*/
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_file_src_0", 0, "./vp_data/test_images/llm/understanding/%d.jpg", 2, 0.5);
|
||||
auto writing_prompt = "给图片打标签,要求包含:\n"
|
||||
"1. 先仔细观察图片内容,为图片赋予适合的标签\n"
|
||||
"2. 给出的标签最多不超过5个\n"
|
||||
"3. 输出按以下格式:\n"
|
||||
"通过仔细观察图片,可以为图片赋予这些标签:['标签1', '标签2', '标签3']。";
|
||||
auto mllm_analyser_0 = std::make_shared<vp_nodes::vp_mllm_analyser_node>("mllm_analyser_0", // node name
|
||||
"qwen-vl-max", // mllm model name (from aliyun, support image as input)
|
||||
writing_prompt, // prompt
|
||||
"https://dashscope.aliyuncs.com/compatible-mode/v1", // api base url
|
||||
"sk-XXX", // api key (from aliyun)
|
||||
llmlib::LLMBackendType::OpenAI); // backend type
|
||||
auto mllm_osd_0 = std::make_shared<vp_nodes::vp_mllm_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
mllm_analyser_0->attach_to({image_src_0});
|
||||
mllm_osd_0->attach_to({mllm_analyser_0});
|
||||
screen_des_0->attach_to({mllm_osd_0});
|
||||
|
||||
image_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
image_src_0->detach_recursively();
|
||||
}
|
||||
48
samples/multi_detectors_and_classifiers_sample.cpp
Normal file
48
samples/multi_detectors_and_classifiers_sample.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yolo_detector_node.h"
|
||||
#include "../nodes/infers/vp_classifier_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## multi detectors and classifiers sample ##
|
||||
* show multi infer nodes work together.
|
||||
* 1 detector and 2 classifiers applied on primary class ids(1/2/3).
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_stop.mp4", 0.6);
|
||||
/* primary detector */
|
||||
// labels for detector model
|
||||
// 0 - person
|
||||
// 1 - car
|
||||
// 2 - bus
|
||||
// 3 - truck
|
||||
// 4 - 2wheel
|
||||
auto primary_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("primary_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt", 416, 416, 1);
|
||||
/* secondary classifier 1, applied to car(1)/bus(2)/truck(3) only */
|
||||
auto _1st_classifier = std::make_shared<vp_nodes::vp_classifier_node>("1st_classifier", "./vp_data/models/det_cls/vehicle/resnet18-batch=N-type_view_0322_nhwc.onnx", "", "./vp_data/models/det_cls/vehicle/vehicle_types.txt", 224, 224, 1, std::vector<int>{1, 2, 3}, 20, 20, 10, false, 1, cv::Scalar(), cv::Scalar(), true, true);
|
||||
/* secondary classifier 2, applied to car(1)/bus(2)/truck(3) only */
|
||||
auto _2nd_classifier = std::make_shared<vp_nodes::vp_classifier_node>("2nd_classifier", "./vp_data/models/det_cls/vehicle/resnet18-batch=N-color_view_0322_nhwc.onnx", "", "./vp_data/models/det_cls/vehicle/vehicle_colors.txt", 224, 224, 1, std::vector<int>{1, 2, 3}, 20, 20, 10, false, 1, cv::Scalar(), cv::Scalar(), true, true);
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_o", 0);
|
||||
|
||||
// construct pipeline
|
||||
primary_detector->attach_to({file_src_0});
|
||||
_1st_classifier->attach_to({primary_detector});
|
||||
_2nd_classifier->attach_to({_1st_classifier});
|
||||
osd_0->attach_to({_2nd_classifier});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
49
samples/multi_detectors_sample.cpp
Normal file
49
samples/multi_detectors_sample.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#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 "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## multi_detectors_sample ##
|
||||
* detect obstacles AND vehicles using yolo on road.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/unclear.mp4", 0.5);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/roadblock.mp4", 0.6);
|
||||
auto obstacle_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("obstacle_detector", "./vp_data/models/det_cls/obstacles_yolov5s.onnx", "", "./vp_data/models/det_cls/obstacles_2classes.txt", 640, 640);
|
||||
// MUST set class_id_offset for the 2nd detector which is equal with total classes of the 1st detectors
|
||||
auto vehicle_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("vehicle_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt", 416, 416, 1, 2);
|
||||
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
|
||||
obstacle_detector->attach_to({file_src_0, file_src_1});
|
||||
vehicle_detector->attach_to({obstacle_detector});
|
||||
osd->attach_to({vehicle_detector});
|
||||
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();
|
||||
}
|
||||
43
samples/multi_trt_infer_nodes_sample.cpp
Normal file
43
samples/multi_trt_infer_nodes_sample.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_color_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_type_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_feature_encoder.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## multi_trt_infer_nodes_sample ##
|
||||
* detect/classify/encoding on vehicle object using tensorrt
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_src_0", 0, "./vp_data/test_images/vehicle/%d.jpg");
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto trt_vehicle_color_classifier = std::make_shared<vp_nodes::vp_trt_vehicle_color_classifier>("trt_color_cls", "./vp_data/models/trt/vehicle/vehicle_color_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto trt_vehicle_type_classifier = std::make_shared<vp_nodes::vp_trt_vehicle_type_classifier>("trt_type_cls", "./vp_data/models/trt/vehicle/vehicle_type_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto trt_vehicle_feature_encoder = std::make_shared<vp_nodes::vp_trt_vehicle_feature_encoder>("trt_encoder", "./vp_data/models/trt/vehicle/vehicle_embedding_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({image_src_0});
|
||||
trt_vehicle_color_classifier->attach_to({trt_vehicle_detector});
|
||||
trt_vehicle_type_classifier->attach_to({trt_vehicle_color_classifier});
|
||||
trt_vehicle_feature_encoder->attach_to({trt_vehicle_type_classifier});
|
||||
osd_0->attach_to({trt_vehicle_feature_encoder});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
image_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display();
|
||||
}
|
||||
55
samples/nv_hard_codec_sample.cpp
Normal file
55
samples/nv_hard_codec_sample.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## nv_hard_codec_sample ##
|
||||
* use hardware-based `nvv4l2decoder`/`nvv4l2h264enc` gstreamer plugins (come from DeepStream 4.0+) to decode/encode video stream, which would occupy NVIDIA GPUs.
|
||||
* run `nvidia-smi -a` command to watch the Utilization of GPU/Decode/Encode .
|
||||
*
|
||||
* for more information: https://github.com/sherlockchou86/video_pipe_c/blob/master/doc/env.md#about-hardware-acceleration
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6, true, "nvv4l2decoder ! nvvideoconvert");
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/10000", vp_objects::vp_size(), 1024 * 4000, true, "nvvideoconvert ! nvv4l2h264enc");
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({file_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
file_src_0->detach_recursively();
|
||||
|
||||
/*
|
||||
cv::VideoCapture cap("filesrc location=/windows2/zhzhi/vp_data/test_video/face.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! appsink");
|
||||
cv::Mat frame;
|
||||
cap.read(frame);
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
46
samples/obstacle_detect_sample.cpp
Normal file
46
samples/obstacle_detect_sample.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#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 "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## obstacle_detect_sample ##
|
||||
* detect obstacles using yolo on road.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/unclear.mp4", 0.5);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/roadblock.mp4", 0.5);
|
||||
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("obstacle_detector", "./vp_data/models/det_cls/obstacles_yolov5s.onnx", "", "./vp_data/models/det_cls/obstacles_2classes.txt", 640, 640);
|
||||
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});
|
||||
osd->attach_to({yolo_detector});
|
||||
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();
|
||||
}
|
||||
33
samples/openpose_sample.cpp
Normal file
33
samples/openpose_sample.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_openpose_detector_node.h"
|
||||
#include "../nodes/osd/vp_pose_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## openpose sample ##
|
||||
* pose estimation by OpenPose network.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/pose.mp4");
|
||||
auto openpose_detector = std::make_shared<vp_nodes::vp_openpose_detector_node>("openpose_detector", "./vp_data/models/openpose/pose/body_25_pose_iter_584000.caffemodel", "./vp_data/models/openpose/pose/body_25_pose_deploy.prototxt", "", 368, 368, 1, 0, 0.1, vp_objects::vp_pose_type::body_25);
|
||||
auto pose_osd_0 = std::make_shared<vp_nodes::vp_pose_osd_node>("pose_osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
openpose_detector->attach_to({file_src_0});
|
||||
pose_osd_0->attach_to({openpose_detector});
|
||||
screen_des_0->attach_to({pose_osd_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
40
samples/paddle_infer_sample.cpp
Normal file
40
samples/paddle_infer_sample.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_ppocr_text_detector_node.h"
|
||||
#include "../nodes/osd/vp_text_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
#include "../nodes/vp_file_des_node.h"
|
||||
|
||||
/*
|
||||
* ## paddle infer sample ##
|
||||
* ocr based on paddle (install paddle_inference first!)
|
||||
* 1 video input and 2 outputs (screen, rtmp)
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/ocr.mp4", 0.4);
|
||||
auto ppocr_text_detector = std::make_shared<vp_nodes::vp_ppocr_text_detector_node>("ppocr_text_detector", "./vp_data/models/text/ppocr/ch_PP-OCRv3_det_infer","./vp_data/models/text/ppocr/ch_ppocr_mobile_v2.0_cls_infer","./vp_data/models/text/ppocr/ch_PP-OCRv3_rec_infer","./vp_data/models/text/ppocr/ppocr_keys_v1.txt");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_text_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0, true);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
// construct pipeline
|
||||
ppocr_text_detector->attach_to({file_src_0});
|
||||
osd_0->attach_to({ppocr_text_detector});
|
||||
|
||||
// split into 2 sub branches automatically
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
33
samples/plate_recognize_sample.cpp
Normal file
33
samples/plate_recognize_sample.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_plate_detector_v2.h"
|
||||
#include "../nodes/osd/vp_plate_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## plate recognize sample ##
|
||||
* detect and recognize plate in the whole frame
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_src_0", 0, "./vp_data/test_images/plates/%d.jpg", 1);
|
||||
auto plate_detector = std::make_shared<vp_nodes::vp_trt_vehicle_plate_detector_v2>("plate_detector", "./vp_data/models/trt/plate/det_v8.5.trt", "./vp_data/models/trt/plate/rec_v8.5.trt");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_plate_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
plate_detector->attach_to({image_src_0});
|
||||
osd_0->attach_to({plate_detector});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
image_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display();
|
||||
}
|
||||
109
samples/record_sample.cpp
Normal file
109
samples/record_sample.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
#include "../nodes/record/vp_record_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## record sample ##
|
||||
* show how to use vp_record_node to record image and video.
|
||||
* NOTE:
|
||||
* the recording signal in this demo is triggered by users outside pipe (via calling vp_src_node::record_video_manually or vp_src_node::record_image_manually)
|
||||
* in product situations, recording signal is triggered inside pipe automatically.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_SET_LOG_TO_CONSOLE(false); // need interact on console
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face.mp4", 0.6);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/face2.mp4", 0.6);
|
||||
auto yunet_face_detector = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto track = std::make_shared<vp_nodes::vp_sort_track_node>("track", vp_nodes::vp_track_for::FACE);
|
||||
auto osd = std::make_shared<vp_nodes::vp_face_osd_node>("osd");
|
||||
auto recorder = std::make_shared<vp_nodes::vp_record_node>("recorder", "./record", "./record");
|
||||
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true); // split by channel index
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector->attach_to({file_src_0, file_src_1});
|
||||
sface_face_encoder->attach_to({yunet_face_detector});
|
||||
track->attach_to({sface_face_encoder});
|
||||
osd->attach_to({track});
|
||||
recorder->attach_to({osd});
|
||||
split->attach_to({recorder});
|
||||
// split by vp_split_node
|
||||
screen_des_0->attach_to({split});
|
||||
screen_des_1->attach_to({split});
|
||||
|
||||
/*
|
||||
* set hookers for vp_record_node when task compeleted
|
||||
*/
|
||||
// define hooker
|
||||
auto record_hooker = [](int channel, vp_nodes::vp_record_info record_info) {
|
||||
auto record_type = record_info.record_type == vp_nodes::vp_record_type::IMAGE ? "image" : "video";
|
||||
|
||||
std::cout << "channel:[" << channel << "] [" << record_type << "]" << " record task completed! full path: " << record_info.full_record_path << std::endl;
|
||||
};
|
||||
recorder->set_image_record_complete_hooker(record_hooker);
|
||||
recorder->set_video_record_complete_hooker(record_hooker);
|
||||
|
||||
// start channels
|
||||
file_src_0->start();
|
||||
file_src_1->start();
|
||||
|
||||
// for debug purpose
|
||||
std::vector<std::shared_ptr<vp_nodes::vp_node>> src_nodes_in_pipe{file_src_0, file_src_1};
|
||||
vp_utils::vp_analysis_board board(src_nodes_in_pipe);
|
||||
board.display(1, false); // no block
|
||||
|
||||
|
||||
/* interact from console */
|
||||
/* no except check */
|
||||
std::string input;
|
||||
std::getline(std::cin, input);
|
||||
// input format: `image channel` or `video channel`, like `video 0` means start recording video at channel 0
|
||||
auto inputs = vp_utils::string_split(input, ' ');
|
||||
while (inputs[0] != "quit") {
|
||||
// no except check
|
||||
auto command = inputs[0];
|
||||
auto index = std::stoi(inputs[1]);
|
||||
auto src_by_channel = std::dynamic_pointer_cast<vp_nodes::vp_src_node>(src_nodes_in_pipe[index]);
|
||||
if (command == "video") {
|
||||
src_by_channel->record_video_manually(true); // debug api
|
||||
// or
|
||||
// src_by_channel->record_video_manually(true, 5);
|
||||
// src_by_channel->record_video_manually(false, 20);
|
||||
}
|
||||
else if (command == "image") {
|
||||
src_by_channel->record_image_manually(); // debug api
|
||||
// or
|
||||
// src_by_channel->record_image_manually(true);
|
||||
}
|
||||
else {
|
||||
std::cout << "invalid command!" << std::endl;
|
||||
}
|
||||
std::getline(std::cin, input);
|
||||
inputs = vp_utils::string_split(input, ' ');
|
||||
if (inputs.size() != 2) {
|
||||
std::cout << "invalid input!" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "record sample exits..." << std::endl;
|
||||
file_src_0->detach_recursively();
|
||||
file_src_1->detach_recursively();
|
||||
}
|
||||
44
samples/rtmp_src_sample.cpp
Normal file
44
samples/rtmp_src_sample.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "../nodes/vp_rtmp_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## rtmp_src_sample ##
|
||||
* 1 rtmp video input, 1 infer task, and 1 output.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto rtmp_src_0 = std::make_shared<vp_nodes::vp_rtmp_src_node>("rtmp_src_0", 0, "rtmp://192.168.77.196/live/1000", 0.6);
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto track_0 = std::make_shared<vp_nodes::vp_sort_track_node>("track_0");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.196/live/2000", vp_objects::vp_size{1280, 720}, 1024 * 2);
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({rtmp_src_0});
|
||||
track_0->attach_to({trt_vehicle_detector});
|
||||
osd_0->attach_to({track_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
|
||||
rtmp_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({rtmp_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
rtmp_src_0->detach_recursively();
|
||||
}
|
||||
50
samples/rtsp_des_sample.cpp
Normal file
50
samples/rtsp_des_sample.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#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 "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## rtsp_des_sample ##
|
||||
* show how vp_rtsp_des_node works, push video stream via rtsp, no specialized rtsp server needed.
|
||||
* visit `rtsp://server-ip:rtsp_port/rtsp_name directly.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.5);
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/vehicle_stop.mp4", 0.5);
|
||||
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("yolo_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt");
|
||||
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 rtsp_des_0 = std::make_shared<vp_nodes::vp_rtsp_des_node>("rtsp_des_0", 0, 8000, "rtsp_0");
|
||||
|
||||
//auto srceen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
auto rtsp_des_1 = std::make_shared<vp_nodes::vp_rtsp_des_node>("rtsp_des_1", 1, 8000, "rtsp_1");
|
||||
|
||||
// construct pipeline
|
||||
yolo_detector->attach_to({file_src_0, file_src_1});
|
||||
osd->attach_to({yolo_detector});
|
||||
split->attach_to({osd});
|
||||
rtsp_des_0->attach_to({split});
|
||||
rtsp_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();
|
||||
}
|
||||
48
samples/rtsp_src_sample.cpp
Normal file
48
samples/rtsp_src_sample.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "../nodes/vp_rtsp_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## rtsp_src_sample ##
|
||||
* 1 rtsp video input, 1 infer task, and 1 output.
|
||||
* support switching/restarting input rtsp stream.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto rtsp_src_0 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_0", 0, "rtsp://192.168.77.213/live/mainstream", 0.6);
|
||||
auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx");
|
||||
auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yunet_face_detector_0->attach_to({rtsp_src_0});
|
||||
sface_face_encoder_0->attach_to({yunet_face_detector_0});
|
||||
osd_0->attach_to({sface_face_encoder_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
rtsp_src_0->start();
|
||||
|
||||
/* manually switching/restarting RTSP video sources, where the video sources have different widths, heights, and frame rates.
|
||||
continuously print width, height, fps. */
|
||||
while (true) {
|
||||
auto width = rtsp_src_0->get_original_width();
|
||||
auto height = rtsp_src_0->get_original_height();
|
||||
auto fps = rtsp_src_0->get_original_fps();
|
||||
std::cout << "original_width: " << width << "original_height: " << height << "original_fps: " << fps << std::endl;
|
||||
this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
|
||||
rtsp_src_0->detach_recursively();
|
||||
}
|
||||
43
samples/skip_sample.cpp
Normal file
43
samples/skip_sample.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/vp_rtsp_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_rtmp_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## skip_sample ##
|
||||
* 2 inputs , and skip 2 frames every 3 frames for the 2nd channel.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.5);
|
||||
auto rtsp_src_1 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_1", 1, "rtsp://admin:admin12345@192.168.3.157", 0.4, "avdec_h264", 2); // skip 2 frames every 3 frames
|
||||
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("yolo_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt");
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("split", true);
|
||||
auto osd = std::make_shared<vp_nodes::vp_osd_node>("osd", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_1 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 1, "rtmp://192.168.77.60/live/10000");
|
||||
|
||||
// construct pipeline
|
||||
yolo_detector->attach_to({file_src_0, rtsp_src_1});
|
||||
osd->attach_to({yolo_detector});
|
||||
split->attach_to({osd});
|
||||
screen_des_0->attach_to({split});
|
||||
rtmp_des_1->attach_to({split});
|
||||
|
||||
// start channels
|
||||
file_src_0->start();
|
||||
rtsp_src_1->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0, rtsp_src_1});
|
||||
board.display();
|
||||
}
|
||||
68
samples/src_des_sample.cpp
Normal file
68
samples/src_des_sample.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/vp_rtsp_src_node.h"
|
||||
#include "../nodes/vp_udp_src_node.h"
|
||||
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_fake_des_node.h"
|
||||
#include "../nodes/vp_file_des_node.h"
|
||||
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_split_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## src des sample ##
|
||||
* show how src nodes and des nodes work
|
||||
* 3 (file, rtsp, udp) input and merge into 1 infer task, then resume to 3 branches for outputs (screen, rtmp, fake)
|
||||
*/
|
||||
|
||||
int main() {
|
||||
|
||||
// log config
|
||||
// ...
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.5);
|
||||
auto rtsp_src_1 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_1", 1, "rtsp://admin:admin12345@192.168.77.203", 0.4);
|
||||
auto udp_src_2 = std::make_shared<vp_nodes::vp_udp_src_node>("udp_src_2", 2, 6000, 0.3);
|
||||
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_vehicle_detector","./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
|
||||
auto split = std::make_shared<vp_nodes::vp_split_node>("", true);
|
||||
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto osd_1 = std::make_shared<vp_nodes::vp_osd_node>("osd_1", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto osd_2 = std::make_shared<vp_nodes::vp_osd_node>("osd_2", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto rtmp_des_1 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 1, "rtmp://192.168.77.60/live/10000");
|
||||
auto fake_des_2 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_2", 2);
|
||||
|
||||
// construct pipeline
|
||||
// auto merge
|
||||
trt_vehicle_detector->attach_to({file_src_0, rtsp_src_1, udp_src_2});
|
||||
|
||||
split->attach_to({trt_vehicle_detector});
|
||||
|
||||
// resume to 3 branches
|
||||
osd_0->attach_to({split});
|
||||
osd_1->attach_to({split});
|
||||
osd_2->attach_to({split});
|
||||
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_1->attach_to({osd_1});
|
||||
fake_des_2->attach_to({osd_2});
|
||||
|
||||
// start channels
|
||||
file_src_0->start();
|
||||
rtsp_src_1->start();
|
||||
udp_src_2->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0, rtsp_src_1, udp_src_2});
|
||||
board.display();
|
||||
}
|
||||
45
samples/trt_infer_sample.cpp
Normal file
45
samples/trt_infer_sample.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_plate_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
#include "../nodes/vp_file_des_node.h"
|
||||
|
||||
/*
|
||||
* ## trt infer sample ##
|
||||
* vehicle and plate detector based on tensorrt (install tensorrt first!)
|
||||
* 1 video input and 3 outputs (screen, file, rtmp)
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/plate.mp4");
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto trt_vehicle_plate_detector = std::make_shared<vp_nodes::vp_trt_vehicle_plate_detector>("vehicle_plate_detector", "./vp_data/models/trt/plate/det_v8.5.trt", "./vp_data/models/trt/plate/rec_v8.5.trt");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node_v2>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0, true, vp_objects::vp_size{640, 360});
|
||||
auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/10000", vp_objects::vp_size{1280, 720});
|
||||
auto file_des_0 = std::make_shared<vp_nodes::vp_file_des_node>("file_des_0", 0, ".");
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({file_src_0});
|
||||
trt_vehicle_plate_detector->attach_to({trt_vehicle_detector});
|
||||
osd_0->attach_to({trt_vehicle_plate_detector});
|
||||
|
||||
// split into 3 sub branches automatically
|
||||
screen_des_0->attach_to({osd_0});
|
||||
rtmp_des_0->attach_to({osd_0});
|
||||
file_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
60
samples/trt_yolov8_sample.cpp
Normal file
60
samples/trt_yolov8_sample.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_yolov8_detector.h"
|
||||
#include "../nodes/infers/vp_trt_yolov8_seg_detector.h"
|
||||
#include "../nodes/infers/vp_trt_yolov8_pose_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node_v3.h"
|
||||
#include "../nodes/osd/vp_pose_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## trt yolov8 sample ##
|
||||
* detection/segmentation/pose_estimation using yolov8 based on tensorrt
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes for 1st pipeline
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/face2.mp4");
|
||||
auto yolo8_detector = std::make_shared<vp_nodes::vp_trt_yolov8_detector>("yolo8_detector", "./vp_data/models/trt/others/yolov8s_v8.5.engine", "./vp_data/models/coco_80classes.txt");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node_v3>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// create nodes for 2nd pipeline
|
||||
auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/face2.mp4");
|
||||
auto yolo8_seg_detector = std::make_shared<vp_nodes::vp_trt_yolov8_seg_detector>("yolo8_seg_detector", "./vp_data/models/trt/others/yolov8s-seg_v8.5.engine", "./vp_data/models/coco_80classes.txt");
|
||||
auto osd_1 = std::make_shared<vp_nodes::vp_osd_node_v3>("osd_1", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_1 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_1", 1);
|
||||
|
||||
// create nodes for 3rd pipeline
|
||||
auto file_src_2 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_2", 2, "./vp_data/test_video/face2.mp4");
|
||||
auto yolo8_pose_detector = std::make_shared<vp_nodes::vp_trt_yolov8_pose_detector>("yolo8_pose_detector", "./vp_data/models/trt/others/yolov8s-pose_v8.5.engine");
|
||||
auto osd_2 = std::make_shared<vp_nodes::vp_pose_osd_node>("osd_2");
|
||||
auto screen_des_2 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_2", 2);
|
||||
|
||||
// construct 1st pipeline
|
||||
yolo8_detector->attach_to({file_src_0});
|
||||
osd_0->attach_to({yolo8_detector});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// construct 2nd pipeline
|
||||
yolo8_seg_detector->attach_to({file_src_1});
|
||||
osd_1->attach_to({yolo8_seg_detector});
|
||||
screen_des_1->attach_to({osd_1});
|
||||
|
||||
// construct 3rd pipeline
|
||||
yolo8_pose_detector->attach_to({file_src_2});
|
||||
osd_2->attach_to({yolo8_pose_detector});
|
||||
screen_des_2->attach_to({osd_2});
|
||||
|
||||
// start pipelines
|
||||
file_src_0->start();
|
||||
file_src_1->start();
|
||||
file_src_2->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0, file_src_1, file_src_2});
|
||||
board.display();
|
||||
}
|
||||
36
samples/trt_yolov8_sample2.cpp
Normal file
36
samples/trt_yolov8_sample2.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_yolov8_detector.h"
|
||||
#include "../nodes/infers/vp_trt_yolov8_classifier.h"
|
||||
#include "../nodes/osd/vp_osd_node_v3.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## trt yolov8 sample2 ##
|
||||
* detection/classification using yolov8 based on tensorrt
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/mask_rcnn.mp4");
|
||||
auto yolo8_detector = std::make_shared<vp_nodes::vp_trt_yolov8_detector>("yolo8_detector", "./vp_data/models/trt/others/yolov8s_v8.5.engine", "./vp_data/models/coco_80classes.txt");
|
||||
auto yolo8_classifier = std::make_shared<vp_nodes::vp_trt_yolov8_classifier>("yolo8_classifier", "./vp_data/models/trt/others/yolov8s-cls_v8.5.engine", "./vp_data/models/imagenet_1000labels1.txt");
|
||||
auto osd = std::make_shared<vp_nodes::vp_osd_node_v3>("osd", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
yolo8_detector->attach_to({file_src_0});
|
||||
yolo8_classifier->attach_to({yolo8_detector});
|
||||
osd->attach_to({yolo8_classifier});
|
||||
screen_des_0->attach_to({osd});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
32
samples/vehicle_body_scan_sample.cpp
Normal file
32
samples/vehicle_body_scan_sample.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_scanner.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## vehicle_body_scan_sample ##
|
||||
* detect wheels and vehicle type based on side view of vehicle
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_src_0", 0, "./vp_data/test_images/body/%d.jpg");
|
||||
auto vehicle_scanner = std::make_shared<vp_nodes::vp_trt_vehicle_scanner>("vehicle_scanner", "./vp_data/models/trt/vehicle/vehicle_scan_v8.5.trt");
|
||||
auto osd = std::make_shared<vp_nodes::vp_osd_node>("osd");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
vehicle_scanner->attach_to({image_src_0});
|
||||
osd->attach_to({vehicle_scanner});
|
||||
screen_des_0->attach_to({osd});
|
||||
|
||||
image_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_color_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_type_classifier.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_feature_encoder.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/osd/vp_cluster_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_fake_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## vehicle_cluster_based_on_classify_encoding_sample ##
|
||||
* vehicle cluster based on classify(categories) and encoding(features), pipeline would display 3 windows (cluster by t-SNE, cluster by categories, detect osd result)
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_src_0", 0, "./vp_data/test_images/vehicle/%d.jpg");
|
||||
//auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./test_video/22.mp4");
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("trt_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto trt_vehicle_color_classifier = std::make_shared<vp_nodes::vp_trt_vehicle_color_classifier>("trt_color_cls", "./vp_data/models/trt/vehicle/vehicle_color_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto trt_vehicle_type_classifier = std::make_shared<vp_nodes::vp_trt_vehicle_type_classifier>("trt_type_cls", "./vp_data/models/trt/vehicle/vehicle_type_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto trt_vehicle_feature_encoder = std::make_shared<vp_nodes::vp_trt_vehicle_feature_encoder>("trt_encoder", "./vp_data/models/trt/vehicle/vehicle_embedding_v8.5.trt", std::vector<int>{0, 1, 2});
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
auto cluster_0 = std::make_shared<vp_nodes::vp_cluster_node>("cluster_0", true, std::vector<std::string>{"red", "white", "black", "blue", "yellow", "bus", "small_truck", "van", "tanker"}, 1000);
|
||||
auto fake_des_0 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({image_src_0});
|
||||
//trt_vehicle_detector->attach_to({file_src_0});
|
||||
trt_vehicle_color_classifier->attach_to({trt_vehicle_detector});
|
||||
trt_vehicle_type_classifier->attach_to({trt_vehicle_color_classifier});
|
||||
trt_vehicle_feature_encoder->attach_to({trt_vehicle_type_classifier});
|
||||
|
||||
// split into 2 branches automatically
|
||||
/* branch of osd -> screen des*/
|
||||
osd_0->attach_to({trt_vehicle_feature_encoder});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
/* branch of cluster -> fake des*/
|
||||
cluster_0->attach_to({trt_vehicle_feature_encoder});
|
||||
fake_des_0->attach_to({cluster_0}); // to keep pipeline complete
|
||||
|
||||
// start pipeline
|
||||
image_src_0->start();
|
||||
//file_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
//vp_utils::vp_analysis_board board({file_src_0});
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display();
|
||||
}
|
||||
32
samples/vehicle_tracking_sample.cpp
Normal file
32
samples/vehicle_tracking_sample.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_trt_vehicle_detector.h"
|
||||
#include "../nodes/osd/vp_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/track/vp_sort_track_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_stop.mp4", 0.5);
|
||||
auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", "./vp_data/models/trt/vehicle/vehicle_v8.5.trt");
|
||||
auto track_0 = std::make_shared<vp_nodes::vp_sort_track_node>("track_0");
|
||||
auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
trt_vehicle_detector->attach_to({file_src_0});
|
||||
track_0->attach_to({trt_vehicle_detector});
|
||||
osd_0->attach_to({track_0});
|
||||
screen_des_0->attach_to({osd_0});
|
||||
|
||||
// start pipeline
|
||||
file_src_0->start();
|
||||
|
||||
// visualize pipeline for debug
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
42
samples/video_restoration_sample.cpp
Normal file
42
samples/video_restoration_sample.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/vp_image_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_restoration_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_file_des_node.h"
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## video_restoration_sample ##
|
||||
* enhance for any video/images, no training need before running.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto image_src_0 = std::make_shared<vp_nodes::vp_image_src_node>("image_file_src_0", 0, "./vp_data/test_images/restoration/1/%d.jpg", 3);
|
||||
auto restoration_node = std::make_shared<vp_nodes::vp_restoration_node>("restoration_node", "./vp_data/models/restoration/realesrgan-x4.onnx");
|
||||
auto screen_des_0_ori = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0_ori", 0, false);
|
||||
auto screen_des_0_osd = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0_osd", 0);
|
||||
|
||||
// construct pipeline
|
||||
restoration_node->attach_to({image_src_0});
|
||||
screen_des_0_ori->attach_to({restoration_node});
|
||||
screen_des_0_osd->attach_to({restoration_node});
|
||||
|
||||
// start pipeline
|
||||
image_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({image_src_0});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
image_src_0->detach_recursively();
|
||||
}
|
||||
130
samples/vp_logger_sample.cpp
Normal file
130
samples/vp_logger_sample.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "../utils/vp_utils.h"
|
||||
#include "../utils/logger/vp_logger.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
/*
|
||||
* ## sample for vp_logger ##
|
||||
* show how vp_logger works
|
||||
*/
|
||||
|
||||
int main() {
|
||||
// config for log content
|
||||
// VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
// VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
// VP_SET_LOG_INCLUDE_LEVEL(false);
|
||||
|
||||
// config for output
|
||||
// VP_SET_LOG_TO_CONSOLE(false);
|
||||
// VP_SET_LOG_TO_FILE(false);
|
||||
|
||||
// config for log folder
|
||||
VP_SET_LOG_DIR("./log");
|
||||
|
||||
// config log level
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::DEBUG);
|
||||
|
||||
// config for kafka, ignored automatically if not prepared for kafka
|
||||
VP_SET_LOG_TO_KAFKA(true); // false by default if not set
|
||||
VP_SET_LOG_KAFKA_SERVERS_AND_TOPIC("192.168.77.87:9092/vp_log");
|
||||
|
||||
// init
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// 6 threads logging separately
|
||||
auto func1 = []() {
|
||||
while (true) {
|
||||
/* code */
|
||||
auto id = std::this_thread::get_id();
|
||||
std::stringstream ss;
|
||||
ss << std::hex << id;
|
||||
auto thread_id = ss.str();
|
||||
VP_ERROR(vp_utils::string_format("thread id: %s", thread_id.c_str()));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
auto func2 = []() {
|
||||
while (true) {
|
||||
/* code */
|
||||
auto id = std::this_thread::get_id();
|
||||
std::stringstream ss;
|
||||
ss << std::hex << id;
|
||||
auto thread_id = ss.str();
|
||||
VP_DEBUG(vp_utils::string_format("thread id: %s", thread_id.c_str()));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(13));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
auto func3 = []() {
|
||||
while (true) {
|
||||
/* code */
|
||||
auto id = std::this_thread::get_id();
|
||||
std::stringstream ss;
|
||||
ss << std::hex << id;
|
||||
auto thread_id = ss.str();
|
||||
VP_INFO(vp_utils::string_format("thread id: %s", thread_id.c_str()));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(4));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
auto func4 = []() {
|
||||
while (true) {
|
||||
/* code */
|
||||
auto id = std::this_thread::get_id();
|
||||
std::stringstream ss;
|
||||
ss << std::hex << id;
|
||||
auto thread_id = ss.str();
|
||||
VP_WARN(vp_utils::string_format("thread id: %s", thread_id.c_str()));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
auto func5 = []() {
|
||||
while (true) {
|
||||
/* code */
|
||||
auto id = std::this_thread::get_id();
|
||||
std::stringstream ss;
|
||||
ss << std::hex << id;
|
||||
auto thread_id = ss.str();
|
||||
VP_ERROR(vp_utils::string_format("thread id: %s", thread_id.c_str()));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
auto func6 = []() {
|
||||
while (true) {
|
||||
/* code */
|
||||
auto id = std::this_thread::get_id();
|
||||
std::stringstream ss;
|
||||
ss << std::hex << id;
|
||||
auto thread_id = ss.str();
|
||||
VP_INFO(vp_utils::string_format("thread id: %s", thread_id.c_str()));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
std::thread t1(func1);
|
||||
std::thread t2(func2);
|
||||
std::thread t3(func3);
|
||||
std::thread t4(func4);
|
||||
std::thread t5(func5);
|
||||
std::thread t6(func6);
|
||||
|
||||
t1.join();
|
||||
t2.join();
|
||||
t3.join();
|
||||
t4.join();
|
||||
t5.join();
|
||||
t6.join();
|
||||
|
||||
std::getchar();
|
||||
}
|
||||
60
samples/vp_test.cpp
Normal file
60
samples/vp_test.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/vp_rtsp_src_node.h"
|
||||
#include "../nodes/infers/vp_yunet_face_detector_node.h"
|
||||
#include "../nodes/infers/vp_sface_feature_encoder_node.h"
|
||||
#include "../nodes/osd/vp_face_osd_node_v2.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
#include "../nodes/vp_rtmp_des_node.h"
|
||||
#include "../nodes/vp_fake_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## vp_test ##
|
||||
* test anything for videopipe in this cpp.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
|
||||
VP_SET_LOG_INCLUDE_THREAD_ID(false);
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto rtsp_src_0 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_0", 0, "rtsp://192.168.77.193:8554/stream/main", 1, "avdec_h264", 1);
|
||||
auto fake_des_0 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_0", 0);
|
||||
auto rtsp_src_1 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_1", 1, "rtsp://192.168.77.193:8554/stream/main", 1, "avdec_h264", 1);
|
||||
auto fake_des_1 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_1", 1);
|
||||
auto rtsp_src_2 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_2", 2, "rtsp://192.168.77.193:8554/stream/main", 1, "avdec_h264", 1);
|
||||
auto fake_des_2 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_2", 2);
|
||||
auto rtsp_src_3 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_3", 3, "rtsp://192.168.77.193:8554/stream/main", 1, "avdec_h264", 1);
|
||||
auto fake_des_3 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_3", 3);
|
||||
auto rtsp_src_4 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_4", 4, "rtsp://192.168.77.193:8554/stream/main", 1, "avdec_h264", 1);
|
||||
auto fake_des_4 = std::make_shared<vp_nodes::vp_fake_des_node>("fake_des_4", 4);
|
||||
|
||||
// construct pipeline
|
||||
fake_des_0->attach_to({rtsp_src_0});
|
||||
fake_des_1->attach_to({rtsp_src_1});
|
||||
fake_des_2->attach_to({rtsp_src_2});
|
||||
fake_des_3->attach_to({rtsp_src_3});
|
||||
fake_des_4->attach_to({rtsp_src_4});
|
||||
|
||||
// start
|
||||
rtsp_src_0->start();
|
||||
rtsp_src_1->start();
|
||||
rtsp_src_2->start();
|
||||
rtsp_src_3->start();
|
||||
rtsp_src_4->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({rtsp_src_0, rtsp_src_1, rtsp_src_2, rtsp_src_3, rtsp_src_4});
|
||||
board.display(1, false);
|
||||
|
||||
std::string wait;
|
||||
std::getline(std::cin, wait);
|
||||
rtsp_src_0->detach_recursively();
|
||||
rtsp_src_1->detach_recursively();
|
||||
rtsp_src_2->detach_recursively();
|
||||
rtsp_src_3->detach_recursively();
|
||||
rtsp_src_4->detach_recursively();
|
||||
}
|
||||
34
samples/yolov5_seg_sample.cpp
Normal file
34
samples/yolov5_seg_sample.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "../nodes/vp_file_src_node.h"
|
||||
#include "../nodes/infers/vp_yolo5_seg_node.h"
|
||||
#include "../nodes/osd/vp_osd_node_v3.h"
|
||||
#include "../nodes/vp_screen_des_node.h"
|
||||
|
||||
#include "../utils/analysis_board/vp_analysis_board.h"
|
||||
|
||||
/*
|
||||
* ## yolov5-seg sample ##
|
||||
* driving area segmentation(das) using yolov5-seg-v7.0.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
|
||||
VP_LOGGER_INIT();
|
||||
|
||||
// create nodes
|
||||
auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./vp_data/test_video/vehicle_count.mp4", 0.6);
|
||||
// 2 classes using yolov5-seg
|
||||
auto das_detector = std::make_shared<vp_nodes::vp_yolo5_seg_node>("das_detector", "./vp_data/models/lane/das.onnx", "./vp_data/models/lane/das_2classes.txt");
|
||||
auto osd_v3_0 = std::make_shared<vp_nodes::vp_osd_node_v3>("osd_v3_0", "./vp_data/font/NotoSansCJKsc-Medium.otf", false);
|
||||
auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
|
||||
|
||||
// construct pipeline
|
||||
das_detector->attach_to({file_src_0});
|
||||
osd_v3_0->attach_to({das_detector});
|
||||
screen_des_0->attach_to({osd_v3_0});
|
||||
|
||||
file_src_0->start();
|
||||
|
||||
// for debug purpose
|
||||
vp_utils::vp_analysis_board board({file_src_0});
|
||||
board.display();
|
||||
}
|
||||
Reference in New Issue
Block a user