Just spitballing.
A VL6180X LIDAR sensor on the floorplate takes a range reading to the bottom of the follower. The range will vary as rounds are expended/inserted.
A load cell measures the follower spring tension through a load cell. Reading indicates rounds remaining.