Sunday, February 7, 2010

PIL to IPL and IPL to PIL converters

# use OpenCV-2.0.0 and later

from opencv.cv import *
from opencv import adaptors
from opencv.highgui import *
from PIL import Image

if __name__ == '__main__':
    pil_img = Image.open('/home/selva/Desktop/me.jpg')

    cv_img = adaptors.PIL2Ipl(pil_img)

    cvNamedWindow("pil2ipl")
    cvShowImage("pil2ipl", cv_img)
    cvWaitKey()

No comments:

Post a Comment