Ximea machine vision cameras are handled via XiAPI. The API is implemented for the .NET platform. In this article I'll present a IronPython scripts that will use the .NET API to control the Ximea xiQ camera.
IronPython is a Python implementation on the .NET platform and as such it can use any .NET libraries and resources.
At start you have to install the software package with the drivers and libraries. Everything will land in "Ximea" folder located on the primary system partition (C:). It will contain a subfolder called "libraries" with xiApi.NET.dll and m3api.dll. Aside of that we need also IronPython. To script my xiQ MQ013MG-E2 camera I copyed those two mentioned DLL files into an empty folder. I've also copyed ipy.exe - IronPython executable to get quick and fast way to launch IronPython scripts from terminal (I should add the original IronPython executable path into system paths).A basic script that saves one frame looks like so:
At start I load the XiAPI and System.Drawing to get BMP (Bitmap) support required for te capture process. After that I initialise the camera using xiCam class - I set the exposure time to 9 ms, gain to 10 dB and I also set the image format to 8-bit mono (it's a mono camera). GetImage expects a Bitmap object with correct sizes and format. All methods are described in the documentation.
GetParam can be used to get some informations from the camera.
GetParam as a second parameter expects a System.Runtime.CompilerServices.StrongBox instance which holds a reference to a value.
Saving one frame isn't much useful, so I wrote a class for imaging that would be easy to use from a command line:
To capture a batch of frames into a subfolder only a class instance is needed, like XimeaImager(9000, 10.0, 100, False, 'test'). I've also added HDR support which merges 3 different exposures into one image with better dynamic range. The exposure time ratio is the same as in default values described in the documentation.
Note that directory and path operations are done by .NET classes. In IronPython you use the .NET API and not what you would use in Python. IronPython scripting allows quick testing and validating of imaging setups and cameras. It's not Python, you need to know a bit of .NET API, but still you can jump on it without being a .NET developer.
As for imaging with this camera - you may want to try my second article about this camera and astrophotography.