Please see the following blog post for more details about this code
Selective Search for Object Detection (C++ / Python)