Skip to content

Shankar2442/MovingObjectDetection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

MovingObjectDetection

Moving object detection is a technique used in computer vision and image processing. Multiple consecutive frames from a video are compared by various methods to determine if any moving object is detected. Moving objects detection has a wide range of applications like video surveillance, activity recognition, road condition monitoring, airport safety, monitoring of protection along marine border, etc. By acting segmentation among moving objects and stationary area or region, the moving objects motion could be tracked and thus could be analyzed later. To achieve this, consider a video is a structure built upon single frames, moving object detection is to find the foreground moving target(s), either in each video frame or only when the moving target show the first appearance in the video.

Steps Involved

  1. Extract Background in Video Input :

    * Capturing the Video in 'cap' and extract 30 random frames and store the selected frames in an array
    
    * Calculating median and average frames, for better outlier removal
    
  2. Processing a Frame :

     * Studying a single frame separately (first frame)
     
     * Converting the Median and sample image to grayscale
    
  3. Background Removal :

     * Performing Absolute Difference between gray_frame_sample and gray_frame_median to get the moving objects only, with the background removed
    
  4. Blurring :

     * Performing Gaussian Blur for noise reduction and to simplify edge detection  
    
  5. Binarizing the image - Thresholding :

      * Performing Threshold and OTSU Threshold to bring the moving objects out clearly
    
  6. Countour and Boundary Boxes :

      *  Creating contours on the thresholded frame. Contours are curves joining continuous points in an image with same color intensity. We shall use
         cv2.RETR_EXTERNAL to fing the extreme outer contours and cv2.CHAIN_APPROX_SIMPLE to remove the redundant points.
        
      * Creating Bounding Boxes (rectangular) for identified contours and display them on frame_sample
    
  7. Compiling frames together for processing video :

       * Declaring output video to be created
       * Creating cap and getting total frame count
       * Running a Loop to go through all frames and process the Video
    

Output :

To see the output video, go to the media file and check the output video