Если вам нужны каналы rgb изображения, представленного массивом numpy, вы можете использовать:
b,g,r = cv2.split(frame)
или:
b = frame[:,:,0]
g = frame[:,:,1]
r = frame[:,:,2]
Таким образом, вы можете изменить свою функцию:
def webcam_func(cap, s_W, s_H):
# Capture frame by frame
ret, frame_one = cap.read()
if ret:
# seperate the height, width and depth of the array
arr_height = (frame_one.shape[0])
arr_width = (frame_one.shape[1])
arr_rgb = (frame_one.shape[2])
green_frame = frame_one[:,:, 1] #This will return the green channel
# flip the frame
frame_flip = np.rot90(green_frame)
# create a pygame surface and then scale the surface
webcam_frame = pyg.surfarray.make_surface(frame_flip)
webcam_frame = pyg.transform.scale(webcam_frame, (s_W, s_H))
return(webcam_frame)