Building OpenCV_Python on Mac OS X 10.9 Using Homebrew

I am trying to upgrade OpenCV from version 2.4.5 to version 2.4.6.1 using homebrew. When I run brew upgrade opencv
I encountered the following error:

 ==> Upgrading opencv dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid ==> Downloading http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.6.1/opencv-2.4 Already downloaded: /Library/Caches/Homebrew/opencv-2.4.6.1.tar.gz ==> cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2.4.6.1 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIN ==> make /usr/local/Library/ENV/4.3/c++ -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -dynamiclib -Wl,-headerpad_max_install_names -o ../../lib/libopencv_java246.dylib -install_name /tmp/-5W3i/opencv-2.4.6.1/macbuild/lib/libopencv_java246.dylib CMakeFiles/opencv_java.dir/generator/src/cpp/converters.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/core_manual.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/jni_part.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/Mat.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/utils.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/VideoCapture.cpp.o CMakeFiles/opencv_java.dir/core.cpp.o CMakeFiles/opencv_java.dir/imgproc.cpp.o CMakeFiles/opencv_java.dir/objdetect.cpp.o CMakeFiles/opencv_java.dir/features2d.cpp.o CMakeFiles/opencv_java.dir/video.cpp.o CMakeFiles/opencv_java.dir/highgui.cpp.o CMakeFiles/opencv_java.dir/ml.cpp.o CMakeFiles/opencv_java.dir/calib3d.cpp.o CMakeFiles/opencv_java.dir/photo.cpp.o CMakeFiles/opencv_java.dir/contrib.cpp.o -L/usr/local/include/../lib ../../lib/libopencv_core.2.4.6.dylib ../../lib/libopencv_imgproc.2.4.6.dylib ../../lib/libopencv_highgui.2.4.6.dylib ../../lib/libopencv_objdetect.2.4.6.dylib ../../lib/libopencv_flann.2.4.6.dylib ../../lib/libopencv_features2d.2.4.6.dylib ../../lib/libopencv_video.2.4.6.dylib ../../lib/libopencv_ml.2.4.6.dylib ../../lib/libopencv_calib3d.2.4.6.dylib ../../lib/libopencv_photo.2.4.6.dylib ../../lib/libopencv_legacy.2.4.6.dylib ../../lib/libopencv_gpu.2.4.6.dylib ../../lib/libopencv_ocl.2.4.6.dylib ../../lib/libopencv_nonfree.2.4.6.dylib ../../lib/libopencv_contrib.2.4.6.dylib -ltbb ../../lib/libopencv_gpu.2.4.6.dylib ../../lib/libopencv_photo.2.4.6.dylib ../../lib/libopencv_legacy.2.4.6.dylib ../../lib/libopencv_ocl.2.4.6.dylib ../../lib/libopencv_objdetect.2.4.6.dylib ../../lib/libopencv_video.2.4.6.dylib ../../lib/libopencv_ml.2.4.6.dylib ../../lib/libopencv_calib3d.2.4.6.dylib ../../lib/libopencv_features2d.2.4.6.dylib ../../lib/libopencv_highgui.2.4.6.dylib ../../lib/libopencv_imgproc.2.4.6.dylib ../../lib/libopencv_flann.2.4.6.dylib ../../lib/libopencv_core.2.4.6.dylib /usr/lib/libz.dylib -ltbb -framework OpenCL brew: superenv removed: -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -L/usr/local/include/../lib usr/local/Cellar/cmake/2.8.11.2/bin/cmake -E cmake_progress_report /tmp/-5W3i/opencv-2.4.6.1/macbuild/CMakeFiles 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 [100%] Built target opencv_java make: *** [all] Error 2 

It doesn't seem to work when creating OpenCV Python bindings. I have Java version 1.7.0_45-b18 installed on my Mac, and Python 2.7.5 is installed on the system along with Numpy 1.7.1. I was wondering what would happen to this question.

Further debugging shows that the problem occurs when creating OpenCV_Python, and this is an error in which the build stops:

 [ 85%] Building CXX object modules/python/CMakeFiles/opencv_python.dir/src2/cv2.cpp.o cd /tmp/opencv-fc49/opencv-2.4.6.1/macbuild/modules/python && /usr/local/Library/ENV/4.3/c++ -DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_CVCONFIG_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H -DPYTHON_USE_NUMPY=1 -Dopencv_python_EXPORTS -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -Wno-unused-function -fPIC -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2 -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/nonfree/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/ocl/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/gpu/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/legacy/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/contrib/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/objdetect/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/photo/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/calib3d/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/features2d/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/highgui/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/ml/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/video/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/imgproc/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/flann/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/core/include -I/tmp/opencv-fc49/opencv-2.4.6.1/macbuild/modules/python -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/include -I/tmp/opencv-fc49/opencv-2.4.6.1/macbuild -isystem /usr/local/include -isystem /usr/local/include/eigen3 -isystem /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Headers -isystem /usr/local/lib/python2.7/site-packages/numpy/core/include -o CMakeFiles/opencv_python.dir/src2/cv2.cpp.o -c /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:227:9: error: no matching function for call to 'PyInt_Check' if( PyInt_Check(o) ) ^~~~~~~~~~~ /usr/local/include/pypy_decl.h:171:17: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier PyAPI_FUNC(int) PyInt_Check(PyObject *arg0); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:233:9: error: no matching function for call to 'PyFloat_Check' if( PyFloat_Check(o) ) ^~~~~~~~~~~~~ /usr/local/include/pypy_decl.h:142:17: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier PyAPI_FUNC(int) PyFloat_Check(PyObject *arg0); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:239:9: error: no matching function for call to 'PyTuple_Check' if( PyTuple_Check(o) ) ^~~~~~~~~~~~~ /usr/local/include/pypy_decl.h:397:17: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier PyAPI_FUNC(int) PyTuple_Check(PyObject *arg0); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:245:28: error: no matching function for call to 'PyTuple_GetItem' PyObject* oi = PyTuple_GET_ITEM(o, i); ^~~~~~~~~~~~~~~~ /usr/local/include/tupleobject.h:14:26: note: expanded from macro 'PyTuple_GET_ITEM' #define PyTuple_GET_ITEM PyTuple_GetItem ^~~~~~~~~~~~~~~ /usr/local/include/pypy_decl.h:400:24: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *arg0, Py_ssize_t arg1); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:702:28: error: use of undeclared identifier 'PySequence_Fast_ITEMS'; did you mean 'PySequence_Fast_GET_SIZE'? PyObject** items = PySequence_Fast_ITEMS(seq); ^~~~~~~~~~~~~~~~~~~~~ PySequence_Fast_GET_SIZE /usr/local/include/pypy_decl.h:339:24: note: 'PySequence_Fast_GET_SIZE' declared here PyAPI_FUNC(Py_ssize_t) PySequence_Fast_GET_SIZE(PyObject *arg0); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:702:20: error: cannot initialize a variable of type 'PyObject **' (aka '_object **') with an rvalue of type 'Py_ssize_t' (aka 'long') PyObject** items = PySequence_Fast_ITEMS(seq); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:741:27: error: use of undeclared identifier 'PySequence_Fast_ITEMS'; did you mean 'PySequence_Fast_GET_SIZE'? items_i = PySequence_Fast_ITEMS(seq_i); ^~~~~~~~~~~~~~~~~~~~~ PySequence_Fast_GET_SIZE /usr/local/include/pypy_decl.h:339:24: note: 'PySequence_Fast_GET_SIZE' declared here PyAPI_FUNC(Py_ssize_t) PySequence_Fast_GET_SIZE(PyObject *arg0); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:741:25: error: assigning to 'PyObject **' (aka '_object **') from incompatible type 'Py_ssize_t' (aka 'long') items_i = PySequence_Fast_ITEMS(seq_i); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:814:24: error: use of undeclared identifier 'PySequence_Fast_ITEMS'; did you mean 'PySequence_Fast_GET_SIZE'? PyObject** items = PySequence_Fast_ITEMS(seq); ^~~~~~~~~~~~~~~~~~~~~ PySequence_Fast_GET_SIZE /usr/local/include/pypy_decl.h:339:24: note: 'PySequence_Fast_GET_SIZE' declared here PyAPI_FUNC(Py_ssize_t) PySequence_Fast_GET_SIZE(PyObject *arg0); ^ /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:814:16: error: cannot initialize a variable of type 'PyObject **' (aka '_object **') with an rvalue of type 'Py_ssize_t' (aka 'long') PyObject** items = PySequence_Fast_ITEMS(seq); 

Can anyone help in creating OpenCV?

+6
source share
1 answer

Perhaps you get compiler errors in Py * functions because it cannot find what python includes in its search directories.

I would not rely on building python and recommend installing a different version through python. Both python assemblies can coexist on the same machine, but you'd better rely on installing brew. You can verify this by checking that "which python" points to / usr / local / bin / python or from the version when the python interpreter is started. GilberLee's comment points out some good steps to install this: Installing openCV 2.4.2 on Mac OS X 10.9 (Mavericks)

After installing python view homebrew, try reinstalling opencv and see if they failed these compilation errors.

0
source

Source: https://habr.com/ru/post/956174/


All Articles