Description
Im trying to run interference using a model that requires an input of [1,2,128,128] in C++.
I have generated two cv::Mat in the format [1,128,128]
I want to upload them to the GPU so i can run interference on them but first i have to concatenate them. How do I concatenate two [1,128,128] images to one [1,2,128,128] so i can upload it and run interference on it?
Environment
TensorRT Version: 8.5.2.2
GPU Type: iGPU ga10b (i think)
Nvidia Driver Version: Jetson Orin Nano
CUDA Version: 11.4.315
CUDNN Version: 8.6.0.166
Operating System + Version: Ubuntu 20.04 focal
Python Version (if applicable):
TensorFlow Version (if applicable):
PyTorch Version (if applicable):
Baremetal or Container (if container which image + tag):
Relevant Files
Here is my preprocessing method that is supposed to upload the two images to the GPU so i can run interference on them:
void ThroatSegmentationFilter::preprocess(PCLRGBFrame &frame, float *gpu_input, const nvinfer1::Dims &dims)
{
if(!frame.ToFframe.intensity.empty()){
auto& bbox = std::any_cast<std::array<std::array<int, 2>, 2>&>(frame.metaData["mouthBox"]);
std::vector<int> fbbox = fixedShapeBBox(frame, bbox);
cv::Mat depth = cv::Mat(480,640, CV_32FC1, frame.ToFframe.depthData);
cv::Point topleft(fbbox[0], fbbox[1]);
cv::Point btmright(fbbox[2], fbbox[3]);
cv::Rect roiRect(topleft, btmright);
cv::Mat roiI = frame.ToFframe.intensity(roiRect);
cv::Mat roiD = depth(roiRect);
auto input_width = dims.d[3];
auto input_height = dims.d[2];
auto channels = dims.d[1];
auto input_size = cv::Size(input_width, input_height);
//TODO: figure out if this is how we concatenate two Images to get the format [1,2,128,128]
cv::cuda::GpuMat gpu_frame;
gpu_frame.upload(roiI);
gpu_frame.upload(roiD);
std::vector< cv::cuda::GpuMat > chw;
for (size_t i = 0; i < channels; ++i)
{
chw.emplace_back(cv::cuda::GpuMat(input_size, CV_32FC1, gpu_input + i * input_width * input_height));
}
cv::cuda::split(gpu_frame, chw);
}
}