Skip to content

Commit cf5d83f

Browse files
committed
update get_yolo_box(). if multiple objects have the same label, choose the one with the highest score. show the score on the overlay.
1 parent 4b071b4 commit cf5d83f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,25 @@ ImageFloatBox get_yolo_box(
14511451
yolo_detector.detect(snapshot);
14521452

14531453
ImageFloatBox target_box{-1, -1, -1, -1};
1454+
double target_score = 0;
14541455
for (YOLOv5Session::DetectionBox detected_box : detected_boxes){
14551456
ImageFloatBox box = detected_box.box;
14561457
std::string label = yolo_detector.session()->label_name(detected_box.label_idx);
1458+
double score = detected_box.score;
1459+
std::string score_string = std::to_string(std::round(score * 100.0) / 100.0);
1460+
size_t end = score_string.find_last_not_of('0');
1461+
if (end != std::string::npos){
1462+
score_string.erase(end + 1); // remove trailing zeros
1463+
}else{
1464+
score_string.clear();
1465+
}
1466+
std::string label_score = label + ": " + score_string;
14571467
if (target_label == label){
1458-
target_box = box;
1459-
overlays.add(COLOR_RED, box, label);
1468+
overlays.add(COLOR_RED, box, label_score);
1469+
1470+
if (score > target_score){
1471+
target_box = box;
1472+
}
14601473
}else{
14611474
overlays.add(COLOR_BLUE, box, label);
14621475
}

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ void move_player_forward(
390390
);
391391

392392
// get the box of the target object
393+
// if multiple objects have the same label, choose the one with the highest score
393394
// return ImageFloatBox{-1, -1, -1, -1} if target object not found
394395
ImageFloatBox get_yolo_box(
395396
SingleSwitchProgramEnvironment& env,

0 commit comments

Comments
 (0)