in inference_pkg/src/image_process.cpp [71:93]
void stack(cv::Mat &currImg, cv::Mat &retImg,
std::vector<cv::Mat> &imageStack, const std::unordered_map<std::string, int> ¶ms) {
auto itChannels = params.find("channels");
if (itChannels == params.end()) {
RCLCPP_ERROR(rclcpp::get_logger("rclcpp"), "Image processing params has no channel entry");
return;
}
// Add image to the stack.
if (imageStack.empty()) {
for (int i = 0; i < itChannels->second; ++i) {
imageStack.push_back(currImg);
}
}
else {
// Remove the oldest image which should be in the back
imageStack.pop_back();
// Add the current image to the front of the vector, this will be of order
// N, if OpenCV refactors cv::merge to used std::deque refactor immediately.
imageStack.insert(imageStack.begin(), currImg);
}
// Populate the return image with the image stack
cv::merge(imageStack, retImg);
}