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)
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)