|
- bitmap = bitmap.squeeze().squeeze();
- bitmap = bitmap* 255;
- bitmap = bitmap.to(torch::kU8).to(torch::kCPU);
- int height, width;
- height = bitmap.size(0);
- width = bitmap.size(1);
- cv::Mat imgbin(cv::Size(width, height), CV_8UC1, bitmap.data_ptr());
复制代码
参考:
【1】libtorch Tensor与opencv Mat相互转换
【2】torch::Tensor与opencv mat矩阵转换
|
|