I have used Pi Camera for detecting the object and then it moved automatically such that object remains in its frame. I followed multiple tutorials and this was a product of that. Reference will be mentioned below.
The camera movements are decided by servo mototors and servo mototrs move in such a way so that camera always keeps the object in its frame.