Reputation: 9265
I have Boost-Python interface for C++ OpenCv. I am getting this error when I invoke a C++ method from python:
Boost.Python.ArgumentError: Python argument types in
Vision.process(Vision, numpy.ndarray, numpy.ndarray)
did not match C++ signature:
process(python::vision::PythonVision {lvalue}, cv::Mat {lvalue}, cv::Mat {lvalue})
I am using python cv2.so module. How do I convert numpy.ndarray into cv::mat?
Upvotes: 1
Views: 1623
Reputation: 9265
I used the following project:https://github.com/Algomorph/pyboostcvconverter and statically linked to it.
Note (To avoid segmentation fault):
1) PY_ARRAY_UNIQUE_SYMBOL should be defined where import_array is invoked In other places where is included, use NO_IMPORT_ARRAY
#define PY_ARRAY_UNIQUE_SYMBOL PYVISION_ARRAY_API
#include <pyboostcvconverter/pyboostcvconverter.hpp>
2) Invoke init_ar from the BOOST_PYTHON_MODULE
/**
* @brief Initialize Numpy Array
*/
static void init_ar( )
{
// initialize
Py_Initialize();
// defined in numpy
import_array();
}
Upvotes: 1