web-dev-qa-db-fra.com

Comment installer opencv dans Ubuntu 12.04 et l'exécuter avec Python?

Je voudrais faire le traitement d'image sur framboise-pi.

Pour cela, je veux d’abord le faire sous Ubuntu.

Quand je lance la commande Sudo apt-get install libopencv-dev. J'ai la sortie suivante:

naveen@ubuntu:~$ Sudo apt-get install libopencv-dev

[Sudo] password for naveen: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 gir1.2-ubuntuoneui-3.0 firefox-locale-en language-pack-kde-en cabextract
 kde-l10n-engb libjpeg62 libubuntuoneui-3.0-1 Thunderbird-globalmenu
 language-pack-en-base language-pack-kde-en-base language-pack-en
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
 debhelper dh-apparmor gettext html2text intltool-debian libatk1.0-dev
 libavcodec-dev libavformat-dev libavutil-dev libcairo-script-interpreter2
 libcairo2-dev libdc1394-22-dev libexpat1-dev libfontconfig1-dev
 libfreetype6-dev libgdk-pixbuf2.0-dev libgettextpo0 libglib2.0-dev
 libgtk2.0-dev libice-dev libilmbase-dev libmail-sendmail-Perl
 libopencv-calib3d-dev libopencv-calib3d2.3 libopencv-contrib-dev
 libopencv-contrib2.3 libopencv-core-dev libopencv-core2.3
 libopencv-features2d-dev libopencv-features2d2.3 libopencv-flann-dev
 libopencv-flann2.3 libopencv-gpu-dev libopencv-gpu2.3 libopencv-highgui-dev
 libopencv-highgui2.3 libopencv-imgproc-dev libopencv-imgproc2.3
 libopencv-legacy-dev libopencv-legacy2.3 libopencv-ml-dev libopencv-ml2.3
 libopencv-objdetect-dev libopencv-objdetect2.3 libopencv-video-dev
 libopencv-video2.3 libopenexr-dev libpango1.0-dev libpcre3-dev libpcrecpp0
 libpixman-1-dev libpng12-dev libpthread-stubs0 libpthread-stubs0-dev
 libraw1394-dev libsm-dev libswscale-dev libsys-hostname-long-Perl
 libunistring0 libx11-dev libx11-doc libxau-dev libxcb-render0-dev
 libxcb-shm0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev
 libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev
 libxrandr-dev libxrender-dev po-debconf x11proto-composite-dev
 x11proto-core-dev x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev
 x11proto-kb-dev x11proto-randr-dev x11proto-render-dev x11proto-xext-dev
 x11proto-xinerama-dev xorg-sgml-doctools xtrans-dev
 Suggested packages:
  dh-make gettext-doc libfaad-dev libgsm1-dev libogg-dev libschroedinger-dev
  libspeex-dev libtheora-dev libvorbis-dev libcairo2-doc libglib2.0-doc
  libgtk2.0-doc libpango1.0-doc libraw1394-doc libxcb-doc libmail-box-Perl
 Recommended packages:
   libraw1394-tools
 The following NEW packages will be installed:
   debhelper dh-apparmor gettext html2text intltool-debian libatk1.0-dev
   libavcodec-dev libavformat-dev libavutil-dev libcairo-script-interpreter2
   libcairo2-dev libdc1394-22-dev libexpat1-dev libfontconfig1-dev
   libfreetype6-dev libgdk-pixbuf2.0-dev libgettextpo0 libglib2.0-dev
   libgtk2.0-dev libice-dev libilmbase-dev libmail-sendmail-Perl
   libopencv-calib3d-dev libopencv-calib3d2.3 libopencv-contrib-dev
   libopencv-contrib2.3 libopencv-core-dev libopencv-core2.3 libopencv-dev
   libopencv-features2d-dev libopencv-features2d2.3 libopencv-flann-dev
   libopencv-flann2.3 libopencv-gpu-dev libopencv-gpu2.3 libopencv-highgui-dev
   libopencv-highgui2.3 libopencv-imgproc-dev libopencv-imgproc2.3
   libopencv-legacy-dev libopencv-legacy2.3 libopencv-ml-dev libopencv-ml2.3
   libopencv-objdetect-dev libopencv-objdetect2.3 libopencv-video-dev
   libopencv-video2.3 libopenexr-dev libpango1.0-dev libpcre3-dev libpcrecpp0
   libpixman-1-dev libpng12-dev libpthread-stubs0 libpthread-stubs0-dev
   libraw1394-dev libsm-dev libswscale-dev libsys-hostname-long-Perl
   libunistring0 libx11-dev libx11-doc libxau-dev libxcb-render0-dev
   libxcb-shm0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev
   libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev
   libxrandr-dev libxrender-dev po-debconf x11proto-composite-dev
   x11proto-core-dev x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev
   x11proto-kb-dev x11proto-randr-dev x11proto-render-dev x11proto-xext-dev
   x11proto-xinerama-dev xorg-sgml-doctools xtrans-dev
   0 upgraded, 90 newly installed, 0 to remove and 0 not upgraded.
   Need to get 300 kB/32.4 MB of archives.
   After this operation, 135 MB of additional disk space will be used.
 Do you want to continue [Y/n]? y
   Err http://archive.ubuntu.com/ubuntu/ precise-updates/main x11proto-core-dev all 7.0.22-1ubuntu0.1
   Connection failed [IP: 91.189.91.13 80]
   Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/x/x11proto-core/x11proto-core-dev_7.0.22-1ubuntu0.1_all.deb  Connection failed [IP: 91.189.91.13 80]
   E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Y a-t-il quelque chose que je puisse faire pour résoudre l'erreur?

1
Naveen Kumar

Beaucoup de gens ont du mal à installer OpenCV. Il existe un simple fichier de script .sh qui permet de récupérer tous les fichiers de dépendance sur Internet et de compiler le code source, puis d'installer opencv sur votre système.

Téléchargez le dernier opencv.sh de ici

Je suppose que comme vous m'avez dit que vous avez téléchargé le script dans le répertoire de téléchargement, procédez comme suit:

Terminal ouvert.

cd ~/Downloads  
chmod +x opencv.sh
./opencv.sh

Voir le documentation Ubunt pour plus d'informations

0
Maythux