edmBernard / pybind11_opencv_numpy

Implementation of cv::Mat conversion to numpy.array for pybind11
Apache License 2.0
198 stars 41 forks source link

Adding a test for one dimensional case. Currently fails #19

Closed HattrickGenerator closed 3 years ago

HattrickGenerator commented 3 years ago

Exposing a weakness of current in numpy arrays that are one dimensional via the test.py script. The reason for this might be, that strides are not defined in that case. I'll also try to deliver a fix for that soon.

edmBernard commented 3 years ago

Thanks for pointing this up. I'll also check on my side if I can fixed it.

HattrickGenerator commented 3 years ago

Thanks for considering it! I have also had a closer look on the subject and I think it's a non solvable issue: Cv::Mat dimensions are at least two. The dimension of the numpy array in my test is only one however. This means that numpy array will decay into a cv::Mat array that is indistinguishable from a cv::Mat that was generated from a 2D numpy array. As long as we don't have an extra class on the C++ side - storing that literal 1 bit of information - I think this issue isn't solvable. Furthermore an extra class would require custom expressions for MatExpr because it would need to transport that information. It could be considered a design flaw in the opencv matrix class in my opinion.

edmBernard commented 3 years ago

thanks, I'll close this issue. I haven't find a proper way to handle this without lot's of work. a solution could be the use eigen library as a intermediate format