OpenCV functions freezes the game

I am developing a game that includes the OpenCV library. But whenever I call a function such as findContours and shape context matching my app will freeze for a few seconds and return back in after doing some heavy calculations. I’m planning to launch a pre loader scene while the app is busy doing some background processes but I’m not sure on how to properly implement this on code.

By the way I’m using cocos2d-x 3.8. Any help would be appreciated. thanks’

Anyone? Please help.