Python use with Mightex Buffer USB camera

Christoph Gohlke cjgohlke at
Thu Oct 28 01:12:04 CEST 2010

On Oct 27, 7:16 am, Greg Miller <et1ssgmil... at> wrote:
> Does anyone have any experience using Python and ctypes to interface
> with one of the Mightex USB cameras?  I am following the CPP code
> example and so far I think I've done pretty well talking to the dll.
> I am able to get serial number information back from the camera,
> however I am not sure if I'm using the ctypes pointer( ) correctly to
> send the pointer to the data structure that the camera is supposed to
> fill in when I make a call to grab a current frame.  Mightex tech
> staff has been VERY helpful, but they don't know Python.

I'm not familiar with the Mightex API, but assuming a C function
'getframe' in the mightex.dll takes a camera handle (typically a C
int) and a pointer to a C unsigned short (16 bit) image buffer, you
could allocate the image using numpy and pass a pointer to the image
data to mightex.getframe as follows (code not tested):

mightex = ctypes.windll.LoadLibrary('mightex.dll')
# omitted code to open camera, get camerahandle, frame width and
PUSHORT = ctypes.POINTER(ctypes.c_uint16)
mightex.getframe.argtypes = (ctypes.c_int, PUSHORT)
image = numpy.empty((width, height), 'uint16')
mightex.getframe(camerahandle, image.ctypes.data_as(PUSHORT))

More information about the Python-list mailing list