2012-07-12 14 views
11

Ich habe vor kurzem OpenCV 2.4.2 in Ubuntu 12.04 installiert.VideoCapture funktioniert nicht in OpenCV 2.4.2

cap = VideoCapture(0) 

funktioniert. aber ich kann keine Frames von einer Videoquelle aufnehmen.

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

gibt mir eine Anzahl mit allen Nullelementen.

ich auch ffmpeg 0,11 Neueste Schnappschuss x264, v4l-0.8.8 installiert haben (Alle sind aktuelle stabile Versionen)

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 

Als ich Cmake tun, bekomme ich diese

- - Erkannte Version von GNU GCC: 46 (406)
- gefunden OpenEXR: /usr/lib/libIlmImf.so
- Looking for linux/videodev.h
- Suche nach linux/videodev.h - nicht gefunden
- Suche nach linux/videodev2.h
- Suche nach linux/videodev2.h - gefunden
- Suche nach libavformat/avformat.h
- Suche nach libavformat/avformat.h - gefunden
- Auf der Suche nach ffmpeg/avformat.h
- Suche nach ffmpeg/avformat.h - nicht
gefunden - Prüfung für Modul 'TBB'
- Paket 'TBB' nicht

gefunden und

-- 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 

ich für videodev.h sah, etc

  • /usr/include/linux/videodev2.h existiert
  • /usr/include/libavformat/avformat.h existiert
  • /usr /local/include/libavformat/avformat.h existiert

Aber ich konnte nicht finden ffmpeg/avformat.h

Was ist das Problem hier?

+1

Ich habe auch ein Problem mit Videocapture, es Abstürze beim Versuch, Video zu öffnen ... –

Antwort

18

Also erkannte ich, dass es ein Problem mit ffmpeg gab. und ich habe ffmpeg neu erstellt und installiert und dann Flags für cmake geändert, um opencv zu machen.

Für 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 

Für OpenCV,

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

Hier ist das komplette Skript OpenCV installieren 2.4.2 https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_2.sh

und hier ist mein Blogpost über OpenCV 2.4.2 Installation im Detail http://jayrambhia.com/blog/install-opencv-2-4-in-ubuntu-12-04-precise-pangolin/

+2

Ich verstehe einfach nicht, wie können sie es so kompliziert machen, sollte dies standardmäßig –

+0

Was wäre, wenn ich alles über apt-get installieren? Glaubst du, ich kann es laufen lassen? –

+0

Ich denke, es könnte ein Lizenzproblem sein, das es auf diese Weise tun muss. – Russj