It’s been almost 2 years since I’ve asked this question and I think it’s time to answer it: the source code that implements this filter using OpenCV can be found in my GitHub repo.
The implementation is based on the documentation of Adobe Flash DisplacementMapFilter.
There’s another tutorial I recommend people to read: Psyarkâs DisplacementMapFilter Tutorial. It’s old but accurate.
The result: