You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
799 B
Python
31 lines
799 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
'''
|
|
@File : prediction.py
|
|
@Time : 2023/07/26
|
|
@Author : Fpt
|
|
'''
|
|
import cv2
|
|
from ultralytics import YOLO
|
|
|
|
def process_video(input_video_path):
|
|
cap = cv2.VideoCapture(input_video_path)
|
|
frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
|
|
|
# 遍历视频帧
|
|
while cap.isOpened():
|
|
success, frame = cap.read()
|
|
if success:
|
|
|
|
return frame, frame_width, frame_height, fps
|
|
else:
|
|
break
|
|
|
|
# 释放视频捕获对象和输出视频对象
|
|
cap.release()
|
|
|
|
if __name__ == '__main__':
|
|
video = r"E:\git-Xznsh\XZNSH-Code-AI\xznsh_flow2\video\0711-1_3_01_0.avi"
|
|
process_video(video) |