簡體   English   中英

調整圖像大小時以yolo格式調整邊界框

[英]Adjust bounding box in yolo format when resizing image

我正在嘗試調整圖像大小,但調整圖像大小還需要我更改邊界框值。 這是 yolo 格式x y 寬度 高度

當我調整特定寬度和高度的圖像大小時,在將圖像調整為 python 中的 temp_width 和 temp_height 后,將格式 xy 寬度高度的歸一化綁定框值轉換為新值的邏輯是什么

YOLO 格式確實是一個標准化的 bbox(又名邊界框)坐標/數據。

在這里,有明確的解釋如何獲取這些數據(以及 Pascal VOC)。
下面,您將找到獲取這些 Yolo 格式數據的代碼。
然后你就會明白,只要你使用縮放的圖像,你就沒有什么可改變的。

實際上,bbox 的標准化 x_center、y_center、box_width 和 box_height 坐標將根據圖像進行相應縮放。

但是如果你裁剪它們,那么你需要檢索 bbox 的 [x_topleft, y_topleft, box_width, box_height] 坐標,並使用該crop_image 的大小對其進行歸一化。

假設你有一個“bbox”:

bbox = np.array([x_topleft, y_topleft, box_width, box_height])
       
b_width = bbox[2,]
b_height = bbox[3,]
x_max = bbox[0,] + b_width
y_max = bbox[1,] + b_height

bbox[0,] = ((x_max + bbox[0,]) / 2)  / width
bbox[1,] = ((y_max + bbox[1,]) / 2)  / height
bbox[2,] = bbox[2,] / width
bbox[3,] = bbox[3,] / height
        
bobox = bbox[0,], bbox[1,], bbox[2,], bbox[3,] # normalized x_center, y_center, box_width and box_height

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM