Use this to fix build errors:

    radius = std::min(radius, (int) sqrt((double) img.cols*img.cols + img.rows*img.rows));