![](https://secure.gravatar.com/avatar/af6c39d6943bd4b0e1fde23161e7bb8c.jpg?s=120&d=mm&r=g)
Hi Chris 2009/10/2 Chris Colbert <sccolbert@gmail.com>:
I have since been wanting to get back to working on the wrapper, but I've been toying with the idea of instead of just wrapping the OpenCV array type and providing functions to convert to and from numpy arrays, to use a numpy array as the base data type (perhaps through subclassing or a hidden attribute; i havent yet decided) and dynamically creating/updating OpenCV array headers that point to the numpy data. I think this approach would be more natural and pythonic (at a small cost for speed). It would also eleminate the need to wrap the entire opencv library as simple manipulations can just be done with numpy or scipy.ndimage
I am not familiar with the OpenCV array type, but if it addresses contiguous memory, this should be fairly easy to achieve by adding an array interface. The is basically how we are capable of reading PIL arrays these days. An alternative approach would be to write the converter you describe, using this trick suggested by Travis Oliphant: http://blog.enthought.com/?p=62 Thanks for contributing! Regards Stéfan
![](https://secure.gravatar.com/avatar/20ecc2648c30f3c3c5a37804709da79f.jpg?s=120&d=mm&r=g)
not only does IplImage address contiguous array, it uses a strided model similar to numpy. It should be relatively trivial to have numpy be the storage and make it play nice with OpenCV libs. I will see if i cant get a small self contained example going over the next days and let you see what you think... Chris 2009/10/3 Stéfan van der Walt <stefan@sun.ac.za>:
Hi Chris
2009/10/2 Chris Colbert <sccolbert@gmail.com>:
I have since been wanting to get back to working on the wrapper, but I've been toying with the idea of instead of just wrapping the OpenCV array type and providing functions to convert to and from numpy arrays, to use a numpy array as the base data type (perhaps through subclassing or a hidden attribute; i havent yet decided) and dynamically creating/updating OpenCV array headers that point to the numpy data. I think this approach would be more natural and pythonic (at a small cost for speed). It would also eleminate the need to wrap the entire opencv library as simple manipulations can just be done with numpy or scipy.ndimage
I am not familiar with the OpenCV array type, but if it addresses contiguous memory, this should be fairly easy to achieve by adding an array interface. The is basically how we are capable of reading PIL arrays these days.
An alternative approach would be to write the converter you describe, using this trick suggested by Travis Oliphant:
http://blog.enthought.com/?p=62
Thanks for contributing!
Regards Stéfan
participants (2)
-
Chris Colbert
-
Stéfan van der Walt