Skip to main content
. 2019 Nov 28;19(23):5230. doi: 10.3390/s19235230
Algorithm 1 Moving Vessel Detection Algorithm
  • 1: 

    Phase 1—Initiate a background subtractor (GSOC algorithm from OpenCV (Open Source BSD Licence):

  • 2:   

    For the first 250 frames, convert each frame to 720 p resolution, convert to grayscale and blur;

  • 3:   

    Update the background model with the result from step 1.1.

  • 4: 

    Phase 2—Frame analysis of the video stream:

  • 5:   

    Convert the frame to 720 p resolution, convert to grayscale and blur;

  • 6:   

    If the frame is a multiple of 10, update the background model using it (for a stream of 30 frames per second; when streams have a different framerate, update the model using 3 frames per second).

  • 7:   

    For 1 frame per second, continue; otherwise, go to the analysis of the next frame;

  • 8:   

    Download the current background mask from the background model;

  • 9:   

    Search for edges in the background mask;

  • 10:   

    For each edge:

  • 11:      

    Calculate the bounding box;

  • 12:       

    Check the following conditions; if any of them is not met, proceed to the next edge analysis:

  • 13:            

    The bounding box is outside the negative area (the defined area on the scene for which no motion is detected);

  • 14:            

    The bounding box height is greater than the defined minimum value;

  • 15:            

    The bounding box width is greater than the defined minimum value;

  • 16:            

    The ratio of height to width of the envelope is less than the defined value;

  • 17:            

    The bounding box area is greater than the defined minimum value;

  • 18:            

    Check that the bounding box does not contain water using the Water Detection Algorithm (this algorithm detects the water area by checking the number and length of the edges).

  • 19:  

    Merge overlapping bounding boxes.

  • 20: 

    Phase 3—Write the bounding box list into the Temporary Buffer:

  • 21:  

    For each bounding box:

  • 22:      

    Calculate the percentage of intersection of the bounding box with the bounding box detected in the previous frame;

  • 23:      

    Calculate the distance between the centre of the box and the boxes from the previous round;

  • 24:      

    Calculate the angle between the centre of the box and the boxes from the previous round;

  • 25:      

    Assign the current bounding box the ID number of the bounding box from the previous round with which the intersection area is the largest—if there is no such area, select the bounding box at a distance not greater than 1.5 from the current bounding box and with an angle difference not greater than the maximum value;

  • 26:      

    If the previous step failed to obtain the ID number, then create a new one;

  • 27:      

    Write the bounding box in the Temporary Buffer with the ID number.