visual studio 11和windows 7上的opencv_python构建错误

时间:2017-03-27 05:16:13

标签: python visual-studio opencv image-processing cmake

当我使用opencv_contribvisual studio 11从源代码中使用 python支持构建cv2.cpp时,我在1>------ Build started: Project: opencv_python2, Configuration: Release Win32 ------ 1> cv2.cpp 1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0(605): error C2129: static function 'PyObject *pyopencv_from<cv::Matx44d>(const T &)' declared but not defined 1> with 1> [ 1> T=cv::Matx44d 1> ] 1> C:\Users\tofaa\Downloads\Compressed\opencv\sources\opencv-3.2.0\opencv-3.2.0\modules\python\src2\cv2.cpp(207) : see declaration of 'pyopencv_from' ========== Build: 0 succeeded, 1 failed, 101 up-to-date, 0 skipped ========== 中出现了一个错误,我在网上找不到任何帮助

ActivityTestRule

1 个答案:

答案 0 :(得分:0)

This is because pyopencv_cv_ppf_match_3d_ppf_match_3d_ICP_registerModelToScene does not know what to do with 4x4 matrix when it calls pyopencv_from func. You need to add s stub(!) to modules/python/src2/cv2.cpp something like "code" below, until developer add real function. Do not forget that something will go wrong because of this stub. Also this is the answer to all who ignores warning during make: ImportError: dlopen(/OpenCV/StaticLibs/Lib/cv2.so, 2): Symbol not found: _PyCObject_Type or __ZL13pyopencv_fromIN2cv4MatxIdLi4ELi4EEEEP7_objectRKT_ and so on when python import cv2

//your do_not_forget comment here
template<>
PyObject* pyopencv_from(const Matx44d& m) 
{

    Mat temp, *p = (Mat*)&m;
    if(!p->u || p->allocator != &g_numpyAllocator)
    {
        temp.allocator = &g_numpyAllocator;
    }
    PyObject* o = (PyObject*)p->u->userdata;
    Py_INCREF(o);
    return o;
}