解决opencv打开视频上下翻转问题

#1.加载视频 
import cv2
import numpy as np
cap = cv2.VideoCapture('./cheliang.MP4')

#循环读取视频
while True:
    ret, frame = cap.read()
    if ret == True:
       
        cv2.imshow('video', frame)

    #一毫秒一帧    
    key = cv2.waitKey(1)
    if key == 27:
        break       
cap.release()
cv2.destroyAllWindows()

这是源代码,解决opencv打开视频上下翻转问题_第1张图片

 

只需要在if ret == True下面加一句frame = cv2.flip(frame, 0)

#1.加载视频 
import cv2
import numpy as np
cap = cv2.VideoCapture('./cheliang.MP4')

#循环读取视频
while True:
    ret, frame = cap.read()
    if ret == True:
        frame = cv2.flip(frame, 0)
        cv2.imshow('video', frame)

    #一毫秒一帧    
    key = cv2.waitKey(1)
    if key == 27:
        break       
cap.release()
cv2.destroyAllWindows()

@大榕树51 ,此问题由大榕树先生回答

你可能感兴趣的:(大数据)