One thing I've been finding inconvenient recently is the fact that two
(apparently) identical ctypes data types don't compare as equivalent.
Thus, the current wrapper has the behavior that
"cvSize(5,10)==cvSize(5,10)" is False, whereas even in C comparing the
structures generated by those two constructors would compare true. A lot
of it comes from the fact that in ctypes, even c_int(5)==c_int(5) is false.
At best it's inconvenient as you have to check the fields, but at worst it
can slip by, such as when I did a simple check during a loop to see if
cvGetSize on the supplied image was different than the prior frame and
ended up incurring a lot more overhead than needed, as I thought every
frame was different.
The attached patch attempts to remedy this by providing equivalence for
structure types based on their underlying fields, using the wrapped value
(e.g., 5 for c_int(5)) when available or for pointers, the address being
pointed to. It also permits comparisons to hold true when comparing to a
native Python tuple, as long as that tuple can construct an equivalent object.
Demos all continue to run, although since they couldn't currently depend on
equivalence, I suppose that's not surprising.
Original issue reported on code.google.com by db3l.em...@gmail.com on 23 Jan 2009 at 2:52
Original issue reported on code.google.com by
db3l.em...@gmail.com
on 23 Jan 2009 at 2:52Attachments: