Python use with Mightex Buffer USB camera

G

Greg Miller

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.
 
C

Christoph Gohlke

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
height
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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top