Do undistort while live tracking
Problem:
The low cost camera used by PiVR creates distortion effects, especially at the edge:

Current solution
Currently, collected videos can be 'undistorted' post-hoc with good results

PiVR uses the opencv2 library to achieve this. An in-depth explanation can be found on their website: https://docs.opencv.org/master/dc/dbb/tutorial_py_calibration.html or better https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html
However, this can only be done post-hoc at the moment. Therefore the coordinates of animals at the edge of the image if real-time tracking has been done are off.
Proposed solution
I doubt we can run the opencv2 function on the whole image in real-time tracking: Too expensive to run it on the whole image!
Instead, it would be better to only apply the correction of the coordinates either to the small image, or even better, to the resulting coordinates (e.g. centroid, head and tail).
This will involve getting to the bottom of how exactly the opencv2.undistort function works to understand if it can be applied (or some derivative function therefore) only to a part of the image