Closed kartik2112 closed 6 years ago
I have already found the solution to this problem, the description of which I have mentioned here
Hello, I have followed your steps to add cv2.cpp and pycompat.hpp in my directory, and then made some changes you've suggested. But it doesn't work. So I want to check 2 points to make sure that I'm rigidly follow your steps.
Removed lines template<> from lines 393, 426 Added line import_array as the first line in body of bool pyopencv_to(PyObject o, Matx<_Tp, m, n>& mx, const char name) and PyObject* pyopencv_from(const Mat& m). This is because if I wasn't adding this, it was resulting in a segmentation fault. So somewhere I found a solution that import_array() is necessary for initializing this.
There are the last 2 steps of your suggestion. The former asked to removed lines 393, 426. It means only 393 and 426 these 2 lines or from 393 to 426? The latter asked to add " import_array ". But " import_array()" were also mentioned. Which one should I use? if" import_array()" is the right one, should I add ";" after the "()"?
Thanks for your reply~
Check out this folder from our Silatra repository. This is a working version. It is being used in this repository. The filename cv2 is changed to cv_cpp_py_interface for convenience of understanding in this repository
Thanks for your reply. I used the cv_cpp_py_interface.cpp to cover cv2.cpp, all the files in the new folder you mentioned were included in my codes' But the same problem occurred again. Four errors always here! `` error1: cannot declare variable ‘g_numpyAllocator’ to be of abstract type ‘NumpyAllocator’ NumpyAllocator g_numpyAllocator;
error2: ‘class cv::Mat’ has no member named ‘refcount’ m.refcount = refcountFromPyObject(o);
error3: ‘class cv::Mat’ has no member named ‘refcount’ if(!p->refcount || p->allocator != &g_numpyAllocator)
error4: ‘class cv::Mat’ has no member named ‘refcount’ return pyObjectFromRefcount(p->refcount); `` Are there any other changes should I make? Thanks again.
Please check the file. I have replaced p->refcount
with p->u
. This should solve errors 3, 4. No idea why you are getting the other 2 errors.
Wrapper functions used for sending data from c++ to python and getting back is different for opencv3