/VRMovie_inv_distorter

Correct distorted movie captured in SteamVR's mirror

Primary LanguagePythonMIT LicenseMIT

VRMovie_inv_distorter

Correct distorted movie captured in SteamVR's mirror.
OpenCV,OpenCV-ffmpeg,numpy and numba are needed.
This script fixes the distortion of recorded videos you record the screen of Display mirror of SteamVR.
Most VR devices have lenses to magnify image from screen but they also distorts images.
VR application distorts images in advance to compensate distortion by lenses.
When You record the window of SteamVR's Display mirror, pre-distorted images are recorded.
This script simulate post-distortion which is originally brought by lenses.

How to use
1.Record SteamVR's mirrored display. sample movie(distorted.mp4) is available.
2.put corrector.py and recorded movie(rename distorted.mp4) in the same folder.
3.run corrector.py, then you will get compensated movie. corrected.mp4 is compensated sample movie.

corrector.py assume that the post-distortion is defined (X,Y)= (x,y) * (a * r ** 4 + b * r ** 2 + c) where r ** 2 = (x ** 2 + y ** 2)
You can change coefficients, which are a,b and c ,to get better result.
If debug flag is true, script will give grid to original(distorted) movie. You can check the degree of compensation.
If guide flag is true, script will give grid to compensated movie. You can check whether compensated movie is not distorted.
While corrector.py is making compensated movie, it shows the frames of the movie.

This script is very simple, so you will find some to improve it.
I welcome your idea!