[SOLVED] How to install latest openCV from source in Mageia

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

[SOLVED] How to install latest openCV from source in Mageia

Postby erotavlas » Jan 23rd, '14, 19:57

Hi,

I'm a new user of Mageia, 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:

Code: Select all

version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9])+' | cut -c2-)"
echo "Installing OpenCV" $version
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg
echo "Downloading OpenCV" $version
wget -O OpenCV-$version.tar.gz http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/opencv-"$version".tar.gz/download
echo "Installing OpenCV" $version
tar -xvf OpenCV-$version.tar.gz
cd opencv-$version
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j2
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV" $version "ready to be used"



I can reuse all the part except the following:

Code: Select all

echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get remove ffmpeg x264 libx264-dev
echo "Installing Dependencies"
sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg



Can you provide me the corresponding command package in Mageia?

Code: Select all

echo "Removing any pre-installed ffmpeg and x264"
sudo rpm -e ffmpeg x264 libx264-dev
echo "Installing Dependencies"
sudo rpm -i libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg


Thank you very much
Best Regards
Last edited by erotavlas on Jan 27th, '14, 22:45, edited 2 times in total.
erotavlas
 
Posts: 6
Joined: Jan 23rd, '14, 19:51

Re: How to install latest openCV from source in openSuse 64

Postby doktor5000 » Jan 24th, '14, 00:59

In the topic you wrote OpenSuse 64, is that a typo?

erotavlas wrote:Can you provide me the corresponding command package in mageia?


This should do it:
Code: Select all
echo "Removing any pre-installed ffmpeg and x264"
sudo urpme -a ffmpeg x264
echo "Installing Dependencies"
sudo urpmi --buildrequires http://ftp.nluug.nl/pub/os/Linux/distr/mageia/distrib/cauldron/SRPMS/core/release/opencv-2.4.6.1-2.mga4.src.rpm


Please remember that sudo is not installed/configured by default in Mageia. For setup see https://wiki.mageia.org/en/Configuring_sudo

Also for sudo urpme -a ffmpeg x264 be sure to look which packages it wants to remove, as quite some packages depend on libx264.
Just tried here, and it included wine, k3b, essential parts of kde and plasmoids, vlc, mplayer, xbmc and some others.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18042
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to install latest openCV from source in Mageia 64

Postby erotavlas » Jan 24th, '14, 10:21

I'm sorry I would have to write Mageia. Too many distribution and I made a mistake.
I'm trying to write a script to install openCV from source with a custom CMAKE. At the moment I'm able to this on Debian, Ubuntu and Mint and openSuse. Can you help me to find the corresponding package in Mageia operating system?

Thank you
erotavlas
 
Posts: 6
Joined: Jan 23rd, '14, 19:51

Re: How to install latest openCV from source in Mageia 64

Postby doktor5000 » Jan 24th, '14, 12:05

erotavlas wrote:Can you help me to find the corresponding package in Mageia operating system?

Did you actually read my last post?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18042
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to install latest openCV from source in Mageia 64

Postby erotavlas » Jan 24th, '14, 15:13

Yes I have read it. 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, Fedora and openSuse. Now I want to do this with Mageia
Code: Select all
echo "Removing any pre-installed ffmpeg and x264"
su -c "urpme -a ffmpeg x264 libx264-dev"
echo "Installing Dependencies"
su -c "urpmi  libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg"

What I need is a way to locate the corresponding packages in Mageia. 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 Mageia?

Thank you
Last edited by erotavlas on Jan 25th, '14, 11:18, edited 1 time in total.
erotavlas
 
Posts: 6
Joined: Jan 23rd, '14, 19:51

Re: How to install latest openCV from source in Mageia 64

Postby doktor5000 » Jan 25th, '14, 00:26

erotavlas wrote:Yes I have read it.
[..]
Now I want to do this with Mageia
Code: Select all
echo "Removing any pre-installed ffmpeg and x264"
su -c "urpme -a ffmpeg x264 libx264-dev"
echo "Installing Dependencies"
su -c "urpmi  libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg"

What I need is a way to locate the corresponding packages in openSUSE.

Again you mention openSUSE ?

Anyways, I've given you the command to install all required packages to compile opencv, please check my second-to last post again.

If you want to search for packages, best use
Code: Select all
urpmf -f -m --name packagename

If you have further questions about using urpm* tool, please have a look at https://wiki.mageia.org/en/URPMI
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18042
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to install latest openCV from source in Mageia 64

Postby erotavlas » Jan 25th, '14, 13:39

I want to search each package and your hints are very useful. Sorry if I'm continuing to talk about openSUSE. I have found almost all the packages except those which are non-free (faac, mp3lame, x264) and (v4l, gtk2, xvid, amrnb and amrwb). I read here https://wiki.mageia.org/en/URPMI how to add a repository with the command
Code: Select all
urpmi.addmedia nameofmedia ftp://ftp.site.com/path/to/Mageia/RPMS

but where are the links of the repositories (non-free and tainted)?
Thank you
erotavlas
 
Posts: 6
Joined: Jan 23rd, '14, 19:51

Re: How to install latest openCV from source in Mageia 64

Postby doktor5000 » Jan 26th, '14, 00:36

Please read https://wiki.mageia.org/en/Software_management
If you have added a full set of repositories, then you just need to enable the nonfree and tainted repos.
Also check http://doc.mageia.org/mcc/3/en/content/ ... media.html

But not sure why you're still searching the packages when you could conveniently install all of them with a single command.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18042
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to install latest openCV from source in Mageia 64

Postby erotavlas » Jan 26th, '14, 13:25

Hi,
thank you very much for your availability. I have two more questions: the first is related to the command
Code: Select all
su -c "/usr/sbin/urpmi.update --no-ignore \"Tainted Release\" && /usr/sbin/urpmi.update --no-ignore \"Nonfree Release\" && /usr/sbin/urpmi --auto-update"

It asks to me if I want update and the it starts to ask continuosly "Insert medium Core Release". If I'm not wrong it is the medium from which I have installed Mageia. Or what else?
The second is related to the sudo command. It only works for sudo user and the behaviour is different from ubuntu and openSUSE. Moreover in Mageia the command su - c "rmpi ..." requires the full path su - c "/usr/sbin/rmpi ..."

My final script is this: so I hope that I can save a lot of time for people that need to install openCV from source code with custom options.
Code: Select all
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 repositories"
su -c "/usr/sbin/urpmi.update --no-ignore \"Tainted Release\" && /usr/sbin/urpmi.update --no-ignore \"Nonfree Release\" && /usr/sbin/urpmi --auto-update"
echo "Removing any pre-installed ffmpeg and x264"
su -c "/usr/sbin/urpme -a ffmpeg x264 lib64x264-devel"
echo "Installing Dependenices ffmpeg, codecs and zlib"
su -c "/usr/sbin/urpmi gcc gcc-c++ make cmake checkinstall pkgconfig yasm opencv-devel lib64tiff-devel lib64jpeg-devel lib64jasper-devel lib64avcodec54 lib64avformat54 lib64swscaler2 lib64dc1394-devel lib64xine-devel lib64gstreamer0.10-devel lib64gstreamer-plugins-base0.10-devel lib64v4l-devel lib64python-devel python-numpy-devel tbb-devel tbb lib64qt4-devel lib64aacs-devel lib64gtk+2.0-devel lib64lame-devel gstreamer0.10-amrnb gstreamer0.10-amrwbdec lib64vo-amrwbenc-devel lib64theora-devel lib64vorbis-devel lib64xvid-devel x264 lib64x264-devel v4l-utils ffmpeg lib64ffmpeg-devel unzip lib64zlib-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 "/usr/sbin/ldconfig"
echo "OpenCV" $version "ready to be used"


Best Regards
erotavlas
 
Posts: 6
Joined: Jan 23rd, '14, 19:51

Re: How to install latest openCV from source in Mageia 64

Postby doktor5000 » Jan 27th, '14, 01:53

erotavlas wrote:Hi,
thank you very much for your availability. I have two more questions: the first is related to the command
Code: Select all
su -c "/usr/sbin/urpmi.update --no-ignore \"Tainted Release\" && /usr/sbin/urpmi.update --no-ignore \"Nonfree Release\" && /usr/sbin/urpmi --auto-update"

It asks to me if I want update and the it starts to ask continuosly "Insert medium Core Release". If I'm not wrong it is the medium from which I have installed Mageia. Or what else?

Yes it is. See the description next to the second screenshot in this section: https://wiki.mageia.org/en/Software_man ... ia_sources
Apart from that you only enable the _release media, and will miss any updates/bugfixes for the nonfree and tainted packages you're installing.
This is what I'm using after installation (sudo is configured passwordless here)
Code: Select all
sudo urpmi.update --no-ignore "Tainted Release" && sudo urpmi.update --no-ignore "Tainted Updates" && sudo urpmi.update --no-ignore "Nonfree Release" && sudo urpmi.update --no-ignore "Nonfree Updates" && sudo urpmi.update -a


erotavlas wrote:The second is related to the sudo command. It only works for sudo user and the behaviour is different from ubuntu and openSUSE. Moreover in Mageia the command su - c "rmpi ..." requires the full path su - c "/usr/sbin/rmpi ..."


Please read what I've written before:
doktor5000 wrote:Please remember that sudo is not installed/configured by default in Mageia. For setup see https://wiki.mageia.org/en/Configuring_sudo

Apart from that, sudo has exactly nothing to do with su.

For your question about the path, probably /usr/sbin is in the $PATH of standard users in *buntu/openSUSE, that would explain this behaviour.
If you want the same behaviour on Mageia, use
Code: Select all
su - -c "urpmi"
as su - will create a full environment, including $PATH.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18042
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to install latest openCV from source in Mageia 64

Postby erotavlas » Jan 27th, '14, 22:44

Thank you very much. This is my final script. I hope to help people to save time on installing openCV from source with custom options in Mageia 3 64 bit.
Best Regards

Code: Select all
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 repositories"
su -c "/usr/sbin/urpmi.update --no-ignore \"Tainted Release\" && /usr/sbin/urpmi.update --no-ignore \"Tainted Updates\" && /usr/sbin/urpmi.update --no-ignore \"Nonfree Release\" && /usr/sbin/urpmi.update --no-ignore \"Nonfree Updates\" && /usr/sbin/urpmi.update -a"
echo "Removing any pre-installed ffmpeg and x264"
su -c "/usr/sbin/urpme -a ffmpeg x264 lib64x264-devel"
echo "Installing Dependenices ffmpeg, codecs and zlib"
su -c "/usr/sbin/urpmi gcc gcc-c++ make cmake checkinstall pkgconfig yasm opencv-devel lib64tiff-devel lib64jpeg-devel lib64jasper-devel lib64avcodec54 lib64avformat54 lib64swscaler2 lib64dc1394-devel lib64xine-devel lib64gstreamer0.10-devel lib64gstreamer-plugins-base0.10-devel lib64v4l-devel lib64python-devel python-numpy-devel tbb-devel tbb lib64qt4-devel lib64aacs-devel lib64gtk+2.0-devel lib64lame-devel gstreamer0.10-amrnb gstreamer0.10-amrwbdec lib64vo-amrwbenc-devel lib64theora-devel lib64vorbis-devel lib64xvid-devel x264 lib64x264-devel v4l-utils ffmpeg lib64ffmpeg-devel unzip lib64zlib-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 "/usr/sbin/ldconfig"
echo "OpenCV" $version "ready to be used"
erotavlas
 
Posts: 6
Joined: Jan 23rd, '14, 19:51


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron