At my lab the professor bought a camera that came with a c library to control it from a computer. Right now he wants me to create a gui in matlab to control it but I'm such a python zealot I'd rather do it in that, and then call it from matlab(I'm assuming I can do that).

Right now in matlab I have a figure that displays a live feed from the camera, I do this by calling the c function for the camera that returns a character array containing the grayscale values for each pixel and then resize it into a matrix and have matlab display the picture. How would I do this in wxPython? Also some other slightly related questions:

Can I keep the video feed at a constant ratio as the window resizes?
If I want to constantly refresh the image from the camera do I have to use multiple threads?

Recommended Answers

All 5 Replies

1. Get the character array from the C function (you can call C functions with the built-in ctypes module), and use wx.BitmapFromBuffer to get a wx.Bitmap object (please take note of the buffer format expected).

2. I don't know.

3. wxPython provides a wx.Timer that may help you with that.

I'm trying to use ctypes and it's not working for me. I've done the following:

from ctypes import *
pixci = cdll.LoadLibrary("C:\Program Files\EPIX\XCLIB\XCLIBWNT")
print pixci

test = pixci.pxd_PIXCIopen("", "", "")
print test

which give the following output:

<CDLL 'C:\Program Files\EPIX\XCLIB\XCLIBWNT', handle 10000000 at cd1970>
Traceback (most recent call last):
File "C:\Documents and Settings\Pier\workspace\camera_control\src\camera_control.py", line 5, in <module>
test = pixci.pxd_PIXCIopen("", "", "")
File "C:\Python26\lib\ctypes\__init__.py", line 366, in __getattr__
func = self.__getitem__(name)
File "C:\Python26\lib\ctypes\__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'pxd_PIXCIopen' not found

I've got it working now.

I've got it working now.

In a forum we try to inform each other. What did you do different?

I do hate it when I'm looking for a solution on google and the guy doesn't share his solution.

I removed the loadLibrary function, moved the dll into the same folder as the python script, and I'll check later since I don't have access to the script right now but simply calling windll.XCLIBWNT.pxd_PIXCIopen("","","") or windll.pxd_PIXCIopen("","","") worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.