I have a FPV (First Person View) receiver that shows receiving frames from a FPV camera mounted on a drone. When the transmitter is working, receiver shows a camera view. Otherwise, if connection is lost or the transmitter is not working, it shows noise frames.
The noise frames have random patterns (sometimes with more white pixels and sometimes with more black pixels). I want to detect those noise frames using OpenCV in Python in an efficient way. I know that OpenCV has a method called cv2.fastNlMeansDenoisingColored()
. But in this case, I want to detect the noise frames not noise in each frame.
A sample of noise frames is attached:
Another noise frame example:
A valid frame (that could be anything):
Given the assumptions, that your valid video frames have at least a certain amount of color information, and that your noise frames are more or less black and white, there might be a simple approach using the saturation channel from the HSV color space.
cv2.cvtColor
.cv2.calcHist
.0.05
.0.5
, then at least fifty percent of all pixels have a saturation of at least0.05
, so this frame seems to be a valid frame. (Adapt the thresholds, if needed.)The visualization outputs (in the order as presented in the question):
And, the main output:
Removing the whole visualization stuff, the
is_valid
call needs less than 0.01 seconds per image on my machine. Not sure, which hardware you have when doing your recordings, but maybe this approach is also suitable for some "real-time" processing with a sufficient frame rate.One last remark: I tried to get rid of the OpenCV histogram, and calculate the percentage directly using NumPy, but that took more time than the presented approach. Strange.
Hope that helps!