Processing line scanner data
A first suggestion (without being sure to understand the question).

After sorting on X, try a line fit in a short sliding window (say 4 units long) and observe the correlation coefficient.

In smooth areas, the fit will be excellent. It will degrade at corners. Looking at the plot of the correlation, you should be able to set a suitable detection threshold.