VideoPipe可视化视频结构化框架更新总结(2023-3-30)
博客园 2023-03-30 14:40:05

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


(资料图)

往期文章:https://www.cnblogs.com/xiaozhi_5638/p/16969546.html

最近有多个更新,有兴趣的扫码加群交流。

新增实例分割相关支持

增加了基于mask-rcnn的实例分割插件和相关sample。

1 #include "VP.h" 2  3 #include "../nodes/vp_file_src_node.h" 4 #include "../nodes/infers/vp_mask_rcnn_detector_node.h" 5 #include "../nodes/track/vp_sort_track_node.h" 6 #include "../nodes/osd/vp_osd_node_v3.h" 7 #include "../nodes/vp_screen_des_node.h" 8  9 #include "../utils/analysis_board/vp_analysis_board.h"10 11 /*12 * ## mask rcnn sample ##13 * image segmentation using mask rcnn.14 */15 16 #if mask_rcnn_sample17 18 int main() {19     VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);20     VP_LOGGER_INIT();21 22     // create nodes23     auto file_src_0 = std::make_shared("file_src_0", 0, "./test_video/19.mp4", 0.6);24     auto mask_rcnn_detector = std::make_shared("mask_rcnn_detector", "./models/mask_rcnn/frozen_inference_graph.pb", "./models/mask_rcnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt", "./models/coco_80classes.txt");25     auto track_0 = std::make_shared("sort_track_0");26     auto osd_v3_0 = std::make_shared("osd_v3_0", "../third_party/paddle_ocr/font/NotoSansCJKsc-Medium.otf");27     auto screen_des_0 = std::make_shared("screen_des_0", 0);28 29     // construct pipeline30     mask_rcnn_detector->attach_to({file_src_0});31     track_0->attach_to({mask_rcnn_detector});32     osd_v3_0->attach_to({track_0});33     screen_des_0->attach_to({osd_v3_0});34 35     file_src_0->start();36 37     // for debug purpose38     vp_utils::vp_analysis_board board({file_src_0});39     board.display();40 }41 42 43 #endif

上面代码效果图如下:

新增语义分割相关支持

新增了基于ENet网络的语义分割插件和sample。

1 #include "VP.h" 2  3 #include "../nodes/vp_file_src_node.h" 4 #include "../nodes/infers/vp_enet_seg_node.h" 5 #include "../nodes/osd/vp_seg_osd_node.h" 6 #include "../nodes/vp_screen_des_node.h" 7  8 #include "../utils/analysis_board/vp_analysis_board.h" 9 10 /*11 * ## enet seg sample ##12 * semantic segmentation based on ENet.13 * 1 input, 2 outputs including orignal frame and mask frame.14 */15 16 #if enet_seg_sample17 18 int main() {19     VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);20     VP_LOGGER_INIT();21 22     // create nodes23     auto file_src_0 = std::make_shared("file_src_0", 0, "./test_video/21.mp4");24     auto enet_seg = std::make_shared("enet_seg", "models/enet-cityscapes/enet-model.net");25     auto seg_osd_0 = std::make_shared("seg_osd_0", "models/enet-cityscapes/enet-classes.txt", "models/enet-cityscapes/enet-colors.txt");26     auto screen_des_mask = std::make_shared("screen_des_mask", 0, true, vp_objects::vp_size(400, 225));27     auto screen_des_original = std::make_shared("screen_des_original", 0, false, vp_objects::vp_size(400, 225));28 29     // construct pipeline30     enet_seg->attach_to({file_src_0});31     seg_osd_0->attach_to({enet_seg});32     screen_des_mask->attach_to({seg_osd_0});33     screen_des_original->attach_to({seg_osd_0});34 35     file_src_0->start();36 37     // for debug purpose38     vp_utils::vp_analysis_board board({file_src_0});39     board.display();40 }41 42 #endif

上面代码效果图如下:

新增多级推理插件sample

多个检测、分类插件串联,不同分类器作用于不同的主目标:

1 #include "VP.h" 2  3 #include "../nodes/vp_file_src_node.h" 4 #include "../nodes/infers/vp_yolo_detector_node.h" 5 #include "../nodes/infers/vp_classifier_node.h" 6 #include "../nodes/osd/vp_osd_node.h" 7 #include "../nodes/vp_screen_des_node.h" 8 #include "../utils/analysis_board/vp_analysis_board.h" 9 10 /*11 * ## multi detectors and classifiers sample ##12 * show multi infer nodes work together.13 * 1 detector and 2 classifiers applied on primary class ids(1/2/3).14 */15 16 #if multi_detectors_and_classifiers_sample17 18 int main() {19     VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);20     VP_LOGGER_INIT();21 22     // create nodes23     auto file_src_0 = std::make_shared("file_src_0", 0, "test_video/20.mp4", 0.6);24     /* primary detector */25     // labels for detector model26     // 0 - person27     // 1 - car28     // 2 - bus29     // 3 - truck30     // 4 - 2wheel31     auto primary_detector = std::make_shared("primary_detector", "models/det_cls/yolov3-tiny-2022-0721_best.weights", "models/det_cls/yolov3-tiny-2022-0721.cfg", "models/det_cls/yolov3_tiny_5classes.txt", 416, 416, 1);32     /* secondary classifier 1, applied to car(1)/bus(2)/truck(3) only */33     auto _1st_classifier = std::make_shared("1st_classifier", "models/det_cls/vehicle/resnet18-batch=N-type_view_0322_nhwc.onnx", "", "models/det_cls/vehicle/vehicle_types.txt", 224, 224, 1, std::vector{1, 2, 3}, 10, false, 1, cv::Scalar(), cv::Scalar(), true, true);34     /* secondary classifier 2, applied to car(1)/bus(2)/truck(3) only */35     auto _2nd_classifier = std::make_shared("2nd_classifier", "models/det_cls/vehicle/resnet18-batch=N-color_view_0322_nhwc.onnx", "", "models/det_cls/vehicle/vehicle_colors.txt", 224, 224, 1, std::vector{1, 2, 3}, 10, false, 1, cv::Scalar(), cv::Scalar(), true, true);36     auto osd_0 = std::make_shared("osd_0");37     auto screen_des_0 = std::make_shared("screen_des_o", 0);38 39     // construct pipeline40     primary_detector->attach_to({file_src_0});41     _1st_classifier->attach_to({primary_detector});42     _2nd_classifier->attach_to({_1st_classifier});43     osd_0->attach_to({_2nd_classifier});44     screen_des_0->attach_to({osd_0});45 46     // start47     file_src_0->start();48 49     // for debug purpose50     vp_utils::vp_analysis_board board({file_src_0});51     board.display();52 }53 54 #endif

上面代码运行效果如下:

新增图片源输入插件

支持以图片方式输入(文件或UDP),频率可调、各个通道互相独立。

1 #include "VP.h" 2  3 #include "../nodes/vp_image_src_node.h" 4 #include "../nodes/infers/vp_yolo_detector_node.h" 5 #include "../nodes/osd/vp_osd_node.h" 6 #include "../nodes/vp_split_node.h" 7 #include "../nodes/vp_screen_des_node.h" 8  9 #include "../utils/analysis_board/vp_analysis_board.h"10 11 /*12 * ## image_src_sample ##13 * show how vp_image_src_node works, read image from local file or receive image from remote via udp.14 */15 16 #if image_src_sample17 18 int main() {19     VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);20     VP_LOGGER_INIT();21 22     // create nodes23     auto image_src_0 = std::make_shared("image_file_src_0", 0, "./images/test_%d.jpg", 1, 0.4); // read 1 image EVERY 1 second from local files, such as test_0.jpg,test_1.jpg24     /* 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` */25     auto image_src_1 = std::make_shared("image_udp_src_1", 1, "6000", 3);                       // receive 1 image EVERY 3 seconds from remote via udp , such as 127.0.0.1:600026     auto yolo_detector = std::make_shared("yolo_detector", "models/det_cls/yolov3-tiny-2022-0721_best.weights", "models/det_cls/yolov3-tiny-2022-0721.cfg", "models/det_cls/yolov3_tiny_5classes.txt");27     auto osd = std::make_shared("osd");28     auto split = std::make_shared("split_by_channel", true);    // split by channel index (important!)29     auto screen_des_0 = std::make_shared("screen_des_0", 0);30     auto screen_des_1 = std::make_shared("screen_des_1", 1);31     32     // construct pipeline33     yolo_detector->attach_to({image_src_0, image_src_1});34     osd->attach_to({yolo_detector});35     split->attach_to({osd});36     screen_des_0->attach_to({split});37     screen_des_1->attach_to({split});38 39     image_src_0->start();  // start read from local file40     image_src_1->start();  // start receive from remote via udp41 42     // for debug purpose43     vp_utils::vp_analysis_board board({image_src_0, image_src_1});44     board.display();45 }46 47 #endif

上面代码运行效果如下:

新增图片结果输出插件

支持以图片格式输出结果(文件或UDP),频率可调、各通道互相独立。

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_image_des_node.h" 9 10 #include "../utils/analysis_board/vp_analysis_board.h"11 12 /*13 * ## image_des_sample ##14 * show how vp_image_des_node works, save image to local file or push image to remote via udp.15 */16 17 #if image_des_sample18 19 int main() {20     VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);21     VP_LOGGER_INIT();22 23     // create nodes24     auto file_src_0 = std::make_shared("file_src_0", 0, "./test_video/10.mp4", 0.6);25     auto yunet_face_detector_0 = std::make_shared("yunet_face_detector_0", "./models/face/face_detection_yunet_2022mar.onnx");26     auto sface_face_encoder_0 = std::make_shared("sface_face_encoder_0", "./models/face/face_recognition_sface_2021dec.onnx");27     auto osd_0 = std::make_shared("osd_0");28     auto screen_des_0 = std::make_shared("screen_des_0", 0);29     30     /* save to file, `%d` is placeholder for filename index */31     //auto image_des_0 = std::make_shared("image_file_des_0", 0, "./images/%d.jpg", 3);32     33     /* 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` */34     auto image_des_0 = std::make_shared("image_udp_des_0", 0, "192.168.77.248:6000", 3, vp_objects::vp_size(400, 200));35 36     // construct pipeline37     yunet_face_detector_0->attach_to({file_src_0});38     sface_face_encoder_0->attach_to({yunet_face_detector_0});39     osd_0->attach_to({sface_face_encoder_0});40     screen_des_0->attach_to({osd_0});41     image_des_0->attach_to({osd_0});42 43     file_src_0->start();44 45     // for debug purpose46     vp_utils::vp_analysis_board board({file_src_0});47     board.display();48 }49 50 #endif

上面代码运行效果如下:

更多更新扫码加入微信群,及时获取通知。

VideoPipe可视化视频结构化框架更新总结(2023-3-30)

2023-03-30

和讯个股快报:2023年03月30日 晶华微(688130)该股换手率大于8%

2023-03-30

每日热门:福州博爱医院男科是正规医院吗_慈心为民_不坑人

2023-03-30

留洋盛况!国青7星闪耀,2人获欧洲豪门重视,木塔力甫冲5大联赛

2023-03-30

环球头条:手机不离手才安心?89.2%受访者手机不在身边不踏实

2023-03-30

未注册商标与注册商标的区别是什么?为什么要注册商标?

2023-03-30

杨志城:甘当“德胜黑山羊”“推销员”

2023-03-30

天天滚动:华工科技与十堰市政府签订战略合作框架协议

2023-03-30

五菱汽车(00305.HK)发布公告,该公司将于2023年7月31日派发末期股息每股0.003港元

2023-03-30

英汉金融财经词典_关于英汉金融财经词典的简介 全球百事通

2023-03-30

天天日报丨本市多区道路施工 途经注意通行安全

2023-03-30

当前要闻:原耽什么意思是_原耽什么意思啊?

2023-03-29

金山云(03896)委任仇睿恒为非执行董事

2023-03-29

达县职高参加区九届中小学运动会再创佳绩

2023-03-29

怎么挑选游泳衣 怎么挑选游泳衣质量好

2023-03-29

湖南暂停与渤海银行资金监管合作:慎重在该行存公积金等资金 最资讯

2023-03-29

盘点10款平价的 给长辈的生日礼物

2023-03-29

焦点短讯!您可能没有经常清洁浴室

2023-03-29

呈贡区气象台发布大风预警信号蓝色预警【Ⅳ级/一般】

2023-03-29

平安区:党建“红”引领百业“绿” 天天资讯

2023-03-29