Re: [Numpy-discussion] compiling c extension

2008-01-22 Thread Danny Chan
Yes, that is not the problem. The compiling of the source file works fine, it 
is when the linker tries to create the shared library file that something blows 
up.

Lou Pecora [EMAIL PROTECTED] schrieb: Did you include arrayobject.h and  call 
import_array()
in the initialization function, after the call to
Py_InitModule() ?

--- Danny Chan  wrote:

 Hi!
 I am trying to compile a c extension that uses numpy
 arrays on windows. I can compile the extension file,
 but once I get to the linking stage I get unresolved
 references to PyArray_API and import_array. Can
 anyone help me with the correct linker flags? 
 
 Thanks, Danny

[cut]
 more undefined references to `PyArray_API' follow

build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0xc216):
 undefined reference to `import_array'
 collect2: ld returned 1 exit status
 error: command 'gcc' failed with exit status 1



-- Lou Pecora,   my views are my own.


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


   
-
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit 
dem  neuen Yahoo! Mail. ___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] compiling c extension

2008-01-22 Thread Danny Chan
Ha, found the problem! I thought I had included arrayobject.h and import_array 
correctly, but due to the preprocessor it wasn't  defined correctly!

Danny Chan [EMAIL PROTECTED] schrieb: Yes, that is not the problem. The 
compiling of the source file works fine, it is when the linker tries to create 
the shared library file that something blows up.

Lou Pecora [EMAIL PROTECTED] schrieb: Did you include arrayobject.h and  call 
import_array()
in the initialization function, after the call to
Py_InitModule() ?

--- Danny Chan  wrote:

 Hi!
 I am trying to compile a c extension that uses numpy
 arrays on windows. I can compile the extension file,
 but once I get to the linking stage I get unresolved
 references to PyArray_API and import_array. Can
 anyone help me with the correct linker flags? 
 
 Thanks, Danny

[cut]
 more undefined references to `PyArray_API'  follow

build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0xc216):
 undefined reference to `import_array'
 collect2: ld returned 1 exit status
 error: command 'gcc' failed with exit status 1



-- Lou Pecora,   my views are my own.


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

  

-
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit 
dem   neuen Yahoo! Mail.  ___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


   
-
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit 
dem  neuen Yahoo! Mail. ___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] reading 10 bit raw data into an array

2007-08-01 Thread Danny Chan
Hi Travis!
I guess I will still have to pad my data to full bytes before reading it, 
correct?

Travis Oliphant [EMAIL PROTECTED] schrieb: Danny Chan wrote:
 Hi all!
 I'm trying to read a data file that contains a raw image file. Every 
 pixel is assigned a value from 0 to 1023, and all pixels are stored from 
 top left to bottom right pixel in binary format in this file. I know the 
 width and the height of the image, so all that would be required is to 
 read 10 bits at a time and store it these as an integer. I played around 
 with the fromstring and fromfile function, and I read the documentation 
 for dtype objects, but I'm still confused. It seems simple enough to 
 read data in a format with a standard bitwidth, but how can I read data 
 in a non-standard format. Can anyone help?
 

This kind of bit-manipulation must be done using bit operations on 
standard size data types even in C.  The file reading and writing 
libraries use bytes as their common denominator.

I would read in the entire image into a numpy array of unsigned bytes 
and then use slicing, masking, and bit-shifting to take 5 bytes at a 
time and convert them to 4 values of a 16-bit unsigned image.

Basically, you would do something like

# read in entire image into 1-d unsigned byte array
# create 16-bit array of the correct 2-D size
# use flat indexing to store into the new array
#   new.flat[::4] = old[::5] + bitwise_or(old[1::5], MASK1b)  SHIFT1b
#   new.flat[1::4] = bitwise_or(old[1::5], MASK2a)  SHIFT2a
 + bitwise_or(old[2::5], MASK2b)  SHIFT2b

#   etc.


The exact MASKS and shifts to use is left as an exercise for the reader :-)


-Travis
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


   
-
Jetzt Mails schnell in einem Vorschaufenster überfliegen. Dies und viel mehr 
bietet das  neue Yahoo! Mail. ___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] reading 10 bit raw data into an array

2007-08-01 Thread Danny Chan

 Quick comment :  are you really sure your  camera produces the 12 bit
 data in a 12 bit stream --- all I have ever seen is that cameras
 would just use 16 bit for each pixel.  (All you had to know if it uses
 the left or the right part of those.  In other words, you might have
 to divide (or use  bit shifting) the data by 16.)
 Wasteful yes, but much simpler to handel !?


10 bit, but yes, I am sure. It is an embedded camera system, in fact, I get 
the data stream even before it is handled to any ISP for further processing 
of the picture. In the end, the ISP will convert the data stream to another 
format, but I have to simulate some of the algorithms that will be 
implemented in hardware.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion