From b344e51da2cc7f68b16e9f5d0548ad9a8921bbce Mon Sep 17 00:00:00 2001 From: Jaycee Lock Date: Mon, 26 Aug 2024 10:58:27 +0100 Subject: [PATCH] Using env variable for test iamge location --- .../clients/client_behaviors/cb_http_request.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/smacc2_sm_reference_library/sm_atomic_openai/include/sm_atomic_openai/clients/client_behaviors/cb_http_request.hpp b/smacc2_sm_reference_library/sm_atomic_openai/include/sm_atomic_openai/clients/client_behaviors/cb_http_request.hpp index 073fcb14..babbf640 100644 --- a/smacc2_sm_reference_library/sm_atomic_openai/include/sm_atomic_openai/clients/client_behaviors/cb_http_request.hpp +++ b/smacc2_sm_reference_library/sm_atomic_openai/include/sm_atomic_openai/clients/client_behaviors/cb_http_request.hpp @@ -74,7 +74,17 @@ class CbHttpRequest : public cl_http::CbHttpRequestBase } // Gather image data - auto image = cv::imread("~/Downloads/wood_table.jpg"); + const auto img_path_cstr = std::getenv("OPENAI_IMG_PATH"); + const auto img_path = img_path_cstr == NULL ? std::string() : std::string(img_path_cstr); + if (img_path.empty()) + { + RCLCPP_FATAL_STREAM( + this->getNode()->get_logger(), "Set the OPENAI_IMG_PATH environment variable to where your test image resides"); + triggerTranstition(); + return; + } + + auto image = cv::imread(img_path); std::vector img_buf; cv::imencode(".jpg", image, img_buf); const auto *encoded_img_b64 = reinterpret_cast(img_buf.data());