[C++-sig] Creating an array in C++

CÔTÉ Marc-Alexis Marc-Alexis.Cote at ino.ca
Mon Feb 23 21:08:25 CET 2004


Hello,

I am relatively new to the world of python, so please bear with me if you
find this question rather basic.

I am writting some python code that interfaces with an image processing
library that I wrote in C++. Up until now, I have exchanged image data
(between the c++ library and python) through bitmaps stored in files. I find
this rather clumsy and I am trying to use boost.python and the
numeric::array type to help me transfer images from the library in a more
elegant manner.

My first problem is in creating the numeric::array in the c++ code. Let's
say that I want a 3 dimensional array of unsigned bytes, would this be a
correct way to do it?

unsigned char data[300];
boost::python::numeric::array anArray(&data[0], "UByte",
boost::python::make_tuple(10,10,3));

This doesn't give an error when I compile it. However, it fails to run as I
expect it:

>>>TypeError: No to_python (by-value) converter found for C++ type: unsigned
char

What am I missing?
Would you even use an array to return the data, or is there a better way?

Thanks,

Marc-Alexis Cote
*************************************************************************************
Ce courrier électronique s'adresse uniquement à la personne désignée 
ci-dessus, il est confidentiel et ne doit pas être remis à une autre
personne, ni reproduit et son contenu ne peut être autrement divulgué.
Si ce courrier électronique vous est transmis par erreur, veuillez
nous en avertir immédiatement à l'adresse securite at ino.ca. Nous
vous remercions de votre collaboration.

This email is directed in confidence solely to the person named above,
and may not otherwise be distributed, copied or disclosed. If you have
received this email by error, please notify us immediately by email to
address security at ino.ca. Thank you for your cooperation.
***********************************************************************************





More information about the Cplusplus-sig mailing list