Selaa lähdekoodia

修改main函数

leon 2 viikkoa sitten
vanhempi
commit
f3f74777ec
4 muutettua tiedostoa jossa 16 lisäystä ja 7 poistoa
  1. 1 1
      Makefile
  2. 12 3
      src/main.cpp
  3. 1 1
      src/nodes/draw/drawNode.cpp
  4. 2 2
      src/pipeline/pipeline.cpp

+ 1 - 1
Makefile

@@ -45,7 +45,7 @@ library_paths        := $(opencv_library_path) \
 link_opencv       := opencv_core opencv_imgproc opencv_videoio opencv_imgcodecs
 link_trt          := nvinfer nvinfer_plugin nvonnxparser
 link_cuda         := cuda cublas cudart cudnn nvcuvid nvidia-encode
-link_sys          := stdc++ dl
+link_sys          := stdc++ dl yaml-cpp
 link_ffmpeg       := avcodec avformat swresample swscale avutil
 
 link_librarys     := $(link_opencv) $(link_ffmpeg) $(link_trt) $(link_cuda) $(link_sys)

+ 12 - 3
src/main.cpp

@@ -16,12 +16,21 @@
 int main(int argc , char* argv[])
 {
     plog::init(plog::info, "log/vsp.log", 1000000, 5);
-    if (argc < 2) {
-        std::cerr << "Usage: " << argv[0] << " <json_path>" << std::endl;
+    if (argc < 3) {
+        std::cerr << "Usage: " << argv[0] << " <config_path>" << std::endl;
         return 1;
     }
-    const char* json_path = argv[1];
+    const char* config_path = argv[1];
+    const char* config_type = argv[2];
     Pipe::PipelineManager pipeline_manager;
+    if (std::string(config_type) == "yaml") {
+        pipeline_manager.create_from_yaml(std::string(config_path));
+    } else if (std::string(config_type) == "json") {
+        pipeline_manager.create_from_json(std::string(config_path));
+    } else {
+        std::cerr << "Unknown config type: " << config_type << std::endl;
+        return 1;
+    }
     pipeline_manager.create_from_json(std::string(json_path));
 
     for (const auto& p : pipeline_manager.getPipelines()) {

+ 1 - 1
src/nodes/draw/drawNode.cpp

@@ -234,8 +234,8 @@ void DrawNode::draw_result(cv::Mat& image, const data::BoxArray& result)
 
 void DrawNode::handle_data(std::shared_ptr<meta::BaseData>& meta_data) 
 {
-  frame_data->draw_image = frame_data->image.clone();
     auto frame_data = std::dynamic_pointer_cast<meta::FrameData>(meta_data);
+    frame_data->draw_image = frame_data->image.clone();
     if (config_data_ == nullptr) 
     {
       

+ 2 - 2
src/pipeline/pipeline.cpp

@@ -427,8 +427,8 @@ void PipelineManager::create_from_yaml(const std::string& yaml_path) {
                                             current_pipeline.nodes[i + 1],
                                             max_queue_size,
                                             strategy);
-                             std::cout << "  Linked node " << current_pipeline.nodes[i]->get_id()
-                                      << " -> " << current_pipeline.nodes[i+1]->get_id() << std::endl;
+                             std::cout << "  Linked node " << current_pipeline.nodes[i]->get_name()
+                                      << " -> " << current_pipeline.nodes[i+1]->get_name() << std::endl;
                         }
                     }
                 } else {