Fix HoughLines crashes (Bug #3959).

Avoid phi exceed PI/2 to get the negative value of cos(phi).
Merge pull request #3392 from wangyan42164:houghlines_bug_fix