2017-08-09 48 views
1

我一直試圖從源代碼安裝opencv而不是pip,因爲我無法成功讀取VideoCapture。opencv - cmake錯誤:在Ubuntu上沒有這樣的文件或目錄

安裝opencv-3.2.0 on Ubuntu 16.04.3 LTS。跟着提到的細節here

我得到以下錯誤在 「.../OpenCV的-3.2.0 /編譯/ CMakeFiles/CMakeError.log」:

.../opencv-3.2.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory 


.../opencv-3.2.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory 

libv4l-dev的已經是最新的版本(1.10。 0-1)

我也爲在/ usr /在include/linux運行以下命令:

sudo ln -s ../libv4l1-videodev.h videodev.h 

中國氣象局柯輸出是:

-- General configuration for OpenCV 3.2.0 ===================================== 
-- Version control:    unknown 
-- 
-- Platform: 
--  Timestamp:     2017-08-09T05:39:43Z 
--  Host:      Linux 4.4.0-87-generic x86_64 
--  CMake:      3.5.1 
--  CMake generator:    Unix Makefiles 
--  CMake build tool:   /usr/bin/make 
--  Configuration:    RELEASE 
-- 
-- C/C++: 
--  Built as dynamic libs?:  YES 
--  C++ Compiler:    /usr/bin/c++ (ver 5.4.0) 
--  C++ flags (Release):   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG 
--  C++ flags (Debug):   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG 
--  C Compiler:     /usr/bin/cc 
--  C flags (Release):   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG 
--  C flags (Debug):    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG 
--  Linker flags (Release): 
--  Linker flags (Debug): 
--  ccache:      NO 
--  Precompiled headers:   YES 
--  Extra dependencies:   /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libtiff.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libjpeg.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 gobject-2.0 glib-2.0 fontconfig freetype gthread-2.0 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg dl m pthread rt 
--  3rdparty dependencies:  libwebp IlmImf 
-- 
-- OpenCV modules: 
--  To be built:     core flann imgproc ml photo video imgcodecs shape videoio highgui objdetect superres ts features2d calib3d stitching videostab python2 python3 
--  Disabled:     world 
--  Disabled by dependency:  - 
--  Unavailable:     cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java viz 
-- 
-- GUI: 
--  QT:       NO 
--  GTK+ 2.x:     YES (ver 2.24.30) 
--  GThread :     YES (ver 2.48.2) 
--  GtkGlExt:     NO 
--  OpenGL support:    NO 
--  VTK support:     NO 
-- 
-- Media I/O: 
--  ZLib:      /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8) 
--  JPEG:      /usr/lib/x86_64-linux-gnu/libjpeg.so (ver) 
--  WEBP:      build (ver 0.3.1) 
--  PNG:       /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54) 
--  TIFF:      /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6) 
--  JPEG 2000:     /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1) 
--  OpenEXR:      build (ver 1.7.1) 
--  GDAL:      NO 
--  GDCM:      NO 
-- 
-- Video I/O: 
--  DC1394 1.x:     NO 
--  DC1394 2.x:     NO 
--  FFMPEG:      YES 
--  avcodec:     YES (ver 56.60.100) 
--  avformat:     YES (ver 56.40.101) 
--  avutil:     YES (ver 54.31.100) 
--  swscale:     YES (ver 3.1.101) 
--  avresample:    NO 
--  GStreamer:     NO 
--  OpenNI:      NO 
--  OpenNI PrimeSensor Modules: NO 
--  OpenNI2:      NO 
--  PvAPI:      NO 
--  GigEVisionSDK:    NO 
--  Aravis SDK:     NO 
--  UniCap:      NO 
--  UniCap ucil:     NO 
--  V4L/V4L2:     YES/YES 
--  XIMEA:      NO 
--  Xine:      NO 
--  gPhoto2:      NO 
-- 
-- Parallel framework:   pthreads 
-- 
-- Other third-party libraries: 
--  Use IPP:      9.0.1 [9.0.1] 
--   at:      /root/twix/tensorflow/opencv-3.2.0/build/3rdparty/ippicv/ippicv_lnx 
--  Use IPP Async:    NO 
--  Use VA:      NO 
--  Use Intel VA-API/OpenCL:  NO 
--  Use Lapack:     NO 
--  Use Eigen:     NO 
--  Use Cuda:     NO 
--  Use OpenCL:     YES 
--  Use OpenVX:     NO 
--  Use custom HAL:    NO 
-- 
-- OpenCL:      <Dynamic loading of OpenCL library> 
--  Include path:    /root/twix/tensorflow/opencv-3.2.0/3rdparty/include/opencl/1.2 
--  Use AMDFFT:     NO 
--  Use AMDBLAS:     NO 
-- 
-- Python 2: 
--  Interpreter:     /usr/bin/python2.7 (ver 2.7.12) 
--  Libraries:     /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12) 
--  numpy:      /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0) 
--  packages path:    lib/python2.7/dist-packages 
-- 
-- Python 3: 
--  Interpreter:     /usr/bin/python3 (ver 3.5.2) 
--  Libraries:     /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2) 
--  numpy:      /usr/lib/python3/dist-packages/numpy/core/include (ver 1.11.0) 
--  packages path:    lib/python3.5/dist-packages 
-- 
-- Python (for build):   /usr/bin/python2.7 
-- 
-- Java: 
--  ant:       NO 
--  JNI:       /usr/lib/jvm/java-8-oracle/include /usr/lib/jvm/java-8-oracle/include/linux /usr/lib/jvm/java-8-oracle/include 
--  Java wrappers:    NO 
--  Java tests:     NO 
-- 
-- Matlab:      Matlab not found or implicitly disabled 
-- 
-- Documentation: 
--  Doxygen:      NO 
-- 
-- Tests and samples: 
--  Tests:      YES 
--  Performance tests:   YES 
--  C/C++ Examples:    YES 
-- 
-- Install path:     /usr/local 
-- 
-- cvconfig.h is in:    /root/twix/tensorflow/opencv-3.2.0/build 
-- 
-- Configuring incomplete, errors occurred! 
+0

做'cmake'命令或'make'命令會產生你提到的錯誤嗎?還有,你是否確認文件'/ usr/include/linux/videodev.h'(創建符號鏈接後)是否存在? – BNT

+0

@BNT這是'cmake'命令。是的,我可以看到已經創建了'/ usr/include/linux/videodev.h'。 – Twix

回答

0

回想起來這似乎很傻,但cmake命令有一個-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \的路徑選項。此路徑在我的系統上不正確。我把它改成了正確的路徑,它工作。感謝所有的幫助傢伙!

+0

這意味着你正在按照我的答案中提到的步驟 – Kallz

0

對於你的問題,你有以下命令

sudo apt-get install libv4l-dev 

對Ubuntu的安裝OpenCV跑,我總是遵循一些步驟永遠奏效。

我安裝OpenCV與opencv_contrib(對於OpenCV的一些額外的模塊)

打開終端並運行下面的命令

要安裝OpenCV依賴性

sudo apt-get install build-essential 

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev 

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 

sudo apt-get install libxvidcore-dev libx264-dev 

要安裝OpenCV

  1. cd/opt/

  2. 須藤GIT中克隆https://github.com/opencv/opencv.git

  3. 須藤GIT中克隆https://github.com/opencv/opencv_contrib.git

  4. CD的OpenCV

  5. 須藤MKDIR釋放

  6. CD發行

  7. 須藤cmake的-D CMAKE_INSTALL_PREFIX =/usr/local -D INSTALL_C_EXAM PLES = ON -D INSTALL_PYTHON_EXAMPLES = ON -D OPENCV_EXTRA_MODULES_PATH = /選擇/ opencv_contrib /模塊-D WITH_LIBV4L = ON -D WITH_V4L = OFF -D BUILD_EXAMPLES = ON /選擇/的OpenCV/

  8. 須藤使

  9. 須藤使安裝

  10. pkg配置--modversion OpenCV的#檢查版本安裝

如果你不想安裝opencv_contrib可以跳過第三步,改變7步

sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D 
CMAKE_INSTALL_PREFIX=/usr/local -D /opt/opencv/ 
+0

我已經安裝了所有這些依賴關係。請檢查我分享的鏈接。這幾乎與你提到的一樣。這並不能解決我的問題。 – Twix

+0

@Twix使用openc_contrib安裝opencv,我也更新第7步命令,請檢查 – Kallz

+0

是的,我使用openc_contrib進行安裝。你所說的和[this](https://github.com/kratzert/Ubuntu_from_scratch/blob/master/Ubuntu_16_04LTS.md#installing-opencv3)之間唯一的區別在於,使用INSTALL_C_EXAMPLES設置爲ON。試過了。沒有工作。 – Twix

相關問題