web-dev-qa-db-ja.com

Ubuntu 12.04にopencvをインストールし、Pythonで実行する方法は?

Raspberry-piで画像処理を行いたいです。

そのためには、まずUbuntuでやりたいと思います。

コマンドSudo apt-get install libopencv-devを実行すると。私は次の出力を得ました:

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?

エラーを解決するためにできることはありますか?

1
Naveen Kumar

多くの人がOpenCVのインストールに問題があります。インターネットからすべての依存ファイルを取得し、最終的にシステムにopencvをインストールするソースをコンパイルする単純な.shスクリプトファイルがあります。

here から最新のopencv.shをダウンロードします

私はあなたがダウンロードディレクトリにスクリプトをダウンロードしたと言ったので、次のことをすると仮定します:

ターミナルを開きます。

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

詳細については buntuのドキュメント をご覧ください

0
Maythux