1 | initial version |
numpy stacking creates a copy because it's impossible to enlarge arrays in-place.
thus, you are copying the whole array for EVERY frame. that's O(n^2) complexity.
in your loop, you should append each frame to a simple python list (that_list.append(frame.flatten())
. when you are done, convert the list of arrays to one big array (video_matrix = np.array(that_list)
)