2. Writing your first opencv python program.
First of all create one directory for your opencv programs.
Lets say OpencvPython, Now we will save our every program into this Folder, i'll tell you why we are doing this later on.
Now open your favorite Text Editor, i suggested few in my last post. I'll be using sublime text.
write following line and save it as opencv_test.py in the directory OpencvPython that we have created earlier.
Make sure there should not be any space before import or you might get error of indentation by python compiler.
Once you have saved the file now its time to compile and run our Program.
To do so, go to you python program directory in windows explorer.
Now before you run your program make sure your file opencv_test.py is there in you directory. if not then make sure you have saved it earlier if not then save as again in that directory.
I assume now you are in OpencvPython directory and you have opencv_test.py in that directory.
Now
1. Hold Shift key + press Right mouse Click. (make sure no file is selected)
2. click on open command window here.
Now it will open CMD window,
Run the following command in cmd.
python opencv_test.py
and press enter.
if you see below window like this, that means you have no error and your opencv installation is perfect.
See this is the easiest way to run python opencv program, you see why i told you to create new folder and place your python file in that folder so we can run it easily.
Now we will do one more test to finalize our opencv installation by printing opencv version.
To do so write following code in your program.
if you see version printed out like below window, then you should jump out the chair or bed because opencv is finally working on your computer. now you are ready to write some awesome code that can amaze anyone in the world.
See you in next post, we will be learning how to read image file from your computer and display it.
Tags: opencv, opencvpyhon, firstprogram, opencv version test, windows.





No comments:
Post a Comment