0

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.

asked Jan 19, 2020 at 20:37
1
  • 3
    yes it is possible Commented Jan 19, 2020 at 20:38

1 Answer 1

1

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.

answered Jan 20, 2020 at 0:27
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this will really help.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.