1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| enum SeatPosition { SEAT_DRIVER = 0, SEAT_FRONT_PASSENGER = 1, SEAT_REAR_LEFT = 2, SEAT_REAR_CENTER = 3, SEAT_REAR_RIGHT = 4 };
struct SeatRegion { float x_min; float x_max; float y_min; float y_max; };
std::map<SeatPosition, SeatRegion> kSeatRegions = { {SEAT_DRIVER, {0.05f, 0.35f, 0.10f, 0.60f}}, {SEAT_FRONT_PASSENGER, {0.65f, 0.95f, 0.10f, 0.60f}}, {SEAT_REAR_LEFT, {0.05f, 0.35f, 0.65f, 0.95f}}, {SEAT_REAR_CENTER, {0.35f, 0.65f, 0.65f, 0.95f}}, {SEAT_REAR_RIGHT, {0.65f, 0.95f, 0.65f, 0.95f}} };
SeatPosition DetermineSeatPosition( const BoundingBox& bbox, const CameraConfig& config) { float center_x = bbox.x + bbox.width / 2.0f; float center_y = bbox.y + bbox.height / 2.0f; float normalized_x = center_x / config.image_width; float normalized_y = center_y / config.image_height; for (const auto& [seat, region] : kSeatRegions) { if (normalized_x >= region.x_min && normalized_x <= region.x_max && normalized_y >= region.y_min && normalized_y <= region.y_max) { return seat; } } return SEAT_DRIVER; }
|