新版反陀螺。

This commit is contained in:
xinyang
2019-08-03 19:00:46 +08:00
parent cdd6716214
commit ef32b54761
18 changed files with 148 additions and 73 deletions

View File

@@ -147,7 +147,14 @@ bool ArmorFinder::findArmorBox(const cv::Mat &src, ArmorBox &box) {
armor_box.id = c;
}
}, armor_boxes.size());
sort(armor_boxes.begin(), armor_boxes.end());
sort(armor_boxes.begin(), armor_boxes.end(), [&](const ArmorBox &a, const ArmorBox &b){
if(last_box.rect != cv::Rect2d()){
return getPointLength(a.getCenter()-last_box.getCenter()) <
getPointLength(b.getCenter()-last_box.getCenter());
}else{
return a < b;
}
});
if(armor_boxes[0].id != 0){
box = armor_boxes[0];
}