Git Product home page Git Product logo

opencv's Issues

pyopencv_from crash while calling Py_INCREF (opencv 4.1.2 python binding with cv2.cpp)

Hello,

I am doing a python binding for a function that returns opencv mat object. so I used pyopencv_from for that as below:

static PyObject *method_convertLeaf2Mat(PyObject *self, PyObject *args) {
    /* inner details....*/
    const cv::Mat& m = i_leaf->getCvMat(cmd_context);
    return pyopencv_from(m);
}

But when pyopencv_from is called, the program crashes. If I remove "Py_INCREF(o);" part from pyopencv_from function then I got following result:

>>> x = mod_imgproc.convertLeaf2Mat(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: <built-in function convertLeaf2Mat> returned NULL without setting an error

Here is the pyopencv_from function definition:

template<>
PyObject* pyopencv_from(const Mat& m)
{
    if( !m.data )
        Py_RETURN_NONE;
    Mat temp, *p = (Mat*)&m;
    if(!p->u || p->allocator != &g_numpyAllocator)
    {
        temp.allocator = &g_numpyAllocator;
        ERRWRAP2(m.copyTo(temp));
        p = &temp;
    }
    PyObject* o = (PyObject*)p->u->userdata;
    Py_INCREF(o);
    return o;
}

I am using opencv 4.1.2. Which part could be wrong?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.