What is the easiest way to convert ndarray into cv::Mat?

前端 未结 5 1563
悲&欢浪女
悲&欢浪女 2020-12-05 12:31

I\'m trying to create Python/Cython wrapper for C++ library that uses cv::Mat class from OpenCV. In official Python wrapper all functions take

5条回答
  •  萌比男神i
    2020-12-05 13:06

    If it helps, I wrote a wrapper that does exactly this. It's a convenience library that registers a boost::python converter to implicitly convert between OpenCV's popular cv::Mat datatype and NumPy's popular np.array() datatype. This allows a developer to go back and forth between their OpenCV C++ API and Python API written using NumPy with relative ease, avoiding the need to write additional wrappers that handle PyObjects being passed around or returned.

    Take a look: https://github.com/spillai/numpy-opencv-converter

提交回复
热议问题