I'm not sure if "object recognition" is the correct phrase for this, as that has connotation of computer vision etc but what I am after in theory is far more simple.
Basically I have a train set. The trains go along the track. Currently I have 3 trains, but I could get more in future. I guess 8 would be a practical limit.
Currently I can quite easily detect when a train goes down a particular piece of track by having a simple IR sensor mounted trackside - this then sends a signal to my microcontroller which acts accordingly changing lights or whatever.