| Algorithm 2. Copy-Paste Objects from Multiple Images |
|
Input: - ‘results’: Output of Algorithm 1 - ‘fallen_person_imgs’: List of fallen person images Output: - Augmented image |
|
For each ‘bg_img’ in ‘bg_imgs’ do Initialize an ‘occlusion_mask’ to 0 Iw, Ih = size of ‘bg_img’ Open corresponding file in ‘bg_txts’, read lines into ‘bg_lines’ For each ‘bg_line’ in ‘bg_lines’ do Update the corresponding ‘occlusion_mask’ to 255 If the section changes, then Update ‘heightmax’, ‘widthmax’, ‘heightmin’, ‘widthmin’, ‘areamax’ Create a ‘bonnet’ mask with Grounded-SAM If ‘’ > 0.5, then For each ‘fallen_person_img’ in ‘fallen_person_imgs’ do Break if you encounter the maximum paste object value during the loop Create a ‘fallen person’ mask with the YOLOv8x-seg Adjust position and size for fallen person within RoI Randomly rotate ‘fallen person’ with a probability of 0.25 Each ‘fallen person’ is flipped vertically and horizontally with a probability of 0.5 if ‘occlusion_mask’ exists at the current position, then continue Paste a ‘fallen person’ into the background image Apply alpha blending Save the augmented image |