Detect Slow Gradual Change in Background with Live Video and Python 3?
Hello everyone. How can I go about detecting slow gradual change in a live video? I am experienced with writing Python OpenCV code for motion detection, but not for slow gradual change in live video. I would like to write a Python OpenCV script to detect smoke build-up in a home.
Here is what I think I need help with:
- Create and initialize a bool variable "frameChange = False"
- Recognize and remember the initial frames of the live video from cv2.VideoCapture().
- Read the current frame, and compare to the initial frames.
- If the initial frame and the current frame differ by 25%, then frameChange = True.
I'm thinking I can get the average pixel value for the initial frame, and compare that value to the average pixel value of the current frame. If there are any other ideas, I'd be very grateful.
Are you familiar with the
absdiff
function?Hello sjhalayka. So I'm thinking I can do something like: absdiff(initialFrame, currentFrame) . Is this correct?
Actually,
absdiff
takes three parameters in C++:For Python, it's