Update pptinypose_utils.cc

添加 py 范围限制, 避免 utils::DarkParse 内部出现数组越界
This commit is contained in:
ThinkWD
2024-01-29 19:16:19 +08:00
committed by GitHub
parent cfebd24dfc
commit cfd80e95a1

View File

@@ -101,7 +101,7 @@ void GetFinalPredictions(const std::vector<float>& heatmap,
coords[j * 2 + 1] = idx / heatmap_width; coords[j * 2 + 1] = idx / heatmap_width;
int px = int(coords[j * 2] + 0.5); int px = int(coords[j * 2] + 0.5);
int py = int(coords[j * 2 + 1] + 0.5); int py = int(coords[j * 2 + 1] + 0.5);
if (DARK && px > 1 && px < heatmap_width - 2) { if (DARK && px > 1 && px < heatmap_width - 2 && py > 1 && py < heatmap_height - 2) {
utils::DarkParse(heatmap, dim, &coords, px, py, index, j); utils::DarkParse(heatmap, dim, &coords, px, py, index, j);
} else { } else {
if (px > 0 && px < heatmap_width - 1) { if (px > 0 && px < heatmap_width - 1) {