How to skip similar frames

Hi., I am trying to make a program that detects the face without face mask and write it to the folder in jpg format.

I successfully did it., but it writes all the very similar frames of the same person to disk and after 1 minute of detection inference from video file it is about 389 images saved, but originally I need to save about 10 images from the whole video to the disk.

My question is how to drop/skip the writing the similar frames to the hard drive? What is the best technic for this purpose?

only write a picture if you haven’t written any within the last 5 seconds?

  • keep a timestamp.
  • whenever you imwrite a picture, update the timestamp.
  • whenever you want to imwrite a picture, check the timestamp, and if it’s too recent, don’t imwrite the picture.

or you could apply face landmark detection, estimate the head’s pose, and compare that to the head poses you already have, and if it’s facing a similar direction, don’t imwrite the picture.

1 Like

Thank you very much for reply! I will try to follow the first approach it seems the most easy to implement., the second is very interesting but rather difficult

Could you please share a code example of this approach? Thank you

this isn’t a free code writing service. certainly not for something that is purely programming, and trivial programming, with no crucial involvement of OpenCV.

you should be able to write that code.

you’re on your own.

1 Like

Thank you for a help