ctypes help

view full story

http://www.daniweb.com – I've been working on facial recognition and have obtained a dll that can recognize faces in an image, and gives cordinates aswell. It came with an example program written in C++ and I'm trying to port it to python. Here is the C++ code #include "windows.h" #include "loadbmp.h" // from http://gpwiki.org/index.php/LoadBMPCpp #include "fdlib.h" void main(int argc, char *argv[]) {         int i, n, x[256], y[256], size[256], w, h, threshold;                BMPImg *bi;         unsigned char *bgrdata, *graydata;                 if (argc==1)         {             printf("usage: fdtest bmpfilename [threshold]\n");             exit(0);         }                         bi = new BMPImg();         printf("\nloading %s\n", argv[1]);         bi->Load(argv[1]);         w = bi->GetWidth();         h = bi->GetHeight();         printf("image is %dx%d pixels\n", w, h);         bgrdata = bi->GetImg();         graydata = new unsigned char[w*h];                 for (i=0; i<w*h; i++)         {             graydata[i] = (unsigned char) ((.11*bgrdata[3*i] + .59*bgrdata[3*i+1] + .3*bgrdata[3*i+2]));             //if (i<10) printf("%d ", graydata[i]);                    }                        threshold = argc>2 ? atoi(argv[2]) : 0;         printf("detecting with threshold = %d\n", threshold);         fdlib_detectfaces(graydata, w, h, threshold);                                n = fdlib_getndetections();         if (n==1)             printf("%d face found\n", n);         else             printf("%d faces found\n", n);                                for (i=0; i<n; i++)         {             fdlib_getdetection(i, x+i, y+i, size+i);             printf("x:%d y:%d size:%d\n", x[i], y[i], size[i]);         }                 delete[] graydata;         delete bi; }The "bgrdata = bi->GetImg();" seems like it is the same as pythons Image modules getpixel(), as in returns a tuple of the RGB values for the given pixel. I could be wrong. But what I need help with is the graydata.         for (i=0; i<w*h; i++)         {             graydata[i] = (unsigned char) ((.11*bgrdata[3*i] + .59*bgrdata[3*i+1] + .3*bgrdata[3*i+2]));             //if (i<10) printf("%d ", graydata[i]);                    }I know graydata is an array of grayscale values. I convert my image from RGB to grayscale with the Image module and then convert the each pixel value to a ctype to place in the graydata array: while i < 307200: #size of image (640*480)   graydata[i] = c_ubyte(gl[i]) #gl = list of grayscale values   i += 1but when I pass it to the dll i get: >>> fd.fdlib_detectfaces(graydata, w, h, threshold) Traceback (most recent call last):   File "<stdin>", line 1, in <module> ValueError: Procedure probably called with too many arguments (16 bytes in exces s)I didn't know whether to post this problem here, or in the C++ forums. What am I doing wrong? (General)