Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

(numpy) np.frombuffer does not work with any other dtype except np.int8 or np.uint8

Hello,

Does anybody know why np.frombuffer only work with dtype = np.int8 or np.uint8 (E.g. the following datatypes do not work with np.frombuffer()):

numpy_array = np.frombuffer(imgPtr, dtype=np.int16) //for images with unsigned integer with 2 byte(-32768 to 32767) //does not work "numpy_array = np.frombuffer(imgPtr, dtype=np.uint16) //for images with unsigned integer with 2 byte(0 to 65535) //does not work

numpy_array = np.frombuffer(imgPtr, dtype=np.int32) //for images with signed integer with 4 byte(-2^31 to 2^31-1) "numpy_array = np.frombuffer(imgPtr, dtype=np.uint32) //for images with unsigned integer with 4 byte(0 to 2^32)

Is there any other solution for supporting the above? i.e. for loading image data from the shared Python memory (shared by C++ app) and display it in Python?

Thanks.

(numpy) np.frombuffer does not work with any other dtype except np.int8 or np.uint8

Hello,

Does anybody know why np.frombuffer only work with dtype = np.int8 or np.uint8 (E.g. (i.e. the following datatypes do not work with np.frombuffer()):

numpy_array = np.frombuffer(imgPtr, dtype=np.int16) //for images with unsigned integer with 2 byte(-32768 to 32767) //does not work "numpy_array = np.frombuffer(imgPtr, dtype=np.uint16) //for images with unsigned integer with 2 byte(0 to 65535) //does not work

numpy_array = np.frombuffer(imgPtr, dtype=np.int32) //for images with signed integer with 4 byte(-2^31 to 2^31-1) "numpy_array = np.frombuffer(imgPtr, dtype=np.uint32) //for images with unsigned integer with 4 byte(0 to 2^32)

Is there any other solution for supporting the above? i.e. for loading image data (with dtype=np.int16, np.uint16, np.int32, np.uint32) from the shared Python memory (shared by C++ app) and display it in Python?Python? Currently, I can only load dtype=np.int8 and np.uint8...

Thanks.Will be great to use np.frombuffer(), if not, other method for loading image from buffer is also ok...

Thanks

(numpy) np.frombuffer does not work with any other dtype except np.int8 or np.uint8

Hello,

Does anybody know why np.frombuffer only work with dtype = np.int8 or np.uint8 (i.e. the following datatypes do np.frombuffer() does not work with np.frombuffer()):np.unit32? Do you know any fix or workaround?

numpy_array = np.frombuffer(imgPtr, dtype=np.int16) //for images I am not able to update the title... but after investigation, np.frombuffer does work with unsigned integer with 2 byte(-32768 to 32767) "numpy_array = np.frombuffer(imgPtr, dtype=np.uint16) //for images with unsigned integer with 2 byte(0 to 65535)

numpy_array = np.frombuffer(imgPtr, dtype=np.int32) //for images with signed integer with 4 byte(-2^31 to 2^31-1) "numpy_array = np.frombuffer(imgPtr, dtype=np.uint32) //for images with unsigned integer with 4 byte(0 to 2^32)

Is there any other solution for supporting the above? i.e. for loading image data (with dtype=np.int16, np.uint16, np.int32, np.uint32) from the shared Python memory (shared by C++ app) and display it in Python? Currently, I can only load dtype=np.int8 and np.uint8...

Will be great to use np.frombuffer(), if not, other method for loading image from buffer is also ok...int8, unint8, int16, uint16, int32... Only uint32 does not work...

Thanks

(numpy) np.frombuffer does not work with any other dtype except np.int8 or np.uint8

Hello,

Does anybody know why np.frombuffer() does not work with np.unit32? Do you know any fix or workaround?

I am not able to update the title... but after investigation, np.frombuffer does work with int8, unint8, int16, uint16, int32... Only uint32 does not work...

Thanks

ThanksUpdate on the investigation : actually, np.frombuffer() with np.uint32 does work. The thing that is not working is cv2.imshow() - when I tried to show the image that I loaded from the buffer. I got the following error saying:

TypeError: mat data type = 8 is not supported

is there any display function in opencv that can display mat with data type =8 (i.e. np.uint32)?

(numpy) np.frombuffer does not work with any other dtype except np.int8 or np.uint8

Hello,

Does anybody know why np.frombuffer() does not work with np.unit32? Do you know any fix or workaround?

I am not able to update the title... but after investigation, np.frombuffer does work with int8, unint8, int16, uint16, int32... Only uint32 does not work...

Thanks

Update on the investigation : actually, np.frombuffer() with np.uint32 does work. The thing that is not working is cv2.imshow() - when I tried to show the image that I loaded from the buffer. I got the following error saying:

TypeError: mat data type = 8 is not supported

is there any display function in opencv that can display mat with data type =8 (i.e. np.uint32)?