First you need to choose your pins, look up the attachInterrupt function and let us know which pins can be used on the mega, it is then very easy to modify this code, but first let us know what you have found out about the pins -
This project does something similar, It has an IR Transmitter fitted and the Arduino looks for the presence of the IR to count a lap, you want to look for the abscense of the IR to indicate a person, but the principle is the same -
You do not want to use the software servo library, at one time the standard servo library that comes with Arduino was limited to a small number of servos, but for years now it has been able to support 12, it is very well known, very well supported and very reliable. Best of all the standard library does not require you to call refersh every 50ms.
Here is an example you can use right now that drives 12 servos with the standard library -