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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.