lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


that's also what happens in Python, where PIL (not to be confused with
PiL, the book) is so well known that every other library that does
anything with images have some way to interoperate with it. But
that's because of popularity, not about any underlying common data
standard.

Quite the opposite.  PIL uses Py_buffer, a data standard in the Python kernel.  That's why you can say "numpy.asarray(img)" when "img" is a PIL image; numpy actually doesn't know anything about PIL, it just uses the Py_buffer interface.

OpenCV and lots of other libraries also use the standard Python typed array facilities and hence all interoperate easily.

Python (and other scripting languages) added facilities like this because there is a real need for a standard for exchanging typed arrays between extensions. I think it would be good if Lua had a simple standard for this as well (and the simplest is just 1D typed arrays used via copying).

Tom

PS:

note that even in C it's a very rare coincidence when unrelated
libraries are so interoperable

What I showed in the Lua example was returning one typed array from one library and passing it to another library.  In C, the "typed array" is a pointer, and it actually is the primary means of exchanging large amounts of data between libraries.