CvSize does not exist?

I installed the official python bindings for OpenCv, and I implement some of the standard tutorial functions just to get used to the python syntax. However, I ran into the problem that CvSize does not actually exist, although it is documented on the site ...

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

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

+7
source share
4 answers

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

+7
source

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

For example, in OpenCV 2.4:

This (it is not true that will give an error)

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

Instead it will be written as

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

Please note that we just pass Tuple directly.

+2
source

The correct call is cv.cvSize (inp.width / 2, inp.height / 2).

All functions in opencv python bindings start at the bottom of c, even in the highgui module.

0
source

Perhaps the documentation is incorrect and you should use cv.cvSize instead of cv.cvSize ? Also, create a directory (cv) to find out the methods available to you.

-one
source

All Articles