I expect be not afternoon in the solution.
Prefer no aplied color sensor need and the cost.
It can utilize sensor magnetic. In the half case, box they are classified then in these was bonded a sheet of metal, divided in 4 quadrants. (Top/left. top/right, bottom/left bottom/right). And 02...