I am trying to create a wrapper in pybind11 to create part of the code in c ++ and I need to use pyopencv_to
inside my function but when I want to build my project I'm getting this error error: ‘pyopencv_to’ was not declared in this scope
pyopencv_to(frame, frame_gpu);
. How can I use pyopencv_to function?
#include <torch/script.h> // One-stop header.
#include <iostream>
#include <memory>
#include <opencv2/opencv.hpp>
#include <opencv2/core/cuda.hpp>
#include <ATen/ATen.h>
#include <pybind11/pybind11.h>
at::Tensor gpumat2torch(PyObject* frame) {
cv::cuda::GpuMat frame_gpu;
pyopencv_to(frame, frame_gpu);
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);
}