Hi, big masters and huge Gods,
I wanna ask a question hope anyone open this link can give me a help which is convert a Tensor to cv::Mat.
I have a Tensor outputs from my model and it’s [1, 19, 32, 43] shape, which is, batch_size, 19 instances, and 32x43 is the featuremap size.
I have it’s type: CPUFloatType. And I want converts it into cv::Mat, here is what I do:
cv::Mat one_mat(heatMapsTensor.size(2), heatMapsTensor.size(3), CV_32FC1); std::memcpy((void *) one_mat.data, one_heat_map.data_ptr(), sizeof(torch::kFloat32) * one_heat_map.numel());
heatMapsTensor is the tensor described above. one_mat is what I need to got.
But I got the mat incorrect. what did I wrong?
I suspect 2 maybe mistake:
- the type maybe not float32, but I do not know which it is;
- the mat shape is not wrong
Any body could help me out?