Finding flashing lights from video

6 visualizzazioni (ultimi 30 giorni)
Matthew Kennedy
Matthew Kennedy il 25 Apr 2022
Risposto: Ayush il 15 Dic 2023
So I have a video and I want to detect the flashing lights (if any) inside the video. I want to also determine there frequencies so my idea is to like compute the FFT of a small section of frames and use that to determine if a light source is flashing, however, I'm not sure how to apply the FFT to a series of images in matlab. I have only ever used it for filtering

Risposte (1)

Ayush
Ayush il 15 Dic 2023
Hi Matthew,
I understand that you want to find if there is any flashlight in a video and apply FFT to a series of images in MATLAB.
You can apply the FFT to analyse the temporal frequency content of the video frames. The steps described below will help in better understanding:
  1. Read the video, using “VideoReader” function and extract frames for further processing.
  2. As you mentioned you would like to compute FFT of a small section of frames, thus segregate your frames in small groups.
  3. Convert the frames to grayscale, using “rgb2gray” function. This will simplify the analysis and intensity changes can be detected.
  4. Apply FFT analysis using “fft” function on the selected frames, thus obtaining the frequency domain of the frames.
  5. Analyse the frequencies from the FFT, observe the peaks in the frequency domain representation to determine the frequencies associated with the flashing lights.
Refer the following pseudo code for better understanding:
% Step 1: Read the video
videoFile = 'your_video_file.mp4';
videoObj = VideoReader(videoFile);
% Step 2: Frame selection
startFrame = 100; % Start frame index
endFrame = 200; % End frame index
selectedFrames = read(videoObj, [startFrame, endFrame]);
% Step 3: Convert frames to grayscale
grayFrames = rgb2gray(selectedFrames);
% Step 4: FFT analysis
numFrames = size(grayFrames, 4);
for i = 1:numFrames
frame = double(grayFrames(:, :, i));
fftResult = fft(frame);
% Perform frequency analysis and identify dominant frequencies
% Store or visualize the FFT results for further analysis
end
% Step 5: Frequency analysis
% Analyze the FFT results to identify dominant frequencies
% Step 6: Detection and visualization
% Based on frequency analysis, determine the presence of flashing lights and visualize the results
Refer the links below for more information on “VideoReader”, “rgb2gray”, “fft” functions and “Fourier Transform” related documentation:
Regards,
Ayush

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by