Is it possible in python to extract frames from a LIVE video using opencv. I am trying to write code for a text recognition software. Using opencv and tesseract but I cant get tesseract to review the video unless it is in frames.
1 Answer
My man, you need to extract each video frame and parse it as a cv Mat. Here's a snippet code (in C++) that reads an mp4 video, extracts each frame and converts it to an OpenCV matrix:
// 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 //... } For this C++ implementation, I've previously #included for OpenCV's video io definitions.
1 Comment
Bradley C
Thanks this will really help.