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

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

Step L3:Run python samples

You need to set environment variable as this configuration is not ordinary.
Sample codes can be found at
http://docs.opencv.org/3.2.0/
or simply
/tmp/iit/usr/share/OpenCV/samples/python

http://docs.opencv.org/3.2.0/
Click: OpenCV-Python Tutorials
Click: GUI Features in OpenCV
Click: Getting Stated with Images
http://docs.opencv.org/3.2.0/dc/d2e/tutorial_py_image_display.html

Our OpenCV was made by python2, but our libirary should work with both python(2) and python3.
How can you know this kind of info? In which file? (remember cmake's output)

  1. Playing samples
    Original samples are found at
    file:///tmp/iit/work/opencv/samples/python
    And they are copied on installation procedure to
    file:///tmp/iit/usr/share/OpenCV/samples/python

    To enjoy sample programs, you should run them at the source tree, and need some setup.
    (As the data files are there.)
    Terminal: Shell
    # As the cv2 (computer vision library of OpenCV API 2.0?) is installed 
    # in our special folder, we should tell python that.
    
    # For python2,
    PYTHONPATH=/tmp/iit/usr/lib/python2.7/dist-packages
    
    # For python3
    # (PYTHONPATH=/tmp/iit/usr/lib/python3.5/dist-packages)
    
    # export
    export PYTHONPATH
    
    # You are ready!
    cd /tmp/iit/work/openv/samples/python
    
    # Try one by one, some works well, some are not.
    
    # for example,
    less lappr.py
    # and run  (you need a USB camera before you run this)
    python lappr.py
    
    

  2. Playing (and edit) your samples
    Download python samples and see that!

kameda[at]iit.tsukuba.ac.jp