OpenCV获取视频参数(Python/C++)

Python

import cv2

video = cv2.VideoCapture(video_path)

width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = int(video.get(cv2.CAP_PROP_FPS))

print("Height x Width: {} x {} | FPS: {}".format(height, width, fps))

C++

cv::VideoCapture cap(video_path);

int N_frame = cap.get(cv::CAP_PROP_FRAME_COUNT);
int width = cap.get(cv::CAP_PROP_FRAME_WIDTH);
int height = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
double fps = cap.get(cv::CAP_PROP_FPS);

参考

posted @ 2022-10-07 14:28  达可奈特  阅读(107)  评论(0编辑  收藏  举报