Project

General

Profile

How to interface a new 1394 camera with pyScope?

Added by Jinyang Liu over 13 years ago

I just start working on a new project on a customized TEM. Currently we haven’t decided which camera to use. One possibility is to use Allied vision technologies (AVT) PIKE series. There are C API provoided by the manufacturer. How can we interface this IIDC camera with pyScope? Thanks.


Replies (1)

RE: How to interface a new 1394 camera with pyScope? - Added by Jim Pulokas over 13 years ago

Hi Jinyang,
Writing a new camera module for pyscope is not so difficult. It would be best to look at the existing support for Gatan and Tietz camera in pyscope as an example of how to do it. You can browse the repository here on redmine, or check it out using your own SVN client. Unfortunately, there is no official documentation on developing modules for pyscope other than those examples. I can help you as much as possible if you want to send me information on the C API for this new camera. Actually, maybe it is available on their web site, so I will check that out.

For each camera that we want to control from pyscope, we create a python module. For example, in pyscope you will find gatan.py and tietz.py. The goal of each of these modules it to provide a standard python interface to each camera. This means that you can load pyscope into a python script and use it without knowing the details of the camera manufacturer API. For example, every camera python module in pyscope will have a "getImage" function to acquire the image and a "setBinning" function to set the binning factor on the camera. Not all the functions you see in gatan.py and tietz.py are required in general. As a minimum, when Leginon uses pyscope, it will expect find the functions related to image size, binning, and offset, and exposure time. Also, a function to set the exposure type, whether is is "dark" (shutter stays closed) or "normal" (shutter opens during the exposure). You can also look at the simccdcamera.py module, which is a fake camera that exists only in python. It provides another example of the functions that can be defined.

There is one thing to be aware of if need to do "low dose" imaging, where the beam is usually blanked except for the short duration of the exposure time: While the manufacturer API may include functions for manually controlling the shutter or beam blank, we do not use these from Leginon/pyscope. We expect that when we call the function to acquire an image, the shutter will automatically be controlled by the hardware (or maybe low level software). This is necessary because it would be difficult to synchronize the exposure time and shutter open and close with millisecond precision from inside the python code. In all cameras we currenly use, there is a direct cable connection between the camera controller box and the TEM beam blanker.

Both gatan.py and tietz.py interface to the manufacturer's camera driver through Windows COM using the python "win32com" package. The manufacturers have set up the driver as a COM object/server. The python script dynamically binds to the running camera driver and calls functions directly. You might check to see if your new camera will have this type of interface. However, it sounds like they are providing a C API, which means you will first need to compile a python extension module that is written in C and wraps the important functions of their C API. Then you will create a python module in pyscope that wraps the compiled module. The python support for these COM interfaces is sometimes difficult to work with anyway, so it may be better to have this direct control through a C API.

This is just an introduction, so let me know what you think so far and I will continue to help as much as possible.

Jim

    (1-1/1)