2017-01-04 10 views
1

ためOpenCV3.1を構築することはできません私はここでチュートリアルを、以下、OpenCVのとOpenCVのcontribのファイルをダウンロード:http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/は、Python 2.7

私はobj_recogと呼ばれるConda環境でPython2.7用OpenCV3をインストールしたいです。私のOSはUbuntu 16.04です。私は最終的にこれにセトリング、異なるオプションでCMakeのを実行してみました :

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 -D WITH_FFMPEG=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules -D PYTHON_EXECUTABLE=~/anaconda3/envs/obj_recog/bin/python -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D BUILD_EXAMPLES=ON -D WITH_CUBLAS=ON .. 
-- The CXX compiler identification is GNU 5.4.0 
-- The C compiler identification is GNU 5.4.0 
-- Check for working CXX compiler: /usr/bin/c++ 
-- Check for working CXX compiler: /usr/bin/c++ -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Detecting CXX compile features 
-- Detecting CXX compile features - done 
-- Check for working C compiler: /usr/bin/cc 
-- Check for working C compiler: /usr/bin/cc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Detecting C compile features 
-- Detecting C compile features - done 
-- Detected version of GNU GCC: 54 (504) 
-- Performing Test HAVE_CXX_FSIGNED_CHAR 
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success 
-- Performing Test HAVE_C_FSIGNED_CHAR 
-- Performing Test HAVE_C_FSIGNED_CHAR - Success 
-- Performing Test HAVE_CXX_W 
-- Performing Test HAVE_CXX_W - Success 
-- Performing Test HAVE_C_W 
-- Performing Test HAVE_C_W - Success 
-- Performing Test HAVE_CXX_WALL 
-- Performing Test HAVE_CXX_WALL - Success 
-- Performing Test HAVE_C_WALL 
-- Performing Test HAVE_C_WALL - Success 
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE 
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success 
-- Performing Test HAVE_C_WERROR_RETURN_TYPE 
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success 
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR 
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success 
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR 
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success 
-- Performing Test HAVE_CXX_WERROR_ADDRESS 
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success 
-- Performing Test HAVE_C_WERROR_ADDRESS 
-- Performing Test HAVE_C_WERROR_ADDRESS - Success 
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT 
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success 
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT 
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success 
-- Performing Test HAVE_CXX_WFORMAT 
-- Performing Test HAVE_CXX_WFORMAT - Success 
-- Performing Test HAVE_C_WFORMAT 
-- Performing Test HAVE_C_WFORMAT - Success 
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY 
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success 
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY 
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success 
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS 
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success 
-- Performing Test HAVE_C_WMISSING_DECLARATIONS 
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success 
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES 
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed 
-- Performing Test HAVE_C_WMISSING_PROTOTYPES 
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success 
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES 
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed 
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES 
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success 
-- Performing Test HAVE_CXX_WUNDEF 
-- Performing Test HAVE_CXX_WUNDEF - Success 
-- Performing Test HAVE_C_WUNDEF 
-- Performing Test HAVE_C_WUNDEF - Success 
-- Performing Test HAVE_CXX_WINIT_SELF 
-- Performing Test HAVE_CXX_WINIT_SELF - Success 
-- Performing Test HAVE_C_WINIT_SELF 
-- Performing Test HAVE_C_WINIT_SELF - Success 
-- Performing Test HAVE_CXX_WPOINTER_ARITH 
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success 
-- Performing Test HAVE_C_WPOINTER_ARITH 
-- Performing Test HAVE_C_WPOINTER_ARITH - Success 
-- Performing Test HAVE_CXX_WSHADOW 
-- Performing Test HAVE_CXX_WSHADOW - Success 
-- Performing Test HAVE_C_WSHADOW 
-- Performing Test HAVE_C_WSHADOW - Success 
-- Performing Test HAVE_CXX_WSIGN_PROMO 
-- Performing Test HAVE_CXX_WSIGN_PROMO - Success 
-- Performing Test HAVE_C_WSIGN_PROMO 
-- Performing Test HAVE_C_WSIGN_PROMO - Failed 
-- Performing Test HAVE_CXX_WNO_NARROWING 
-- Performing Test HAVE_CXX_WNO_NARROWING - Success 
-- Performing Test HAVE_C_WNO_NARROWING 
-- Performing Test HAVE_C_WNO_NARROWING - Success 
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR 
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success 
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR 
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed 
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS 
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed 
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS 
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed 
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION 
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success 
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION 
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success 
-- Performing Test HAVE_CXX_WNO_LONG_LONG 
-- Performing Test HAVE_CXX_WNO_LONG_LONG - Success 
-- Performing Test HAVE_C_WNO_LONG_LONG 
-- Performing Test HAVE_C_WNO_LONG_LONG - Success 
-- Performing Test HAVE_CXX_PTHREAD 
-- Performing Test HAVE_CXX_PTHREAD - Success 
-- Performing Test HAVE_C_PTHREAD 
-- Performing Test HAVE_C_PTHREAD - Success 
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER 
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER - Success 
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER 
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER - Success 
-- Performing Test HAVE_CXX_MSSE 
-- Performing Test HAVE_CXX_MSSE - Success 
-- Performing Test HAVE_C_MSSE 
-- Performing Test HAVE_C_MSSE - Success 
-- Performing Test HAVE_CXX_MSSE2 
-- Performing Test HAVE_CXX_MSSE2 - Success 
-- Performing Test HAVE_C_MSSE2 
-- Performing Test HAVE_C_MSSE2 - Success 
-- Performing Test HAVE_CXX_MNO_AVX 
-- Performing Test HAVE_CXX_MNO_AVX - Success 
-- Performing Test HAVE_C_MNO_AVX 
-- Performing Test HAVE_C_MNO_AVX - Success 
-- Performing Test HAVE_CXX_MSSE3 
-- Performing Test HAVE_CXX_MSSE3 - Success 
-- Performing Test HAVE_C_MSSE3 
-- Performing Test HAVE_C_MSSE3 - Success 
-- Performing Test HAVE_CXX_MNO_SSSE3 
-- Performing Test HAVE_CXX_MNO_SSSE3 - Success 
-- Performing Test HAVE_C_MNO_SSSE3 
-- Performing Test HAVE_C_MNO_SSSE3 - Success 
-- Performing Test HAVE_CXX_MNO_SSE4_1 
-- Performing Test HAVE_CXX_MNO_SSE4_1 - Success 
-- Performing Test HAVE_C_MNO_SSE4_1 
-- Performing Test HAVE_C_MNO_SSE4_1 - Success 
-- Performing Test HAVE_CXX_MNO_SSE4_2 
-- Performing Test HAVE_CXX_MNO_SSE4_2 - Success 
-- Performing Test HAVE_C_MNO_SSE4_2 
-- Performing Test HAVE_C_MNO_SSE4_2 - Success 
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS 
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS - Success 
-- Performing Test HAVE_C_FFUNCTION_SECTIONS 
-- Performing Test HAVE_C_FFUNCTION_SECTIONS - Success 
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN 
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN - Success 
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN 
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN - Success 
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN 
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN - Success 
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN 
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed 
-- Looking for pthread.h 
-- Looking for pthread.h - found 
-- Check if the system is big endian 
-- Searching 16 bit integer 
-- Looking for sys/types.h 
-- Looking for sys/types.h - found 
-- Looking for stdint.h 
-- Looking for stdint.h - found 
-- Looking for stddef.h 
-- Looking for stddef.h - found 
-- Check size of unsigned short 
-- Check size of unsigned short - done 
-- Using unsigned short 
-- Check if the system is big endian - little endian 
-- Found ZLIB: /home/geoff/anaconda3/envs/obj_recog/lib/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
-- Found TIFF: /home/geoff/anaconda3/envs/obj_recog/lib/libtiff.so (found version "4.0.6") 
-- Found JPEG: /home/geoff/anaconda3/envs/obj_recog/lib/libjpeg.so 
-- Found WebP: /usr/lib/x86_64-linux-gnu/libwebp.so 
-- Found Jasper: /usr/lib/x86_64-linux-gnu/libjasper.so (found version "1.900.1") 
-- Found ZLIB: /home/geoff/anaconda3/envs/obj_recog/lib/libz.so (found version "1.2.8") 
-- Found PNG: /home/geoff/anaconda3/envs/obj_recog/lib/libpng.so (found version "1.6.22") 
-- Looking for /home/geoff/anaconda3/envs/obj_recog/include/libpng/png.h 
-- Looking for /home/geoff/anaconda3/envs/obj_recog/include/libpng/png.h - not found 
-- Looking for semaphore.h 
-- Looking for semaphore.h - found 
-- Performing Test HAVE_CXX_WNO_SHADOW 
-- Performing Test HAVE_CXX_WNO_SHADOW - Success 
-- Performing Test HAVE_CXX_WNO_UNUSED 
-- Performing Test HAVE_CXX_WNO_UNUSED - Success 
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE 
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE - Success 
-- Performing Test HAVE_CXX_WNO_UNDEF 
-- Performing Test HAVE_CXX_WNO_UNDEF - Success 
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS 
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Success 
-- Performing Test HAVE_CXX_WNO_UNINITIALIZED 
-- Performing Test HAVE_CXX_WNO_UNINITIALIZED - Success 
-- Performing Test HAVE_CXX_WNO_SWITCH 
-- Performing Test HAVE_CXX_WNO_SWITCH - Success 
-- Performing Test HAVE_CXX_WNO_PARENTHESES 
-- Performing Test HAVE_CXX_WNO_PARENTHESES - Success 
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS 
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS - Success 
-- Performing Test HAVE_CXX_WNO_EXTRA 
-- Performing Test HAVE_CXX_WNO_EXTRA - Success 
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS 
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success 
-- Checking for module 'gstreamer-base-1.0' 
-- No package 'gstreamer-base-1.0' found 
-- Checking for module 'gstreamer-video-1.0' 
-- No package 'gstreamer-video-1.0' found 
-- Checking for module 'gstreamer-app-1.0' 
-- No package 'gstreamer-app-1.0' found 
-- Checking for module 'gstreamer-riff-1.0' 
-- No package 'gstreamer-riff-1.0' found 
-- Checking for module 'gstreamer-pbutils-1.0' 
-- No package 'gstreamer-pbutils-1.0' found 
-- Checking for module 'gstreamer-base-0.10' 
-- No package 'gstreamer-base-0.10' found 
-- Checking for module 'gstreamer-video-0.10' 
-- No package 'gstreamer-video-0.10' found 
-- Checking for module 'gstreamer-app-0.10' 
-- No package 'gstreamer-app-0.10' found 
-- Checking for module 'gstreamer-riff-0.10' 
-- No package 'gstreamer-riff-0.10' found 
-- Checking for module 'gstreamer-pbutils-0.10' 
-- No package 'gstreamer-pbutils-0.10' found 
-- Checking for module 'libdc1394-2' 
-- Found libdc1394-2, version 2.2.4 
-- Checking for module 'libv4l1' 
-- Found libv4l1, version 1.10.0 
-- Checking for module 'libv4l2' 
-- Found libv4l2, version 1.10.0 
-- Looking for linux/videodev.h 
-- Looking for linux/videodev.h - not found 
-- Looking for linux/videodev2.h 
-- Looking for linux/videodev2.h - found 
-- Looking for sys/videoio.h 
-- Looking for sys/videoio.h - not found 
-- Checking for module 'libavcodec' 
-- Found libavcodec, version 57.64.101 
-- Checking for module 'libavformat' 
-- Found libavformat, version 57.56.100 
-- Checking for module 'libavutil' 
-- Found libavutil, version 55.34.100 
-- Checking for module 'libswscale' 
-- Found libswscale, version 4.2.100 
-- Checking for module 'libavresample' 
-- No package 'libavresample' found 
-- Looking for libavformat/avformat.h 
-- Looking for libavformat/avformat.h - found 
-- Looking for ffmpeg/avformat.h 
-- Looking for ffmpeg/avformat.h - not found 
-- Checking for module 'libgphoto2' 
-- No package 'libgphoto2' found 
-- Checking for module 'tbb' 
-- Found tbb, version 4.4~20151115 
-- ICV: Removing previous unpacked package: /home/geoff/opencv-3.1.0/3rdparty/ippicv/unpack 
-- ICV: Unpacking ippicv_linux_20151201.tgz to /home/geoff/opencv-3.1.0/3rdparty/ippicv/unpack... 
-- ICV: Package successfully downloaded 
-- found IPP (ICV version): 9.0.1 [9.0.1] 
-- at: /home/geoff/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx 
-- CUDA detected: 8.0 
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30 
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake 
-- Found PythonInterp: /home/geoff/anaconda3/envs/obj_recog/bin/python (found suitable version "2.7.12", minimum required is "2.7") 

私はチュートリアルのようmake j-4を実行すると、メイク休憩その後:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \ 
-D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON \ 
-D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON \ 
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 -D WITH_FFMPEG=ON \ 
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \ 
-D PYTHON_EXECUTABLE=~/anaconda3/envs/obj_recog/bin/python \ 
-D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF \ 
-D BUILD_EXAMPLES=ON -D WITH_CUBLAS=ON .. 

ここでは、私が手に出力されます約40%。

私もconda install opencvを使用してインストールしてみましたが、その後、私は.avi動画や画像を読み取ることができない、次のエラーを取得:

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /root/mc-x64-2.7/conda-bld/opencv-3_1482256854890/work/opencv-3.1.0/modules/highgui/src/window.cpp, line 545 
Traceback (most recent call last): 
File "find_game.py", line 24, in <module> 
    cv2.imshow("Image", image) 
cv2.error: /root/mc-x64-2.7/conda-bld/opencv-3_1482256854890/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage 

私がチェックしlibgtk2-0-devが正しくインストールされています。

OpenCVを手作業でビルドする前に、ffmpegとgstreamerもコンパイルして再インストールしました。 make中に

、私はこのエラーを取得する:

//usr/lib/x86_64-linux-gnu/libsoxr.so.0: undefined reference to `[email protected]_4.0' 
collect2: error: ld returned 1 exit status 
samples/opengl/CMakeFiles/example_opengl_opengl_interop.dir/build.make:107: recipe for target 'bin/opengl-example-opengl_interop' failed 
make[2]: *** [bin/opengl-example-opengl_interop] Error 1 
CMakeFiles/Makefile2:31556: recipe for target 'samples/opengl/CMakeFiles/example_opengl_opengl_interop.dir/all' failed 
make[1]: *** [samples/opengl/CMakeFiles/example_opengl_opengl_interop.dir/all] Error 2 

任意の助けいただければ幸いです!

答えて

0

https://realpython.com/blog/python/face-detection-in-python-using-a-webcam/

あなたは、このリンクをたどって、あなたはsudoのパイソンを入力して、このコードに

git clone https://github.com/shantnu/Webcam-Face-Detect.git 
cd cd Webcam-Face-Detect/ 
sudo python webcam_cv3.py haarcascade_frontalface_default.xml 

を実行してみることができる場合だけ実行してみてくださいpython.So使用しているとき、私はエラーを得ていた、私のためのトリックを行いましたsudoを使って

+0

しかし、それはconda/virtual envを使用しません。システムのpythonバージョンでのみ動作します。 – geoffn91

0

このエラーは、libgtk2.0-devおよびpkg-configとは関係ありません。おそらくどちらもインストールされていますが、makeを実行しようとするたびに同じエラーが表示されます。

これは、さまざまなソース(opencv-python、公式のPythonなど)からopencvをインストールしようとしたときによく発生します。 opencv関連のパッケージをすべてアンインストールしてください(特に公式パッケージではない場合)。そして、やり直してください。私はubuntuを一度再インストールしなければならなかった。

pyimagesearchからの指示がうまくいきます。