test(dock_pattern_detector): taped target next to an identical untaped one
Trolley (tape_legs all and entry) and V plate: with tape on, the taped target is picked and the untaped one is rejected by the tape gate, whichever side it stands on. Two fully taped carts still fail as ambiguous; two taped V plates pick the higher confidence without an ambiguity check. Risk characterised: one stray bright ray per bare leg lets a bare cart through with tape_min_points 1 (scene becomes ambiguous); tape_min_points 2 picks the taped cart.
This commit is contained in:
@@ -722,6 +722,85 @@ TEST(VPatternMatcher, TapeConfirmsAPlateThatCarriesIt)
|
||||
EXPECT_GT(d.tape_points[1], 1u);
|
||||
}
|
||||
|
||||
TEST(VPatternMatcher, TapePicksTheTapedPlateOverTheBetterUntapedShape)
|
||||
{
|
||||
std::vector<Segment> world = vPlate(1.20, kHalf, kWing);
|
||||
std::vector<Segment> other = vPlate(1.60, kHalf, kWing);
|
||||
for (Segment& s : other)
|
||||
{
|
||||
s.ay += 0.90;
|
||||
s.by += 0.90;
|
||||
}
|
||||
world.insert(world.end(), other.begin(), other.end());
|
||||
|
||||
Rig shape_rig;
|
||||
ASSERT_TRUE(shape_rig.ok_) << shape_rig.error_;
|
||||
const Detection shape = shape_rig.run(world);
|
||||
ASSERT_TRUE(shape.valid) << shape.reason;
|
||||
ASSERT_GE(shape.candidate_count, 2u);
|
||||
|
||||
// Dán tấm thua khi chỉ xét hình; tấm thắng hình giữ nguyên không dải.
|
||||
const bool near_won = shape.apex_y < 0.45;
|
||||
std::vector<Segment> tapes = vPlateTapes(near_won ? 1.60 : 1.20, kHalf, kWing, kTapeWidth);
|
||||
if (near_won)
|
||||
{
|
||||
for (Segment& s : tapes)
|
||||
{
|
||||
s.ay += 0.90;
|
||||
s.by += 0.90;
|
||||
}
|
||||
}
|
||||
|
||||
Rig tape_rig(vTapeProfile());
|
||||
ASSERT_TRUE(tape_rig.ok_) << tape_rig.error_;
|
||||
const Detection d = tape_rig.run(world, tapes);
|
||||
ASSERT_TRUE(d.valid) << d.reason;
|
||||
EXPECT_NEAR(d.apex_x, near_won ? 1.60 : 1.20, 0.02);
|
||||
EXPECT_NEAR(d.apex_y, near_won ? 0.90 : 0.0, 0.02);
|
||||
EXPECT_EQ(d.candidate_count, 1u);
|
||||
}
|
||||
|
||||
TEST(VPatternMatcher, TwoTapedPlatesChooseTheHigherConfidenceWithoutAmbiguityFailure)
|
||||
{
|
||||
std::vector<Segment> world = vPlate(1.20, kHalf, kWing);
|
||||
std::vector<Segment> other = vPlate(1.60, kHalf, kWing);
|
||||
std::vector<Segment> near_tapes = vPlateTapes(1.20, kHalf, kWing, kTapeWidth);
|
||||
std::vector<Segment> far_tapes = vPlateTapes(1.60, kHalf, kWing, kTapeWidth);
|
||||
for (Segment& s : other)
|
||||
{
|
||||
s.ay += 0.90;
|
||||
s.by += 0.90;
|
||||
}
|
||||
for (Segment& s : far_tapes)
|
||||
{
|
||||
s.ay += 0.90;
|
||||
s.by += 0.90;
|
||||
}
|
||||
world.insert(world.end(), other.begin(), other.end());
|
||||
|
||||
Rig rig(vTapeProfile());
|
||||
ASSERT_TRUE(rig.ok_) << rig.error_;
|
||||
const Detection near = rig.run(world, near_tapes);
|
||||
const Detection far = rig.run(world, far_tapes);
|
||||
ASSERT_TRUE(near.valid) << near.reason;
|
||||
ASSERT_TRUE(far.valid) << far.reason;
|
||||
ASSERT_EQ(near.candidate_count, 1u);
|
||||
ASSERT_EQ(far.candidate_count, 1u);
|
||||
|
||||
near_tapes.insert(near_tapes.end(), far_tapes.begin(), far_tapes.end());
|
||||
const Detection d = rig.run(world, near_tapes);
|
||||
ASSERT_TRUE(d.valid) << d.reason;
|
||||
// Khác bộ dò xe, bộ dò V nhận cả hai rồi chọn điểm tin cao nhất, không báo ambiguous.
|
||||
EXPECT_GE(d.candidate_count, 2u);
|
||||
EXPECT_DOUBLE_EQ(d.confidence, std::max(near.confidence, far.confidence));
|
||||
if (near.confidence != far.confidence)
|
||||
{
|
||||
const bool near_wins = near.confidence > far.confidence;
|
||||
EXPECT_NEAR(d.apex_x, near_wins ? 1.20 : 1.60, 0.02);
|
||||
EXPECT_NEAR(d.apex_y, near_wins ? 0.0 : 0.90, 0.02);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(VPatternMatcher, TapeRejectsAVOfTheRightShapeThatCarriesNoTape)
|
||||
{
|
||||
// Đây là lý do tồn tại của cả tính năng. Hình ở đây ĐÚNG hoàn hảo — cùng góc, cùng chiều dài
|
||||
|
||||
Reference in New Issue
Block a user