From d586cedd79b009e808d3a8b14b5478663ad6d2da Mon Sep 17 00:00:00 2001 From: luoyao Date: Tue, 30 Jan 2024 10:49:53 +0800 Subject: [PATCH] add hrnet segmentation server app --- .../hrnet_segmentation_server.cpp | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/apps/server/scene_segmentation/hrnet_segmentation_server.cpp diff --git a/src/apps/server/scene_segmentation/hrnet_segmentation_server.cpp b/src/apps/server/scene_segmentation/hrnet_segmentation_server.cpp new file mode 100644 index 00000000..a8ca87dd --- /dev/null +++ b/src/apps/server/scene_segmentation/hrnet_segmentation_server.cpp @@ -0,0 +1,54 @@ +/************************************************ + * Copyright MaybeShewill-CV. All Rights Reserved. + * Author: MaybeShewill-CV + * File: hrnet_segmentation_server.cpp + * Date: 24-1-30 + ************************************************/ +// hrnet segmentation server tool + +#include +#include + +#include "factory/scene_segmentation_task.h" + +using jinq::factory::scene_segmentation::create_hrnet_server; + +int main(int argc, char** argv) { + + google::InitGoogleLogging(argv[0]); + google::InstallFailureSignalHandler(); + google::SetStderrLogging(google::GLOG_INFO); + FLAGS_alsologtostderr = true; + FLAGS_colorlogtostderr = true; + + if (argc != 2) { + LOG(INFO) << "usage:"; + LOG(INFO) << "exe cfg_path"; + return -1; + } + + static WFFacilities::WaitGroup wait_group(1); + + std::string config_file_path = argv[1]; + LOG(INFO) << "cfg file path: " << config_file_path; + auto config = toml::parse(config_file_path); + const auto& server_cfg = config.at("HRNET_SERVER"); + auto port = server_cfg.at("port").as_integer(); + LOG(INFO) << "serve on port: " << port; + + auto server = create_hrnet_server("hrnet_segmentation_server"); + auto status = server->init(config); + if (status != jinq::common::StatusCode::OK) { + LOG(INFO) << "hrnet segmentation server init failed"; + return -1; + } + if (server->start(port) == 0) { + wait_group.wait(); + server->stop(); + } else { + LOG(ERROR) << "Cannot start server"; + return -1; + } + + return 0; +} \ No newline at end of file