OpenCV with Python - Getting start

== Env Setup (Windows OS) ==

  • OpenCV - 2.0
  • Python - 2.6.5

Step 1: System Parameter setup for Python Path:
set %PYTHON_HOME%=D:\Rotter\OCR\python26
set %PATH%=%PATH%;%PYTHON_HOME%


Step 2: Set OpenCV lib into Python lib path:
Ref:
http://docs.python.org/library/site.html
http://www.juyimeng.com/how-to-find-and-add-a-python-search-library-path.html

Create opencv.pth in %PYTHON_PATH%\Lib\site-packages:
D:\Rotter\OCR\OpenCV2.0\Python2.6\Lib\site-packages\opencv
D:\Rotter\OCR\OpenCV2.0\bin


Note: Needn't run the 'setup-for-win.py' script in
OpenCV2.0\interfaces\swig\python as some tutorials said.

Step 3: (Just get some video & pic resources)
Create a fold name as 'src' for the test code.
Copy 'D:\Rotter\OCR\OpenCV2.0\samples\c' fold in to 'src'.

At last, the directory tree looks like:
OCR
|- OpenCV2.0
|- python26
    |- Lib
       |- site-packages
          |- opencv.pth
|- src
    |- c

Exampel.py: (put it in the 'src')
import cv
import highgui
 
if __name__=='__main__':
    image=highgui.cvLoadImage("./c/airplane.jpg",1)
    highgui.cvNamedWindow("picwin")
    highgui.cvShowImage("picwin",image)
    highgui.cvWaitKey(0)
    highgui.cvDestroyWindow("picwin")


You can get:
OpenCV with Python - Getting start

Python IDE suggestion:
http://pyclassroom.appspot.com/2009/08/11/ide-recommend.html

你可能感兴趣的:(C++,c,python,C#,ide)