Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python & OpenCV

Dears,

I try to use OpenCV in Python, and running example such as

import numpy as np
import cv2

img = cv2.imread('messi5.jpg',0)

cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.imshow('image',img)
cv2.waitKey(0) 
cv2.destroyAllWindows()import numpy as np
import cv2

img = cv2.imread('messi5.jpg',0)

cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.imshow('image',img)
cv2.waitKey(0) 
cv2.destroyAllWindows()

Unfortunately I'm not able to dislpay image and getting errors such as

Traceback (most recent call last):

  File "<ipython-input-1-0d251b5710ac>", line 1, in <module>
    runfile('C:/Python27/Scripts/untitled1.py', wdir='C:/Python27/Scripts')

  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)


  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Python27/Scripts/untitled1.py", line 14, in <module>
    cv2.imshow('image',img)

error: ..\..\..\modules\highgui\src\window.cpp:269: error: (-215) size.width>0 && size.height>0 in function cv::imshow

what;s the propoer way to handle images and displaying hem in python?

Thank you. Peter