Bugfix for a cv::matchTemplate when img and templ overlap.

Example img is of size 10,10 and templ is of size 11,9.
Line 248-249 will switch img and templ and continue.
Line 251 will set one dimension to 0.

Line 261 calls crossCorr with result where one dimension is 0 (follows
    from Line 251).

Consequently blocksize.width or blocksize.height is set to zero (Lines
79-84)

Either Line 139 or 140 will crash with a division by zero.