How to add “Tracker” in openCV python 2.7

前端 未结 5 1894
一个人的身影
一个人的身影 2020-12-20 14:05

I’m working with python 2.7 and opencv 3.1 I want to run a code for tracking objects by this:

import cv2
import sys

if __name__ == \'__main__\' :

    # Set         


        
5条回答
  •  死守一世寂寞
    2020-12-20 14:59

    Once Installation is over. All files are installed in /usr/local/ folder.
    But to use it, your Python should be able to find OpenCV module.

    You have two options for that.

    1. Move the module to any folder in Python Path: Python path can be found out by entering import sys;print sys.path in Python terminal. It will print out many locations. Move /usr/local/lib/python2.7/site-packages/cv2.so to any of this folder. For example, su mv /usr/local/lib/python2.7/site-packages/cv2.so /usr/lib/python2.7/ → site-packages. But you will have to do this every time you install OpenCV.

    2. Add /usr/local/lib/python2.7/site-packages to the PYTHON_PATH: It is to be done only once. Just open ~/.bashrc and add following line to it, then log out and come back. export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages. Thus OpenCV installation is finished. Open a terminal and try import cv2.

提交回复
热议问题