What sensors to use to read gym machine selected weight
3 come to mind.

An IR encoder as RoyC mentioned. Paint the back or sides of the weights alternating white and black.

A camera as you already mentioned. OpenCV would make quick work of this. And You can do it at a distance without touching anything on the machine.

And the last option is an actual weight sensor. A load cell placed under the weights. When the selected weights are lifted, the load cell will show a negative change equal to the weight that was removed upwards.