L1 / 知能システムツール演習a(2017年度)第5回

Back to the index. 2017/06/23b,18:42

Step L1:Setup at 3L504 Ubuntu linux

3L504 Ubuntu linux (a.k.a. Zengaku PC linux) is strictly administrated by the university.
So unlike your own linux at your PC, we need to have a special care on preparation and compiling the target software (OpenCV).
Limitations are:

  1. Only 2GB at your home
  2. No prividge control (you cannot be root)
  3. Some important prerequisite libraries are missing (or installed in unexpected way)

We use the /tmp directory, which is a freespace.
(Unfortunately, you will loose everything in /tmp on shutdown.)
(If you wan to keep this week's work, you need to make a back up of /tmp/iit/usr (and tmp/iit/work if you have a space.)

The procedure here is rather different from ordinary ones you may find on the Internet.

  1. How to check the installed packages in the ubuntu linux
    An official procedure is shown :
    http://docs.opencv.org/3.2.0/d7/d9f/tutorial_linux_install.html
    However, we cannot install packages to the OS as root (admin).
    (you cannot run "sudo apt-get ...")

    Anyway, you can check what have been installed here.
    Terminal
    # full list
    dpkg -l 
    # find some (e.g. opencv)
    dpkg -l | grep build-essential
    dpkg -l | grep cmake
    dpkg -l | grep git
    dpkg -l | grep libgtk2.0-dev
    # ...
    dpkg -l | grep libdc1394-22-dev
    
    # some are actually missing, but you cannot install them directly.
    
    dpkg -l | grep opencv
    # ... actually, you can find version 2.4.9.1(+dgs-1.5ubuntu1) have been installed
    # ... but we will pursue 3.2.0 
    

  2. Making OpenCV (1)
    Let's say /tmp/iit/work as your working folder (for temporary use) and /tmp/iit/usr as the (final) installation folder.
    The latest sources of the opencv and opencv_contrib can be obtained in zip format.
    But here we try to use github.
    https://github.com/opencv/
    (and choose "opencv", then find "Cline or download", "Clone with HTTPS")
    Terminal:Shell
    cd /tmp
    mkdir iit
    cd    iit
    mkdir work
    cd    work
    
    # take the source (main part)
    git clone https://github.com/opencv/opencv.git
    cd opencv
    
    # https://github.com/opencv/ -> click "opencv" -> click "Clone or download" 
    git log --date=short --pretty='format:%H %cd %s' | less
    # and find "70bbf17b133496bd7d54d034b0f94bd869e0e810" (= OpenCV 3.2.0 release)
    # https://github.com/opencv -> click "opencv" -> click "51 releases" 
    #                           -> click "70bbf17" -> check string of "commit"
    git log --date=short --pretty='format:%H %cd %s' | grep 70bbf17
    
    # let's roll back to the 70bbf17 ..
    # remove everything!
    rm -rf *
    ls
    git checkout 70bbf17b133496bd7d54d034b0f94bd869e0e810
    git reset --hard HEAD
    ls
    
    # take the source (contrib part)
    cd ../
    # https://github.com/opencv/ -> click "opencv" -> click "Clone or download" 
    git clone https://github.com/opencv/opencv_contrib.git
    cd opencv_contrib
    # https://github.com/opencv/ -> click "opencv_contrib" -> click "6 releases" 
    #                            -> click "8634252" -> check string of "commit"
    git log --date=short --pretty='format:%H %cd %s' | grep 8634252
    git checkout 86342522b0eb2b16fa851c020cc4e0fef4e010b7
    git reset --hard HEAD
    ls
    
    # Go back to the main part 
    cd ../opencv
    # dig a folder for compiling
    # mmdd-hhss ... your time now (my recommendation)
    # 20170623-0850 for example
    mkdir build-2017mmdd-hhss
    cd    build-2017mmdd-hhss
    
    # cmake 1st try
    cmake ../ > ../build-2017mmdd-hhss-a.txt
    less CMakeCache.txt
    
    # cmake 2nd try
    cmake \
     -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \
     ../ > ../build-2017mmdd-hhss-b.txt
    
    # cmake 3rd try
    cmake \
     -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \
     -D BUILD_EXAMPLES=ON \
     -D INSTALL_C_EXAMPLES=ON \
     -D INSTALL_PYTHON_EXAMPLES=ON \
     -D WITH_TBB=ON \
     -D CMAKE_INSTALL_PREFIX=/tmp/iit/usr \
     ../ > ../build-2017mmdd-hhss-c.txt
    
    # Find the each variable ("OPENCV_EXTRA_MODULES_PATH", ... ) 
    # in build-2017mmdd-hhss-c.txt and explain it.
    

    Unfortunatelly, the current OS setup does not have proper ffmpeg environment.
    So our OpenCV cannot work with video files properly.

  3. Making OpenCV (2)
    OK, let's make objects and binaries by "make" command.
    Terminal:Shell
    # continued
    cd /tmp/iit/work/opencv/build-2017mmdd-hhss
    
    # Let's check how much we consurme the space
    du -s .
    du -s /tmp/iit/work/opencv
    du -s /tmp/iit/work/FFmpeg-n3.3.2
    du -s /tmp/iit/usr
    
    # It's the time to compile (with 4 CPUs)
    time make -j4
    
    # test (as this is a huge project...)
    make test
    
    # install (without root permission)
    make install
    
    # Let's check how much we consurme the space
    du -s .
    du -s /tmp/iit/work/opencv
    du -s /tmp/iit/usr
    
    # files are
    ls /tmp/iit/usr/
    ls /tmp/iit/usr/lib/
    ls /tmp/iit/usr/lib/
    ls /tmp/iit/usr/share/OpenCV
    
    



kameda[at]iit.tsukuba.ac.jp