I’m a new user of openSuse, I think that it is a great distribution. I’m an old Ubuntu user and I have to learn many things about the difference between them. When I was in Ubuntu I found a very useful script to build openCV from source. The script is the following:
You do know you can simply install opencv using YaST’s Software Manager since it’s located in the OSS repo (which is
enabled by default). Or you can use zypper:
sh-4.2$ su -c "zypper in opencv"
Unlike Ubuntu, openSUSE is not obssessed by sudo': if you going to run a script that installs software, you shouldn't need to begin any line with sudo’ because you can simply run your installation script in openSUSE thus…
sh-4.2$ su -c "sh yourscript.sh"
… obviating the need for `sudos’ inside your script.
The default package installations for Ubuntu and openSUSE differ and by switching defaults, you can’t assume that the
dependency are going to fulfilled identically between the distributions. If you really want to install from source, you
should read the dependencies of opencv that should be listed on the SourceForge site. But I really think it’s a lot
easier to install with dependencies auto-installed using YaST or zypper (see Point 1).
Thank you for your reply. I’m interested about installing openCV from source since I want to add custom codecs and custom compiling options. I’m trying to achieve this in all major distributions. I started with Debian, Ubuntu and Mint and Fedora. Now I want to do this with openSuse.
What I need is a way to locate the corresponding packages in openSUSE. For instance in Ubuntu the command to find a package is apt-cache search name while in Fedora is yum list name.
How can I do this in openSuse?
On 2014-01-24, erotavlas <erotavlas@no-mx.forums.opensuse.org> wrote:
> What I need is a way to locate the corresponding packages in openSUSE.
> For instance in Ubuntu the command to find a package is apt-cache search
> name while in Fedora is yum list name.
> How can I do this in openSuse?
>
> Thank you
> Thank you for your reply. I’m interested about installing openCV from
> source since I want to add custom codecs and custom compiling options.
> I’m trying to achieve this in all major distributions. I started with
> Debian, Ubuntu and Mint and Fedora. Now I want to do this with openSuse.
You could consider then the open buildservice. You get an account, and
build there your package for several distributions. Caveat: those codecs
have to be entirely legal (on the USA, I think).
Calling “su” or “sudo” often inside a script causes it to be requesting
the root password every time. This is highly inconvenient. Normally I
would expect to run such a script simply by root directly.
After all, it is the administrator who does maintenance tasks, not the
users.
–
Cheers / Saludos,
Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)
Ok with the command zypper se name I have found the majority of the libraries. The following libraries are not present in the repositories. Some of them are not open and in the other distributions I added non-free repositories to get them.
Thank you very much at all for the support (in particular to wolfi323). You allow to me to save a lot of time. I have attached the script that do all the work so in future other new user, like me, will have the life simplified
Best Regards
version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9])+' | cut -c2-)"
downloadfilelist="opencv-$version.tar.gz opencv-$version.zip"
downloadfile=
for file in $downloadfilelist;
do
wget --spider http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$file/download
if $? -eq 0 ]; then
downloadfile=$file
fi
done
if -z "$downloadfile" ]; then
echo "Could not find download file on sourceforge page. Please find the download file for version $version at"
echo "http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/ and update this script"
exit 1
fi
echo "Installing OpenCV, ffmpeg and zlib" $version
mkdir OpenCV
cd OpenCV
echo "Installing repository"
su -c "zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_$(cat /etc/SuSE-release | grep "VERSION =" | awk -F "=" '{gsub(" ", "", $2); print $2}')/Multimedia/ packman-multimedia"
su -c "zypper ar -f -n devel-libraries-c++ http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_$(cat /etc/SuSE-release | grep "VERSION =" | awk -F "=" '{gsub(" ", "", $2); print $2}')/ devel-libraries-c++"
su -c "zypper refresh"
echo "Removing any pre-installed ffmpeg and x264"
su -c "zypper remove ffmpeg x264 libx264-devel"
echo "Installing Dependenices ffmpeg, codecs and zlib"
su -c "zypper install gcc gcc-c++ make cmake checkinstall pkg-config yasm opencv-devel libavutil51 libavformat51 libavfilter1 libavdevice51 libavcodec55 libtiff-devel openjpeg-devel libopenjpeg1 libdc1394-devel libXinerama-devel libgstreameexitr-0_10-0 gstreamer-plugins-base libv4l-devel python-devel python-numpy-devel tbb libtbb2 libqt4-devel gtk2-devel libfaac-devel libmp3lame-devel libamrnb-devel libopencore-amrnb0 libtheora-devel libvorbis-devel libvpx1 libxvidcore-devel x264 v4l-utils ffmpeg ffmpeg unzip zlib-devel"
echo "Downloading OpenCV" $version
wget -O $downloadfile http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$downloadfile/download
echo "Installing OpenCV" $version
echo $downloadfile | grep ".zip"
if $? -eq 0 ]; then
unzip $downloadfile
else
tar -xvf $downloadfile
fi
cd opencv-$version
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=ON -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_OPENCL=ON -D WITH_CUDA=ON -D WITH_GTK=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF -D BUILD_EXAMPLES=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_JPEG=ON -D BUILD_PNG=ON -D BUILD_JASPER=ON -D BUILD_ZLIB=ON -D WITH_JPEG=ON -D WITH_PNG=ON -D WITH_JASPER=ON -D WITH_ZLIB=ON -D WITH_OPENEXR=OFF ..
make -j 2
su -c "make install"
su -c "sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'"
su -c "ldconfig"
echo "OpenCV" $version "ready to be used"
you are right this is ok since I don’t want to have folder of openCV with root permission. However the following script requires the password only one time when you launch it with sh -c “sh installOpenCV.sh”
version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9])+' | cut -c2-)"
downloadfilelist="opencv-$version.tar.gz opencv-$version.zip"
downloadfile=
for file in $downloadfilelist;
do
wget --spider http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$file/download
if $? -eq 0 ]; then
downloadfile=$file
fi
done
if -z "$downloadfile" ]; then
echo "Could not find download file on sourceforge page. Please find the download file for version $version at"
echo "http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/ and update this script"
exit 1
fi
echo "Installing OpenCV, ffmpeg and zlib" $version
mkdir OpenCV
cd OpenCV
echo "Installing repository"
zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_$(cat /etc/SuSE-release | grep "VERSION =" | awk -F "=" '{gsub(" ", "", $2); print $2}')/Multimedia/ packman-multimedia
zypper ar -f -n devel-libraries-c++ http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_$(cat /etc/SuSE-release | grep "VERSION =" | awk -F "=" '{gsub(" ", "", $2); print $2}')/ devel-libraries-c++
zypper refresh
echo "Removing any pre-installed ffmpeg and x264"
zypper remove ffmpeg x264 libx264-devel
echo "Installing Dependenices ffmpeg, codecs and zlib"
zypper install gcc gcc-c++ make cmake checkinstall pkg-config yasm opencv-devel libavutil51 libavformat51 libavfilter1 libavdevice51 libavcodec55 libtiff-devel openjpeg-devel libopenjpeg1 libdc1394-devel libXinerama-devel libgstreameexitr-0_10-0 gstreamer-plugins-base libv4l-devel python-devel python-numpy-devel tbb libtbb2 libqt4-devel gtk2-devel libfaac-devel libmp3lame-devel libamrnb-devel libopencore-amrnb0 libtheora-devel libvorbis-devel libvpx1 libxvidcore-devel x264 v4l-utils ffmpeg ffmpeg unzip zlib-devel"
echo "Downloading OpenCV" $version
wget -O $downloadfile http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$downloadfile/download
echo "Installing OpenCV" $version
echo $downloadfile | grep ".zip"
if $? -eq 0 ]; then
unzip $downloadfile
else
tar -xvf $downloadfile
fi
cd opencv-$version
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=ON -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_OPENCL=ON -D WITH_CUDA=ON -D WITH_GTK=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF -D BUILD_EXAMPLES=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_JPEG=ON -D BUILD_PNG=ON -D BUILD_JASPER=ON -D BUILD_ZLIB=ON -D WITH_JPEG=ON -D WITH_PNG=ON -D WITH_JASPER=ON -D WITH_ZLIB=ON -D WITH_OPENEXR=OFF ..
make -j 2
make install
sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
ldconfig
echo "OpenCV" $version "ready to be used"
Because there is no shebang in the “script”, just starting it, it will not be quite clear which shell will be used. By starting the POSIX shell through the sh command and then offering it the file with commands to be executed, the OP is sure which shell is used. (But I would prefer to add the shebang of course).
So what?
If he cares which shell is used, he should add the shebang anyway. Better than having to specify the right shell when calling the script IMHO.
But actually I was mostly aiming at the two “sh”'s in the command line:
sh -c “sh installOpenCV.sh”
But I think now that this was just a typo, the first one was meant to be “su” I guess…