在python中使用opencv从实时视频中提取帧是可能的吗?我正在试着写一个文本识别软件的代码。使用opencv和tesseract,但我无法让tesseract查看视频,除非它是在帧中。
发布于 2020-01-20 08:27:06
我的人,你需要提取每个视频帧,并将其解析为一个简历垫。以下是读取mp4视频、提取每一帧并将其转换为OpenCV矩阵的代码片段(用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++实现,我之前已经包含了# For OpenCV的视频io定义。
https://stackoverflow.com/questions/59814168
复制相似问题