Search code examples
c++opencvvideovideo-processinglight

OpenCV: Detecting seizure-inducing lights in a video?


I have been working on an algorithm which can detect seizure-inducing strobe lights in a video.

Currently, my code returns virtually every frame as capable of causing a seizure (3Hz flashes).

My code calculates the relative luminance of each pixel and sees how many times the luminance goes up then down, etc. or down then up, etc. by more than 10% within any given second.

Is there any way to do this without comparing each individual pixel within a second of each other and that only returns the correct frames.

An example of what I am trying to emulate: https://trace.umd.edu/peat


Solution

  • The common approach to solving this type of problems is to convert the frames to grayscale and then construct a cube containing frames from a 1 to 3 seconds time interval. From this cube, you can extract the time-varying characteristics of either individual pixels (noisy), or blocks (recommended). The resulting 1D curves can first be observed manually to see if they actually show the 3Hz variation that you are looking for (sometimes, these variations are either lost or distorted because of the camera's auto exposure settings). If you can see it, they you should be able to use FFT to isolate and detect it automatically.