I'm new to python and open cv. I'm trying to find out how to load an image in opencv with python. Can any one provide an example (with code) explaining how to load the image and display it?
import sys import cv from opencv.cv import * from opencv.highgui import * ll="/home/pavan/Desktop/iff pics/out0291.tif" img= cvLoadImage( ll ); cvNamedWindow( “Example1”, CV_WINDOW_AUTOSIZE ); cvShowImage( “Example1”, img ); cvWaitKey(10); cvDestroyWindow( “Example");
There have been quite a few changes in the openCV2 API:
import cv ll = "/home/pavan/Desktop/iff pics/out0291.tif" img = cv.LoadImage(ll) cv.NamedWindow("Example", cv.CV_WINDOW_AUTOSIZE ) cv.ShowImage("Example", img ) cv.WaitKey(10000) cv.DestroyWindow("Example")
It is a simpler, quite cleaner syntax!
Also, you don't need trailing
; à-la-matlab. Last, be careful about the quotes you use.
For the newer openCV3 API, you should see the other answer to this question.