为什么在Atlas 200I DK A2无法打开视频
收藏回复举报
为什么在Atlas 200I DK A2无法打开视频
t('forum.solved') 已解决
新人帖
发表于2024-02-08 13:31:20
0 查看
import cv2

def play_video(video_path):
    # 使用OpenCV打开视频
    cap = cv2.VideoCapture(video_path, cv2.CAP_FFMPEG)
   
    # 检查视频是否成功打开
    if not cap.isOpened():
        print("Error: Could not open video.")
        return

    # 循环读取视频帧
    while True:
        ret, frame = cap.read()
        
        # 如果正确读取帧,ret为True
        if not ret:
            print("Error: Failed to read the video frame.")
            break

        # 显示帧
        cv2.imshow('Video', frame)

        # 按 'q' 退出
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # 释放视频对象
    cap.release()
    cv2.destroyAllWindows()

if __name__ == "__main__":
    video_path = "/root/Desktop/WP/Chinese_license_plate_detection_recognition/video/test2.mp4"
    play_video(video_path)

报错:cke_2107.png

我要发帖子