VideoPipe可視化視頻結構化框架新增功能詳解(2022-11-4)

VideoPipe從國慶節上線源代碼到現在經歷過了一個月時間,期間吸引了若干小夥伴的參與,現將本階段新增內容總結如下,有興趣的朋友可以加微信拉羣交流。

項目地址:https://github.com/sherlockchou86/video_pipe_c

以往文章:https://www.cnblogs.com/xiaozhi_5638/p/16767917.html

跟蹤插件

新增了跟蹤插件,同時實現了默認的SORT目標跟蹤算法,後期擴展Deep SORT算法非常方便。下面是車輛跟蹤的效果(底部是pipe運行狀態圖):

下面是人臉跟蹤的效果:

 

錄像和截圖插件

新增了錄像截圖插件,同時提供了一個人工模擬錄像或截圖的接口供測試。當用戶向管道中發送錄像、截圖控制指令時,錄像截圖插件就開始異步工作。下面是異步錄像原理:

 

日誌庫

新增了一個輕量級的日誌庫,支持多線程異步日誌寫入、支持日誌文件自動拆分。日誌沒使用第三方庫,下面是日誌使用方法和效果:

 1 // log level
 2 VP_SET_LOG_LEVEL(_log_level);
 3 // log file dir
 4 VP_SET_LOG_DIR(_log_dir);
 5 
 6 // log to console or not
 7 VP_SET_LOG_TO_CONSOLE(_log_to_console);
 8 // log to file or not
 9 VP_SET_LOG_TO_FILE(_log_to_file);
10 // TO-DO
11 VP_SET_LOG_TO_KAFKA(_log_to_kafka);
12 
13 // include log level or not
14 VP_SET_LOG_INCLUDE_LEVEL(_include_level);
15 // include code location or not (where the log occurs)
16 VP_SET_LOG_INCLUDE_CODE_LOCATION(_include_code_location);
17 // include thread id or not (std::this_thread::get_id())
18 VP_SET_LOG_INCLUDE_THREAD_ID(_include_thread_id);
19 
20 // warn if log cache in memory exceed this value
21 VP_SET_LOG_CACHE_WARN_THRES(_log_cache_warn_threshold);
 1 [2022-11-04 14:12:47.218][Info ] [file_src_0] reading frame complete, total frame==>354
 2 [2022-11-04 14:12:47.219][Info ] [file_src_0] cycle flag is true, continue!
 3 [2022-11-04 14:15:23.416][Warn ][7ffff7f81000][../nodes/vp_infer_node.cpp:39] [vehicle_detector] cv::dnn::readNet load network failed!
 4 [2022-11-04 14:15:24.227][Info ][7ffff7f81000][../nodes/vp_screen_des_node.cpp:14] [screen_des_0] [appsrc ! videoconvert ! textoverlay text=screen_des_0 halignment=left valignment=top font-desc='Sans,16' shaded-background=true ! timeoverlay halignment=right valignment=top font-desc='Sans,16' shaded-background=true ! queue ! fpsdisplaysink video-sink=ximagesink sync=false]
 5 [2022-11-04 14:15:24.227][Info ][7ffff7f81000][../utils/analysis_board/../vp_pipe_checker.h:167] 
 6 ############# pipe check summary ##############
 7  total layers: 5
 8  layer index,       node names
 9  1                    file_src_0,
10  2                    vehicle_detector,
11  3                    track_0,
12  4                    osd_0,
13  5                    screen_des_0,
14 ############# pipe check summary ##############
15 
16 [2022-11-04 14:16:04.638][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:66] [file_src_0] reading frame complete, total frame==>999
17 [2022-11-04 14:16:04.639][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:68] [file_src_0] cycle flag is true, continue!
18 [2022-11-04 14:16:45.258][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:66] [file_src_0] reading frame complete, total frame==>1999
19 [2022-11-04 14:16:45.259][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:68] [file_src_0] cycle flag is true, continue!
20 [2022-11-04 14:17:25.838][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:66] [file_src_0] reading frame complete, total frame==>2999
21 [2022-11-04 14:17:25.839][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:68] [file_src_0] cycle flag is true, continue!
22 [2022-11-04 14:18:06.498][Info ][7fff47318700][../nodes/vp_file_src_node.cpp:66] [file_src_0] reading frame complete, total frame==>3999

 

sample代碼

新增加13個sample文件,可以獨立運行,涵蓋pipe結構、各種插件使用舉例。下面是1-1-1 sample代碼和效果:

 1 #include "VP.h"
 2 
 3 #include "../nodes/vp_file_src_node.h"
 4 #include "../nodes/infers/vp_yunet_face_detector_node.h"
 5 #include "../nodes/infers/vp_sface_feature_encoder_node.h"
 6 #include "../nodes/osd/vp_face_osd_node_v2.h"
 7 #include "../nodes/vp_screen_des_node.h"
 8 #include "../nodes/vp_rtmp_des_node.h"
 9 
10 #include "../utils/analysis_board/vp_analysis_board.h"
11 
12 /*
13 * ## 1-1-1 sample ##
14 * 1 video input, 1 infer task, and 1 output.
15 */
16 
17 #if _1_1_1_sample
18 
19 int main() {
20     VP_SET_LOG_INCLUDE_CODE_LOCATION(false);
21     VP_SET_LOG_INCLUDE_THREAD_ID(false);
22     VP_LOGGER_INIT();
23 
24     // create nodes
25     auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, "./test_video/10.mp4", 0.6);
26     auto yunet_face_detector_0 = std::make_shared<vp_nodes::vp_yunet_face_detector_node>("yunet_face_detector_0", "./models/face/face_detection_yunet_2022mar.onnx");
27     auto sface_face_encoder_0 = std::make_shared<vp_nodes::vp_sface_feature_encoder_node>("sface_face_encoder_0", "./models/face/face_recognition_sface_2021dec.onnx");
28     auto osd_0 = std::make_shared<vp_nodes::vp_face_osd_node_v2>("osd_0");
29     auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
30 
31     // construct pipeline
32     yunet_face_detector_0->attach_to({file_src_0});
33     sface_face_encoder_0->attach_to({yunet_face_detector_0});
34     osd_0->attach_to({sface_face_encoder_0});
35     screen_des_0->attach_to({osd_0});
36 
37     file_src_0->start();
38 
39     // for debug purpose
40     vp_utils::vp_analysis_board board({file_src_0});
41     board.display();
42 }
43 
44 #endif

上面代碼生成的pipe如下圖所示:

感興趣的朋友加微信交流,框架非常適合新手入門!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章