Use National instruments Labview combined with IMAQ vision builder and it will pretty much build the code for you
. I use this software to do much more complex stuff for my senior design project. You can get it to callibrate and correct the acquired image for distortion, detect a small red circle etc etc.