Please see the following blog post for more details about this code Automatic Red Eye Remover using OpenCV (C++ / Python)