Manually implementing bootstrapping in OpenCV