/motion-detector

Motion detection only with image processing by opencv-python. Ideal for optimizing systems where there must be processing when there is any movement identified.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Motion Detector

The system is primarily intended to identify movements by the difference between two frames. It is a method of generating pure image handling by opencv-python. The motion detection method can be used as a trigger to run another script with a high use of computational resources. An example would be a facial recognition project for opening doors. Letting the system look for a face every frame is not feasible. Therefore, using the motion-detector, it is possible to activate this detection only when the motion-detector authorizes it, reducing unnecessary computational consumption.

MotionDetection()

The main system has more informational purposes about image processing. The class can return the visualization of the internal workings of the image treatment with the GenerateStacking() function in addition to recording the videos.

Function name Description
init Start the class and define directory (video/camera) and also the detection sensitivity
stack_images() Static Method to generate a generic image stack
Frames() Starts detection of frames from file or video device. It must be inside a loop key to run correctly. USAGE INSIDE A LOOP
Treatament() Treatment of frame_1 and frame_2 for motion detection. Carefully read each parameter specification to get a better result. USAGE INSIDE A LOOP
BoundingBoxDetection() Generates a bounding box where there is some movement and emits sound. USAGE INSIDE A LOOP
GenerateStacking() It will generate an image stack containing each imaging process needed to identify a detection. USAGE INSIDE A LOOP
bool() Suitable function to know when there is a motion detection. USAGE INSIDE A LOOP
ShowVideo() Shows a window containing the processed images. USAGE INSIDE A LOOP
RecordVideo() Function to record each frame. USAGE INSIDE A LOOP
DestroyCap() Releases the camera from using video and destroys all windows generated by opencv

GenerateStacking()

OptimizedDetection()

The optimized method does not have return methods for displaying images and does not generate numerous variables, reducing the use of computational resources. The focus of this project is the optimized method. It can be used to activate detection and image processing scripts only when needed.

Function name Description
init Start the class and define directory (video/camera) and also the detection sensitivity
Frames() Starts detection of frames from file or video device. It must be inside a loop key to run correctly. USAGE INSIDE A LOOP
Treatment() Treatment of frame_1 and frame_2 for motion detection. Carefully read each parameter specification to get a better result. USAGE INSIDE A LOOP
bool Suitable function to know when there is a motion detection. USAGE INSIDE A LOOP
DestroyCap() Releases the camera from using video and destroys all windows generated by opencv

The only return from the methods of the OptimizedDetection() class is a Boolean value whether or not there is any motion detected. This way, it is more intuitive and easier to integrate the script into other systems.