numpy.core._internal.AxisError in test_video.py
Cying212Jack opened this issue · comments
If the frame picture in the video is gray, then the variable "frame" is 2 dimension-arrary in the first part.
This will cause an error when we want to combine two 2-d array in the second part as follow:
numpy.core._internal.AxisError: axis 2 is out of bounds for array of dimension 2.
-
first part
check = (frame[:,:,0] == frame[:,:,1])
if check.all():
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
-
second part
input_data = np.concatenate([frame, bg_model], 2)
Thanks for your suggestion!
Numpy provides useful functions to expand or reduce dimensions of an array:
np.squeeze()
np.expand_dims()
Free free to modify the code and pull requests!
Thanks again!