Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CvSize does not exist?

I have installed the official python bindings for OpenCv and I am implementing some standard textbook functions just to get used to the python syntax. I have run into the problem, however, that CvSize does not actually exist, even though it is documented on the site...

The simple function: blah = cv.CvSize(inp.width/2, inp.height/2) yields the error 'module' object has no attribute 'CvSize'. I have imported with 'import cv'.

Is there an equivalent structure? Do I need something more? Thanks.

like image 798
socks Avatar asked Dec 23 '10 05:12

socks


2 Answers

It seems that they opted to eventually avoid this structure altogether. Instead, it just uses a python tuple (width, height).

like image 123
Nathan Keller Avatar answered Nov 20 '22 06:11

Nathan Keller


To add a bit more to Nathan Keller's answer, in later versions of OpenCV some basic structures are simply implemented as Python Tuples.

For example in OpenCV 2.4:

This (incorrect which will give an error)

image = cv.LoadImage(sys.argv[1]);
grayscale = cv.CreateImage(cvSize(image.width, image.height), 8, 1)

Would instead be written as this

image = cv.LoadImage(sys.argv[1]);
grayscale = cv.CreateImage((image.width, image.height), 8, 1)

Note how we just pass the Tuple directly.

like image 26
Tim Bull Avatar answered Nov 20 '22 07:11

Tim Bull