Given @cuixing158_1 solution, one could convert a std::vector<cv::Mat> into a std::vector<torch::Tensor>. Now, we could use torch::cat 6, to convert the std::vector<torch::Tensor> into a single tensor. For example
std::vector<torch::Tensor> vec;
torch::Tensor ten = torch::cat(vec);