Dec-01-2021, 02:51 AM
Hello friends,
I am struggling with an array. It's a simple array containing rgb bitmap information, as retrieved via the opencv 2 imread method. Its dimensions are (x,y,3).
I am familiar with the numpy.ndarray.flatten() function which works for 1 to 1 24 bit rgb conversion for serial transmission, but when the rgb data needs to be converted to 16 or 12 bit words, it's much easier and faster to have two 1-dimensional arrays (or lists) with (r,g,b) and (b,g,r) tuples to work with. I've tried reading values in the right order from the matrix and dumping them into a list with tuples, even converting directly from the matrix but in standard python code this is dead slow, not achieving more than 1 frame (240x240 RGB) per 3 or 4 seconds on a raspberry pi 4B.
Who can help me with the correct function to speed up the color conversion? Thank you.
P.S. this is to transmit raw color data to a small LCD display on an SPI interface, which supports 18(24), 16 and 12 bit color modes. 16 and 12 bit color modes produce higher frame rate due to the lower color bandwidth.
I am struggling with an array. It's a simple array containing rgb bitmap information, as retrieved via the opencv 2 imread method. Its dimensions are (x,y,3).
I am familiar with the numpy.ndarray.flatten() function which works for 1 to 1 24 bit rgb conversion for serial transmission, but when the rgb data needs to be converted to 16 or 12 bit words, it's much easier and faster to have two 1-dimensional arrays (or lists) with (r,g,b) and (b,g,r) tuples to work with. I've tried reading values in the right order from the matrix and dumping them into a list with tuples, even converting directly from the matrix but in standard python code this is dead slow, not achieving more than 1 frame (240x240 RGB) per 3 or 4 seconds on a raspberry pi 4B.
Who can help me with the correct function to speed up the color conversion? Thank you.
P.S. this is to transmit raw color data to a small LCD display on an SPI interface, which supports 18(24), 16 and 12 bit color modes. 16 and 12 bit color modes produce higher frame rate due to the lower color bandwidth.