Research Article

YOLOv5-Based Vehicle Detection Method for High-Resolution UAV Images

Algorithm 2

Adaptive clipping detection.
Input: Image, DetectSize
Output: PredictionBox
function Detect (img, detect_size)
 Nw,Nh,Sw,Sh = Adaptive_clipping(img.size, detect_size)
for h in range (Nh) do
  for w in range (Nw) do
   y3 = h Sh do
   y4 = h Sh + detect_size
   x3 = w Sw
   x4 = w Sw + detect_size
   clip_img = img[:,y3:y4,x3:x4]
   pred_clip = Model(clip_img)
   pred_clip[:,:,0] += x3
   pred_clip[:,:,1] += y3
   pred_all = Concat (pred_clip,pred_all)
  end for
  pred = Model(img)
  pred_all=Concat (pred, pred_all)
  pred_all=NMS (pred_all)
end for
return pred_all