[Image-SIG] PIL video capture extension type problem
Sat, 09 Feb 2002 11:34:00 -0800
I'm trying to write a C extension that simply takes a PIL image as an
argument and fills it in with data grabbed from a video capture device.
This should be simple, but the Python type casting is baffling me. The
Python code looks like this:
# open the camera device:
# capture a frame into 'im':
This fails at runtime on the last line with this error:
Traceback (most recent call last):
File "mintest.py", line 14, in ?
SystemError: ././_imaging.c:155: bad argument to internal function
My extension code for the getimage() looks like this:
static PyObject *GetImage(PyObject *self, PyObject *args)
/* Check to see that one arguement was passed in */
if (!PyArg_ParseTuple(args, "O", &op))
/* Check to see if that object is an Imaging */
// this is how it's supposed to be done, I think:
im = PyImaging_AsImaging(op);
printf("in GetImage, type 0x%x x %d y %d\n", im->type, im->xsize,
return Py_BuildValue("i", 1);
Note that I'm not actually trying to fil any video data into the Imaging
structure yet. I'll do that once it accepts that the variable 'im' is
actually of the correct type!
The SystemError in _imaging.c:155 is apparently in the
PyImaging_AsImaging() call, which apparently is supposed to recast the
PyObject as an Imaging type. However, the function is detecting some
problem doing this recasting. Why?
Thanks for any help,