# import cv2
# import time
#
# interval = 0.1  # 捕获图像的间隔，单位：秒
# num_frames = 500  # 捕获图像的总帧数
# out_fps = 24  # 输出文件的帧率
#
# # VideoCapture(0)表示打开默认的相机
# cap = cv2.VideoCapture(0)
#
# # 获取捕获的分辨率
# size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),
#         int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
#
# # 设置要保存视频的编码，分辨率和帧率
# video = cv2.VideoWriter(
#     "time_lapse.avi",
#     cv2.VideoWriter_fourcc('M','P','4','2'),
#     out_fps,
#     size
# )
#
# # 对于一些低画质的摄像头，前面的帧可能不稳定，略过
# for i in range(42):
#     cap.read()
#
# # 开始捕获，通过read()函数获取捕获的帧
# try:
#     for i in range(num_frames):
#         _, frame = cap.read()
#         video.write(frame)
#
#         # 如果希望把每一帧也存成文件，比如制作GIF，则取消下面的注释
#         # filename = '{:0>6d}.png'.format(i)
#         # cv2.imwrite(filename, frame)
#
#         print('Frame {} is captured.'.format(i))
#         time.sleep(interval)
# except :
#     # 提前停止捕获
#     print('Stopped! {}/{} frames captured!'.format(i, num_frames))
#
# #释放资源并写入视频文件
# video.release()
# cap.release()





import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    if ret == True:
        # Our operations on the frame come here
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        print(frame)

        # Display the resulting frame
        cv2.imshow('frame',gray)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
b838e017276e0e357a19c4557b35866f7b782867
<mask token>

<mask token>
while True:
    ret, frame = cap.read()
    if ret == True:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        print(frame)
        cv2.imshow('frame', gray)
        if cv2.waitKey(1) & 255 == ord('q'):
            break
    else:
        break
cap.release()
cv2.destroyAllWindows()

<mask token>
cap = cv2.VideoCapture(0)
while True:
    ret, frame = cap.read()
    if ret == True:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        print(frame)
        cv2.imshow('frame', gray)
        if cv2.waitKey(1) & 255 == ord('q'):
            break
    else:
        break
cap.release()
cv2.destroyAllWindows()

import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while True:
    ret, frame = cap.read()
    if ret == True:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        print(frame)
        cv2.imshow('frame', gray)
        if cv2.waitKey(1) & 255 == ord('q'):
            break
    else:
        break
cap.release()
cv2.destroyAllWindows()

# import cv2
# import time
#
# interval = 0.1  # 捕获图像的间隔，单位：秒
# num_frames = 500  # 捕获图像的总帧数
# out_fps = 24  # 输出文件的帧率
#
# # VideoCapture(0)表示打开默认的相机
# cap = cv2.VideoCapture(0)
#
# # 获取捕获的分辨率
# size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),
#         int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
#
# # 设置要保存视频的编码，分辨率和帧率
# video = cv2.VideoWriter(
#     "time_lapse.avi",
#     cv2.VideoWriter_fourcc('M','P','4','2'),
#     out_fps,
#     size
# )
#
# # 对于一些低画质的摄像头，前面的帧可能不稳定，略过
# for i in range(42):
#     cap.read()
#
# # 开始捕获，通过read()函数获取捕获的帧
# try:
#     for i in range(num_frames):
#         _, frame = cap.read()
#         video.write(frame)
#
#         # 如果希望把每一帧也存成文件，比如制作GIF，则取消下面的注释
#         # filename = '{:0>6d}.png'.format(i)
#         # cv2.imwrite(filename, frame)
#
#         print('Frame {} is captured.'.format(i))
#         time.sleep(interval)
# except :
#     # 提前停止捕获
#     print('Stopped! {}/{} frames captured!'.format(i, num_frames))
#
# #释放资源并写入视频文件
# video.release()
# cap.release()





import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    if ret == True:
        # Our operations on the frame come here
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        print(frame)

        # Display the resulting frame
        cv2.imshow('frame',gray)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()