seeing-things / zwo

ZWO SDK and custom software for debugging and using it.
24 stars 5 forks source link

Implement a Python interface to the ZWO SDK #22

Closed bgottula closed 5 years ago

bgottula commented 5 years ago

There are a couple possible approaches to this:

bgottula commented 5 years ago

I was able to get decently far with SWIG in just a couple hours. With a very short swig.i file I was able to wrap the entire ASICamera2.h header file, import it in Python, and connect to and configure the camera! I was even able to get frames out of the camera but in an inelegant manner.

SWIG is less straightforward for functions like ASIGetVideoData that return information in a buffer that is passed in by pointer, since SWIG has no idea what that pointer argument is for or how to represent that in a meaningful way in Python. I was able to get a rudimentary solution to work using array functions, but I don't know of an easy way to convert this to a numpy array. I think the ideal solution would use Numpy's swig interface file which should allow us to pass a Numpy array directly to the function call in Python, but my initial impression after reading their documentation is that the function prototype for ASIGetVideoData doesn't fit one of their existing templates so there may be a bit of extra work involved to create the right custom template (or something like that).