Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No highgui in python

Tags:

python

opencv

I'm trying to write some programs using opencv and python. I installed opencv and the python libraries from the repositories. I'm using ubuntu 12.04. The folder /var/lib/python-support/python2.7 contains just 5 files :

  • cv2.so
  • cv.py
  • cv.pyc
  • simplegeneric-0.7.egg-info
  • simplegeneric.py
  • simplegeneric.pyc

From what reading I have done, I think there's supposed to be an opencv folder around here. I'm able to import cv library using

    import cv

but

    from opencv import cv 

And I cannot load the highgui module. Any way to work around this? I would really really like to do something in opencv

like image 423
Kevin Martin Jose Avatar asked Aug 13 '26 19:08

Kevin Martin Jose


1 Answers

You must have installed OpenCV >= 2.3.1. In OpenCV 2.3.1 and higher, Python bindings do not have highgui.

import cv2
import cv2.cv as cv

and you're good to go.

import cv2
img  = cv2.imread("image name")
cv2.imshow("window name", img)
cv2.waitKey(0)

You can find more help on OpenCV docs and you could also look at some of the opwncv stuff that I have been doing here.

I hope this helps.

like image 68
Froyo Avatar answered Aug 15 '26 08:08

Froyo