播放视频
import cv2 import numpy as np cap = cv2.VideoCapture('http://vodkgeyttp8.vod.126.net/cloudmusic/MjQ3NDQ3MjUw/89a6a279dc2acfcd068b45ce72b1f560/533e4183a709699d566180ed0cd9abe9.mp4?wsSecret=d77f9aeaadd53999e520ec03bbbc3626&wsTime=1595944539') while(cap.isOpened()): ret, frame = cap.read() canny = cv2.Canny(frame, 85, 255) height, width = canny.shape first_black_array = [] for x in range(width-1): # Slice the relevant column from the image # The image 'column' is a tall skinny image, only 1px thick column = np.array(canny[:,x:x+30]) # Use numpy to find the first non-zero value railPoint = np.argmax(column) cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()
-----------------------------------------------------------------------------------------------------------------------------------------