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.
It seems that they opted to eventually avoid this structure altogether. Instead, it just uses a python tuple (width, height).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With