Skip to content

Commit

Permalink
Using env variable for test iamge location
Browse files Browse the repository at this point in the history
  • Loading branch information
yassiezar committed Aug 26, 2024
1 parent 1a3bcea commit b344e51
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<uchar> img_buf;
cv::imencode(".jpg", image, img_buf);
const auto *encoded_img_b64 = reinterpret_cast<unsigned char *>(img_buf.data());
Expand Down

0 comments on commit b344e51

Please sign in to comment.