ret, frame = cap.read() cv2's read function

parameter

  • no

return value

  • ret Boolean (True or False), which means whether the picture has been read
  • frame represents the captured data of a frame of pictures, which is a three-dimensional array

Instance

    ret, frame = cap.read()  #读取一帧图像
    # ret 读取了数据就返回True,没有读取数据(已到尾部)就返回False
    # frame 返回读取的视频数据 ——  一帧数据是一个三维数组

        Where ret is a boolean value, if the read frame is correct, it returns True, if the file is read to the end, its return value is False. Frame is the image of each frame, which is a three-dimensional matrix.

Read a frame of picture

cap.set(cv2.CAP_PROP_POS_FRAMES,50)  #设置要获取的帧号,这是第51帧(下标从0开始)
ret, frame = cap.read()              #读取一帧图像

Guess you like

Origin blog.csdn.net/qq_43657442/article/details/109277467