Closed benknight135 closed 3 years ago
I will have to check if it's possible to pass cv::Mat as reference. It can be a limitation of python more than a limitation of pybind11. https://pybind11.readthedocs.io/en/stable/faq.html#limitations-involving-reference-arguments
I have check and currently with my binding even in some case return by reference are in fact copied. I'll will try to check if I can use the eigen bind provided by pybind11 to allow correctly these reference.
in the Eigen binding provided by pybind11. There enable this by using a Eigen::Ref
that encapsulate the reference explained here : https://pybind11.readthedocs.io/en/stable/advanced/cast/eigen.html#pass-by-reference
I haven't find equivalent way to do that with opencv mat.
I haven't found a proper way to handle this. I'll close the issue for the moment. If you found how we can to this, you are welcome to continue the discussion
I have the following C++ function to try returning a Mat pointer:
I tried using the following pybind:
But I'm not sure how to use it in python as it doesn't deal with pointers. I'm not sure how to run this in python but I tried passing the numpy array like this:
But that doesn't populate the numpy array with the data and remains empty.
I am doing it like this rather than a return variable as I am also trying to support C# with extern C so need to use standard C types.
Please let me know what I am doing wrong or if this is possible?