fixed slow down in getRectSubPix (original patch by Markus JR Mueller); removed some unused variables and functions
Merge pull request #2588 from vpisarev:fix_samples_n_unused