1

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?

2
  • No idea, but there's any reason why you're not using official bindings? Commented Jan 16, 2016 at 20:21
  • I am using C++ openCV to build an android library. I built python bindings to interface with C++ code for fast prototyping. Thanks. Commented Jan 16, 2016 at 20:23

1 Answer 1

1

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();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.