gpt4 book ai didi

python - Python视频到帧?

转载 作者:行者123 更新时间:2023-12-02 17:25:02 25 4
gpt4 key购买 nike

python是否可以使用opencv从实况视频中提取帧。
我正在尝试为文本识别软件编写代码。使用opencv和tesseract,但除非帧内显示,否则我无法让tesseract来检查视频。

最佳答案

我的男人,您需要提取每个视频帧并将其解析为cv Mat。这是一个片段代码(在C++中),用于读取mp4视频,提取每个帧并将其转换为OpenCV矩阵:

// Video input:
std::string filePath= "C://myPath//";
std::string videoName = "videoTest.mp4";

// Open video file:
cv::VideoCapture vid( filePath + videoName );

// Check for valid data:
if ( !vid.isOpened() ){
std::cout<<"Could not read video"<<std::endl;
//handle the error here...
}

//while the vid is opened:
while( vid.isOpened() ){

// Mat object:
cv::Mat inputFrame;

// get frame from the video
vid >> ( inputFrame);

// carry out your processing
//...

}

对于此C++实现,我以前#include了OpenCV的video io定义。

关于python - Python视频到帧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59814168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com