cap=cv.VideoCapture(0)ifnotcap.isOpened():print("Cannot open camera")exit()"""
cap.get/set(proid) proid是0到18的数字每个数组表示一个视频的属性
https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get
"""# print('width {:.2f}'.format(cap.get(3)))
# print('height {:.2f}'.format(cap.get(4)))
# 不要把set写到循环里,会闪瞎
cap.set(3,320)cap.set(4,240)whileTrue:# Capture frame-by-frame
ret,frame=cap.read()ifret:# Our operations on the frame come here
frame=cv.cvtColor(frame,cv.COLOR_BGR2GRAY)# Display the resulting frame
cv.imshow('frame',frame)ifcv.waitKey(1)&0xFF==ord('q'):break# When everything done, release the capture
cap.release()cv.destroyAllWindows()
cap=cv.VideoCapture(path)whilecap.isOpened():# Capture frame-by-frame
ret,frame=cap.read()ifret:# Our operations on the frame come here
frame=cv.cvtColor(frame,cv.COLOR_BGR2GRAY)# Display the resulting frame
cv.imshow('frame',frame)ifcv.waitKey(1)&0xFF==ord('q'):breakelse:print("Can't receive frame (stream end?). Exiting ...")break# When everything done, release the capture
cap.release()cv.destroyAllWindows()