- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我以前在 Ubuntu 12.04.1 上使用 OpenCV 2.4.5 和一些特定的配置和包,但在 Ubuntu 12.04.2 上升级到 OpenCV 2.4.6.1 时遇到问题
我想分享一些想法(从多个来源收集的值得注意的信息的汇编,包括 SO、ubuntu.org、asklinux.org 和许多其他来源;当然是通过尝试几个过程)
以下是最终让我通过的内容。
注意:确保卸载之前安装的 OpenCV、FFMpeg 和其他先前安装的依赖项。
# goto http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/
# download the latest stable opencv such as 2.4.6.1 (http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.5/opencv-2.4.5.1.tar.gz/download) to current directory (such as home or ~/Document)
# cd /opt
# tar -xvf <path-to-download-folder>/OpenCV-2.4.6.1.tar.gz
# cd OpenCV-2.4.6.1
# create a foler under current dir (following previous step, this should be <opencv-dir>), called prepare
# cd prepare
# Copy the following script to gedit and save as install.sh to current dir, this should be <opencv-dir>/prepare
# Check corresponding url used in the script for latest versions of the package and replace as required
# Open terminal and navigate to location used above
# sudo chmod +x install.sh
# ./install
echo "Removing any pre-installed ffmpeg, x264, and other dependencies (not all the previously installed dependecies)"
sudo apt-get remove ffmpeg x264 libx264-dev libvpx-dev librtmp0 librtmp-dev libopencv-dev
sudo apt-get update
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=0
else
flag=1
fi
echo "Installing Dependenices"
sudo apt-get install autoconf automake make g++ curl cmake bzip2 python unzip \
build-essential checkinstall git git-core libass-dev libgpac-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev
echo "downloading yasm (assembler used by x264 and FFmpeg)"
# use git or tarball (not both)
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
echo "installing yasm"
./configure
make
sudo make install
cd ..
echo 'READ NOTE BELOW which was extracted from http://wiki.serviio.org/doku.php?id=build_ffmpeg_linux'
echo 'New version of x264 contains by default support of OpenCL. If not installed or without sense (example Ubuntu 12.04LTS on VMWare) add to configure additional option --disable-opencl. Without this option ffmpeg could not be configured (ERROR: libx264 not found).'
echo "downloading x264 (H.264 video encoder)"
# use git or tarball (not both)
# git clone http://repo.or.cz/r/x264.git or
git clone git://git.videolan.org/x264.git
cd x264
# wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20130801-2245-stable.tar.bz2
# tar -xvjf x264-snapshot-20130801-2245-stable.tar.bz2
# cd x264-snapshot-20130801-2245-stable/
echo "Installing x264"
if [ $flag -eq 0 ]; then
./configure --enable-static --disable-opencl
else
./configure --enable-shared --enable-pic --disable-opencl
fi
make
sudo make install
cd ..
echo "downloading fdk-aac (AAC audio encoder)"
# use git or tarball (not both)
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
echo "installing fdk-aac"
autoreconf -fiv
./configure --disable-shared
make
sudo make install
cd ..
echo "installing libmp3lame-dev (MP3 audio encoder.)"
sudo apt-get install libmp3lame-dev
echo "downloading libopus (Opus audio decoder and encoder.)"
wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
tar xzvf opus-1.0.3.tar.gz
cd opus-1.0.3
echo "installing libopus"
./configure --disable-shared
make
sudo make install
cd ..
echo "downloading libvpx VP8/VP9 video encoder and decoder)"
# use git or tarball (not both)
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
# wget http://webm.googlecode.com/files/libvpx-v1.1.0.tar.bz2 (this seems not to be update, but can still be used if the fedoraproject link below is not available))
# wget http://pkgs.fedoraproject.org/repo/pkgs/libvpx/libvpx-v1.2.0.tar.bz2/400d7c940c5f9d394893d42ae5f463e6/libvpx-v1.2.0.tar.bz2
# tar xvjf libvpx-v1.2.0.tar.bz2
# cd libvpx-v1.2.0
echo "installing libvpx"
./configure --disable-examples
make
sudo make install
cd ..
sudo ldconfig
echo "downloading ffmpeg"
# git clone http://repo.or.cz/r/ffmpeg.git
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg/
# wget http://ffmpeg.org/releases/ffmpeg-2.0.tar.bz2
# tar -xvjf ffmpeg-2.0.tar.bz2
# cd ffmpeg-2.0/
echo "installing ffmpeg"
if [ $flag -eq 0 ]; then
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libopus --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 --enable-libvpx
else
./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libopus --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 --enable-libvpx --enable-shared
fi
make
sudo make install
hash -r
cd .. # move up one level to prepare folder
cd .. # move up one level to opencv folder
echo "Checking to see if you're using your new ffmpeg"
ffmpeg 2>&1 | head -n1
sudo ldconfig
echo "Installing Dependenices"
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev
echo "installing Video I/O libraries, support for Firewire video cameras and video streaming libraries"
sudo apt-get install libav-tools libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev v4l-utils v4l-conf
echo "installing the Python development environment and the Python Numerical library"
sudo apt-get install python-dev python-numpy
echo "installing the parallel code processing library (the Intel tbb library)"
sudo apt-get install libtbb-dev
echo "installing the Qt dev library"
sudo apt-get install libqt4-dev libgtk2.0-dev
echo "installing other dependencies (if need be it would upgrade current version of the packages)"
sudo apt-get install patch subversion ruby librtmp0 librtmp-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libvpx-dev libxvidcore-dev
echo installing optional packages"
sudo apt-get install libdc1394-utils libdc1394-22-dev libdc1394-22 libjpeg-dev libpng-dev libtiff-dev libjasper-dev
# Open a new terminal window
# Open /etc/ld.so.conf and check,
# if the paths "/usr/lib" and "/usr/local/lib" including the quote exist in the file. If not, add them manually or by
sudo echo "/usr/local/lib" >> /etc/ld.so.conf
sudo echo "/usr/lib" >> /etc/ld.so.conf
# execute the following
sudo ldconfig
# still ensure you haven't close the new terminal window open in STEP 3
# execute the following
mkdir os_build
cd os_build
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_NEW_PYTHON_SUPPORT=ON -DINSTALL_PYTHON_EXAMPLES=ON -DWITH_TBB=ON -DWITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_EIGEN=ON -DWITH_OPENEXR=ON ..
make
sudo make install
# add the following to user environment variable ~/.bashrc
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig
# execute the following
sudo ldconfig
# start to use and enjoy opencv, it should have been install into any of these locations
# /usr/local/include/opencv2, /usr/local/include/opencv, /usr/include/opencv, /usr/include/opencv2, /usr/local/share/opencv
# /usr/local/share/OpenCV, /usr/share/opencv, /usr/share/OpenCV, /usr/local/bin/opencv*, /usr/local/lib/libopencv*
# still ensure you haven't close the new terminal window open in STEP 4
# execute the following
cd ..
mkdir java_build
cd java_build
cmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=OFF -DINSTALL_PYTHON_EXAMPLES=ON -DWITH_TBB=ON -DWITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_EIGEN=ON -DWITH_OPENEXR=ON ..
make
# You can check the "java_build/bin" directory to locate the jar and libopencv_java.so file for your development
# As stated in the docs, the Java bindings dynamic library is all-sufficient, i.e. doesn’t depend on other OpenCV libs, but includes all the OpenCV code inside
# still ensure you haven't close the new terminal window open in STEP 3
# goto http://www.linuxtv.org/downloads/v4l-utils
# download the latest v4l such as v4l-utils-0.9.5.tar.bz2
# copy the downloaded file to the current terminal dir (following previous step, this should be <opencv-dir>/prepare)
# execute the following
tar -xvjf v4l-utils-0.9.5.tar.bz2
cd v4l-utils-0.9.5/
./configure
make
sudo make install
cd ..
cd .. # (to go to <opencv-dir>)
sudo ldconfig
# To check the path where opencv & other lib files are stored, do:
pkg-config --cflags opencv
(output will come as)
-I/usr/include/opencv
pkg-config --libs opencv
(output will come as)
-lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ --ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
# The above paths are needed to compile your opencv programs, as given in the next illustration.
# write a simple C program to test, by saving below program in a file named DisplayImage.c
#include <stdio.h>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char *argv[]) {
IplImage* img=0; /* pointer to an image */
printf("Hello\n");
if(argv[1] != 0)
img = cvLoadImage(argv[1], 0); // 1 for color
else
printf("Enter filename\n");
if(img != 0) {
cvNamedWindow("Display", CV_WINDOW_AUTOSIZE); // create a window
cvShowImage("Display", img); // show image in window
cvWaitKey(0); // wait until user hits a key
cvDestroyWindow("Display");
}
else
printf("File not found\n");
return 0;
}
# write a simple C++ program to test, by saving below program in a file named DisplayImage.cpp
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
# To compile & run :
g++ <filename: e.g. DisplayImage.c or DisplayImage.cpp> `pkg-config --cflags --libs opencv` && ./a.out img
or
g++ -I/usr/include/opencv -I/usr/local/include -lopencv_core -lopencv_highgui -lopencv_ml -lopencv_imgproc -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lopencv_nonfree <filename: e.g. DisplayImage.c or DisplayImage.cpp> && ./a.out img
where “img” is the name of any image with extension within the same folder .
You should be able to see “Hello” and the image in a different window.
If this runs, Congrats! now you can run any C/C++ program with opencv lib.
# Now lets simplify the above big command by making a shortcut for it:
go to your local home directory(cd /home/) and open the .bashrc file using gedit(the file will be hidden). Append the following to the file:
alias gcv="g++ -I/usr/include/opencv -I/usr/local/include -lopencv_core -lopencv_highgui -lopencv_ml -lopencv_imgproc -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lopencv_nonfree"
and save. Close the terminal and open it again.(as this process requires relogin of the terminal)
# Now, go to directory containing a sample program & do
gcv <filename: e.g. DisplayImage.c or DisplayImage.cpp> && ./a.out
or
gcv <filename: e.g. DisplayImage.c or DisplayImage.cpp>
./a.out input_img.jpg
如您所见,这些命令现在变得类似于 $cc filename.c、$./a.out,它们通常用于编译和执行 C/C++ 程序。
检查所有lib文件是否安装的一些方法-
apt-cache search opencv
返回:
libcv-dev - Translation package for libcv-dev
libcv2.3 - computer vision library - libcv* translation package
libcvaux-dev - Translation package for libcvaux-dev
libcvaux2.3 - computer vision library - libcvaux translation package
libhighgui-dev - Translation package for libhighgui-dev
libhighgui2.3 - computer vision library - libhighgui translation package
libopencv-calib3d-dev - development files for libopencv-calib3d
libopencv-calib3d2.3 - computer vision Camera Calibration library
libopencv-contrib-dev - development files for libopencv-contrib
libopencv-contrib2.3 - computer vision contrib library
libopencv-core-dev - development files for libopencv-core
libopencv-core2.3 - computer vision core library
libopencv-dev - development files for opencv
libopencv-features2d-dev - development files for libopencv-features2d
libopencv-features2d2.3 - computer vision Feature Detection and Descriptor Extraction library
libopencv-flann-dev - development files for libopencv-flann
libopencv-flann2.3 - computer vision Clustering and Search in Multi-Dimensional spaces library
libopencv-gpu-dev - development files for libopencv-gpu
libopencv-gpu2.3 - computer vision GPU Processing library
libopencv-highgui-dev - development files for libopencv-highgui
libopencv-highgui2.3 - computer vision High-level GUI and Media I/O library
libopencv-imgproc-dev - development files for libopencv-imgproc
libopencv-imgproc2.3 - computer vision Image Processing library
libopencv-legacy-dev - development files for libopencv-legacy
libopencv-legacy2.3 - computer vision legacy library
libopencv-ml-dev - development files for libopencv-ml
libopencv-ml2.3 - computer vision Machine Learning library
libopencv-objdetect-dev - development files for libopencv-objdetect
libopencv-objdetect2.3 - computer vision Object Detection library
libopencv-video-dev - development files for libopencv-video
libopencv-video2.3 - computer vision Video analysis library
opencv-doc - OpenCV documentation and examples
python-opencv - Python bindings for the computer vision library
最佳答案
感谢提供信息。我尝试运行这些命令但遇到了几个问题。我正在使用全新的 Ubuntu 12.04 安装。
1) 第一个 apt-get remove 命令问我是否要删除很多我不愿意删除的东西,比如 LibreOffice。我没有在这一步中删除任何东西,我认为这没问题,因为我安装的唯一程序是 Java SDK 和 JRE。您为什么选择删除如此庞大的程序列表?
2) 需要在 git 和 tar 命令中添加 sudo。
3)在安装opus和ffmpeg时,./configure命令出现很多错误信息,因为没有写权限,最终配置失败。
无论如何,我只是想将这些问题记录在帖子中,希望它能改进上面列出的过程。
关于opencv - 在 Ubuntu 12.04.02 上设置/安装 OpenCV 2.4.6.1+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18122724/
我听说最好不要从您系统的 Perl 版本所在的 CPAN 安装模块。我知道如何使用命令行安装模块,我只是想知道是否有办法将 CPAN 与系统核心 Perl 分开。 我应该: 下载源代码并专门为这些模块
我听说最好不要从系统的 Perl 版本所在的 CPAN 安装模块。我知道如何使用命令行安装模块,我只是想知道是否有办法将 CPAN 与系统的核心 Perl 分开。 我应该: 下载源代码并专门为这些模块
单独安装 electron 与通过 electron-builder 安装有什么区别?我正在使用 React 构建一个 Electron 应用程序,并且已经找到了一些教程。它们安装 Electron
两者安装有什么区别?我按照安装页面上的说明在全局范围内安装了 webpack,然后我转到了入门指南,据说在那里可以在本地安装 webpack-cli。 CLI = Command Line Inter
我在 OS X Yosemite 上用 PHP 安装了默认的 Apache 服务器,安装了 pear,用 brew 安装了 Solr (brew install solr),现在我正在尝试使用 PEC
我解压并编译了 Ruby 2.1 并安装了几个支持工具。 但是当我安装了 libssl-dev 时,OpenSSL 不会安装。 我在支持 openssl 时遇到这个错误: make: *** No r
我在 android studio 2.3.1 和 gradle 3.2 中设计了 2 到 3 个应用程序。当我从它运行应用程序到任何设备或模拟器时,一切都工作正常。但是当我从构建文件夹中获取该 ap
我注意到我正在读一本书提到通过 apt-get 安装 numpy 和 opencv apt-get install python-numpy python-opencv 但我可以通过以下方式在 pip
我正在尝试在 Windows 8.1 上安装 ansicon。我提取了文件并达到了我需要调用 ansicon -i 的级别。当我在 cmd 中输入此内容并运行 python 脚本时效果很好,但是当我通
我有 linux MINT 17.3 Kernel 4.4.0-81 所有更新可用。 (由于不同的原因,我无法迁移到更新版本的 ubuntu/mint) 我已经通过 PPA 安装了 FFMPEG(不是
尝试在本地运行我的应用程序时出现错误: 我只在 chrome 浏览器中收到此错误。我尝试过不同的东西,但我不确定为什么它是 Chrome 特定的。 最佳答案 我怀疑这不是 Firebase 问题,而是
这是我第一次开发 AngularJS 应用程序并使用脚手架工具 Yeoman ( http://yeoman.io/ )。我想对我的一些图标使用 fontawesome ( http://fortaw
我知道您通常“应该”$ pip install 如果包没有 brew ,但如果有一个你想安装的 python 包,你可以使用 $ pip install或 $ brew install为了?例如,通过
我正在尝试通过 RVM 安装 Ruby 1.9.3。然而,当谈到安装 RubyGems 时,我得到了这个: curl: (22) The requested URL returned error: 4
我是真正提出问题的新手,但你去吧。 我一直在尝试按照安装指南添加 dnsname: https://github.com/containers/dnsname https://github.com/c
Studio更新至0.4.0 建筑产量为“需要1.8版Gradle”;将设置设置为1.8 bin目录; 建立 “要求1.9级”;将设置设置为1.9 bin; 建立 “要求1.8级” 啊。不知道该怎么做
我刚刚注意到 kernel.org 因维护而停机。是否有使用不同镜子的不同公式?或者我可以向 Homebrew 软件添加不同的来源(如 bundler ?)? 谢谢你的帮助! 最佳答案 快速解决方法:
当我运行时: peardev install phpunit/PHPUnit 我得到以下信息: No releases available for package "pear.phpunit.de/P
服务器操作系统为Fedora 24. 64bit。 我想安装 Git 2.6.6。 所以下载源码并安装。 此服务器离线。所以我不使用“yum”。 ./configure --prefix=/usr/l
我正在尝试在我自己的服务器(操作系统:Linux Ubuntu Server 12.04)上安装 OpenEdX,但我遇到了同样的错误。谁能帮帮我? TASK: [ insights | insta
我是一名优秀的程序员,十分优秀!