From 02819b5c047bb354b0ef2374e7c6a6ac4bbd5bba Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期四, 23 一月 2025 11:42:36 +0800
Subject: [PATCH] add sample

---
 samples/from_argv_all_in_one_rtsp.cpp |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/samples/from_argv_all_in_one_rtsp.cpp b/samples/from_argv_all_in_one_rtsp.cpp
index d943159..e08ed54 100644
--- a/samples/from_argv_all_in_one_rtsp.cpp
+++ b/samples/from_argv_all_in_one_rtsp.cpp
@@ -36,31 +36,43 @@
     VP_LOGGER_INIT();
 
     std::vector<std::string> args(argv + 1, argv + argc);
+
     // 榛樿鐨勫懡浠よ鍙傛暟
     std::string rtsp_path = "rtsp://127.0.0.1:8554/demo";
     std::string kafka_server_point = "127.0.0.1:9092";
-
     float resize_ratio = 0.4;
     int skip_interval = 3;
     int channel_index = 21;
+    bool usegpu = false; // 鏂板鍙傛暟锛岄粯璁ゅ�间负 false
 
-    // 濡傛灉鎻愪緵浜嗙涓�涓拰绗簩涓弬鏁帮紝鍒欒鐩栭粯璁ょ殑璺緞
-    if (args.size() >= 5) {
+    // 濡傛灉鎻愪緵浜嗚嚦灏� 6 涓弬鏁帮紝鍒欒鐩栭粯璁ゅ��
+    if (args.size() >= 6) {
         rtsp_path = args[0];
         resize_ratio = std::stof(args[1]);
         kafka_server_point = args[2];
         skip_interval = std::stoi(args[3]);
         channel_index = std::stoi(args[4]);
+        std::string usegpu_arg = args[5];
+        // 灏嗗瓧绗︿覆杞崲涓哄竷灏斿�硷紝鏀寔 true/false 鎴� 1/0
+        std::transform(usegpu_arg.begin(), usegpu_arg.end(), usegpu_arg.begin(), ::tolower);
+        if (usegpu_arg == "true" || usegpu_arg == "1") {
+            usegpu = true;
+        } else if (usegpu_arg == "false" || usegpu_arg == "0") {
+            usegpu = false;
+        } else {
+            std::cerr << "Invalid value for <usegpu>. Please use 'true', 'false', '1', or '0'.\n";
+            return -1;
+        }
     } else {
-        std::cout << "Usage: " << argv[0] << " <rtsp_path> <resize_ratio> <kafka_server_point> <skip_interval>\n";
-        std::cout << "Example: " << argv[0] << " rtsp://admin:Shmixcqwe%21%40%23@172.18.10.113/Streaming/Channels/101 0.4 172.18.0.247:9092 5 21 \n";
+        std::cout << "Usage: " << argv[0] << " <rtsp_path> <resize_ratio> <kafka_server_point> <skip_interval> <channel_index> <usegpu>\n";
+        std::cout << "Example: " << argv[0] << " rtsp://127.0.0.1:8554/demo 0.4 127.0.0.1:9092 5 21 true\n";
         return -1;
     }
 
     // create nodes
     //auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, rtsp_path, resize_ratio);
     //auto file_src_0 = std::make_shared<vp_nodes::vp_rtsp_src_node>("rtsp_src_1", 0, rtsp_path, resize_ratio, "avdec_h264", skip_interval); 
-    auto file_src_0 = std::make_shared<vp_nodes::vp_rtsp_ffmpeg_src_node>("rtsp_src_1", channel_index, rtsp_path, resize_ratio, skip_interval); 
+    auto file_src_0 = std::make_shared<vp_nodes::vp_rtsp_ffmpeg_src_node>("rtsp_src_1", channel_index, rtsp_path, resize_ratio, skip_interval, usegpu); 
     //auto file_src_1 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_1", 1, "./vp_data/test_video/falldown.mp4", 0.5);
     //auto split = std::make_shared<vp_nodes::vp_split_node>("split", false, true);  // split by deep-copy not by channel!
     
@@ -74,8 +86,8 @@
     
     // 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
+        {channel_index, std::vector<vp_objects::vp_point>{vp_objects::vp_point(290, 10), vp_objects::vp_point(340, 10), vp_objects::vp_point(600, 330), vp_objects::vp_point(40, 350)}},  // channel0 -> region
+        {1, std::vector<vp_objects::vp_point>{vp_objects::vp_point(290, 10), vp_objects::vp_point(340, 10), vp_objects::vp_point(600, 330), vp_objects::vp_point(40, 350)}}   // channel1 -> region
     };
     auto ba_jam = std::make_shared<vp_nodes::vp_ba_jam_node>("ba_jam", regions);
     auto ba_stop = std::make_shared<vp_nodes::vp_ba_stop_node>("ba_stop", regions);

--
Gitblit v1.9.1