Fixed bug in cv::detail::waveCorrect

The function makes wave correction of a stitched panorama.
Earlier it gave wrong results for panorama made from 1 frame.
Merge pull request #2967 from LeonidBeynenson:bugfix_wave_correction_wrong_result