C++ conversion from NumPy array to Mat (OpenCV)

前端 未结 3 364
礼貌的吻别
礼貌的吻别 2020-12-01 20:22

I am writing a thin wrapper around ArUco augmented reality library (which is based on OpenCV). An interface I am trying to build is very simple:

  • Python passes
3条回答
  •  遥遥无期
    2020-12-01 20:50

    The best solution in your situation is using custom boost::python converter for cv::Mat object. OpenCV has Python wrapper and when you are using this wrapper you are operating on Numpy arrays - you don't even need to know that those arrays are converted to cv::Mat objects while "crossing the c++ <-> python border". Writing such converter for simple type is quite easy, however creating converter for cv::Mat isn't simple. Fortunetely someone else already did this - here is version for OpenCV 2.x and here for 3.x. If you are not familiar with boost::python converters, this article should help you.
    Hope it helps, if you wil have any problems, let us know.

提交回复
热议问题