We did something similar with some OpenCV code our team wrote and published called Trackerbox2.
https://github.com/FRC2706/TrackerBox2
The Pi 2 is set up via scripts to start trackerbox2 when it powers on. It waits for the IP camera to be available by pinging it first.