I have a stream of images coming in from a source which is, unfortunately a list of list of tuples of RGB values. I want to perform real-time processing on the image, but that code expects a Numpy array of shape (X,Y,3) where X and Y are the image height and width.
X = [[(R, G, B)...]] img_arr = np.array([*X]) The above works fine but takes nearly a quarter of a second with my images which is obviously too slow. Interestingly, I also need to go back the other direction after the processing is done, and that code (which seems to work) is not so slow:
imgout = map(tuple, flipped_image) Some relevant other questions:
imgoutis? Is it really a list of tuples? or just amapobject? For the original conversion what doesnp.array(X)do?imgout = map(tuple, flipped_image)seems fast because it's not actually doing what you want.