PyObject *
转换为cv::cuda::GpuMat
torch::Tensor gpumat2torch(PyObject* frame) {
cv::cuda::GpuMat frame_gpu;
pyopencv_to(frame, frame_gpu); # <-- NOT FOUND
at::ScalarType torch_type = get_torch_type(frame_gpu.type());
auto options = torch::TensorOptions().dtype(torch_type).device(torch::kCUDA);
std::vector<int64_t> sizes = {1,
static_cast<int64_t>(frame_gpu.channels()),
static_cast<int64_t>(frame_gpu.rows),
static_cast<int64_t>(frame_gpu.cols)};
return torch::from_blob(frame_gpu.data, sizes, options);
}
PYBIND11_MODULE(gpumat, m) {
m.doc() = "gpumat2torch function!";
m.def("gpumat2torch", &gpumat2torch, "A function to convert GpuMat to CudaTorch");
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
我发现在OpenCV中有一个要转换的方法,但似乎不是公共的:https://github.com/opencv/opencv/blob/d60ac98ef269f06c433450998bd71236f84ef504/modules/core/misc/python/pyopencv_cuda.hpp
有办法解决这个问题吗
目前没有回答
相关问题 更多 >
编程相关推荐