【发布时间】:2020-01-19 20:37:00
【问题描述】:
是否可以在 python 中使用 opencv 从 LIVE 视频中提取帧。 我正在尝试为文本识别软件编写代码。使用 opencv 和 tesseract 但我无法让 tesseract 审查视频,除非它在帧中。
【问题讨论】:
-
是的,有可能
标签: python opencv video frames
是否可以在 python 中使用 opencv 从 LIVE 视频中提取帧。 我正在尝试为文本识别软件编写代码。使用 opencv 和 tesseract 但我无法让 tesseract 审查视频,除非它在帧中。
【问题讨论】:
标签: python opencv video frames
伙计,您需要提取每个视频帧并将其解析为 cv Mat。这是一个读取 mp4 视频、提取每一帧并将其转换为 OpenCV 矩阵的 sn-p 代码(在 C++ 中):
// 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++ 实现,我之前已经为 OpenCV 的视频 io 定义#included。
【讨论】: