You've seen in the movies, and probably heard about it in real life, where somebody lies down between the rails, a train passes over them, and they come to no harm? Well, this equipment is why. It's called a "dragging equipment detector". If anything contacts that bar between the nearer two yellow posts while a train is passing by, the radio in the box at the top left will announce "Dragging equipment at car ###". The equipment at the next two yellow posts counts cars. The conductor can then check underneath his train to find out what is the matter.
Dragging equipment can be very bad for the ties, spikes, and crossings. Do you really want to find that your train left a 100 mile-long gouge in every tie and crossing?? Pretty sure not.
The white boxes with holes are hotbox detectors. They're looking for overheated bearings or wheels. Sometimes brakes will stick and leave the wheels locked, sliding for mile after mile and getting just a bit hot.