2012-07-12 43 views
11

我最近在Ubuntu 12.04中安裝了OpenCV 2.4.2。VideoCapture無法在OpenCV 2.4.2中工作

cap = VideoCapture(0) 

正在工作。但我無法從某些視頻源抓取幀。

cap = VideoCapture("input.avi") 
img = cap.read() 

給我一個所有零元素的numpy。

我還安裝了ffmpeg的0.11,X264,爲v41-0.8.8(全部是最新的穩定版本)的最新快照

cmake -D WITH_QT=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=OFF WITH_V4L=ON .. 
make 
sudo make install 

當我做cmake的,我得到這個

- - 檢測到的GNU GCC的版本:46(406)
- 實測值的OpenEXR:/usr/lib/libIlmImf.so
- 尋找LINUX/videodev.h
- 尋找LINUX/videodev.h - 不發現
- 尋找LINUX/videodev2.h
- 尋找LINUX/videodev2.h - 發現
- 尋找了libavformat/avformat.h
- 尋找了libavformat/avformat.h - 發現
- 尋找的ffmpeg/avformat.h
- 尋找的ffmpeg/avformat.h - 沒有找到
- 檢查模塊 'TBB'
- 包 'TBB' 未找到

而且

-- Video I/O: 
--  DC1394 1.x:     NO 
--  DC1394 2.x:     YES (ver 2.2.0) 
--  FFMPEG:      YES 
--  codec:      YES (ver 54.23.100) 
--  format:     YES (ver 54.6.100) 
--  util:      YES (ver 51.54.100) 
--  swscale:     YES (ver 2.1.100) 
--  gentoo-style:    YES 
--  GStreamer:     
--  base:      YES (ver 0.10.36) 
--  app:      YES (ver 0.10.36) 
--  video:      YES (ver 0.10.36) 
--  OpenNI:      NO 
--  OpenNI PrimeSensor Modules: NO 
--  PvAPI:      NO 
--  UniCap:      NO 
--  UniCap ucil:     NO 
--  V4L/V4L2:     Using libv4l (ver 0.8.8) 
--  XIMEA:      NO 
--  Xine:      NO 

我看了videodev.h等

  • /usr/include/linux/videodev2.h存在
  • /usr/include/libavformat/avformat.h存在
  • 的/ usr /local/include/libavformat/avformat.h存在

但我找不到ffmpeg/avformat.h

這裏有什麼問題?

+1

我也有videoCapture一個問題,當試圖打開視頻時崩潰... – 2012-09-06 15:02:56

回答

18

所以,我意識到ffmpeg有一些問題。我重建並安裝了ffmpeg,然後更改了cmake的標誌以使opencv成爲可能。

對於ffmpeg的,

./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab 
make 
sudo make install 

對於OpenCV的,

cmake -D CMAKE_BUILD_TYPE=RELEASE .. 
make 
sudo make install 

下面是完整的腳本安裝OpenCV 2.4.2 https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_2.sh

,這裏是我的約2.4 OpenCV的博客帖子。2安裝詳細http://jayrambhia.com/blog/install-opencv-2-4-in-ubuntu-12-04-precise-pangolin/

+2

我根本不明白他們如何使它變得如此複雜,這應該是默認的 – 2012-09-06 15:03:42

+0

如果我通過apt-get安裝所有東西,該怎麼辦?你認爲我可以運行嗎? – 2014-11-07 16:06:28

+0

我想這可能是一些許可證問題,必須這樣做。 – Russj 2014-12-05 03:13:25