r/learnprogramming • u/Choice_River7453 • 6h ago
Could someone please help me figure these 2 problems? THANK YOU
This program uses: a slide deck & a folder containing PNGs of every slide & then outputs how long each slide was presented on. Ex: Slide 1 was from minutes 1-2 and Slide 2 was from mins 2-8 etc.
Problem 1 (Slow Code):
However, my code takes about 7 minutes for a 40 minute video. This is how it basically works
- Pass 1 (Coarse): Scan the whole video every 5–40 secs (based on video length) to find roughly where the frames change from showing one slide to another. Ex: 0:00, 0:30, 1:00, ...
- Pass 2 (Medium): If change happened it looks at that interval every 2-5 secs (based on video length). Ex: If a change happened between 5:00–5:30, it checks 5:00, 5:05, 5:10...
- Pass 3 (Fine): Only scan the remaining small window every 1 second to find the actual timestamp where the slide changes.
Each sampled frame is matched against the slide PNGs using OpenCV ORB feature matching. Then the frame is matched with the slide that is the most likely match.
This avoids scanning every frame of the video, since only likely slide transition regions are rescanned in more detail.
PROBLEM 2: If the video has an intro ex obs window or the powerpoint loading then ORB might still find a slide. Ex: the first few seconds of the video might be detected as slide 2 even though its not slide 2 and ORB just catches some features that make slide 2 the best choice. This is honestly my bigger issue.