A method for measuring relative motion between a surface and an optical sensing device comprising a coherent light source and a photodetector device comprising an array of pixels and comparators, said method comprising the steps of: a) illuminating a portion of said surface at a determined flash rate by means of said coherent light source which produces a non-uniform illumination that has, when impinging on said portion of the surface, at least a first area with a positive intensity gradient along a given direction and at least a second area with a negative intensity gradient along this given direction; b) detecting, by means of said array of pixels, a speckled light intensity pattern of said illuminated portion of the surface for each flash; c) extracting, by means of said comparators, positive and negative edges from said detected speckled light intensity patterns by comparing light intensity between neighbouring pixels for each pattern, wherein a positive edge is defined as a condition wherein the light intensity of a first pixel is less than the light intensity of a second pixel and a negative edge is defined as a condition wherein the light intensity of the first pixel is greater than the light intensity of the second pixel: d) determining a relative motion between said optical sensing device and said surface based on a variation of inflexions between successive speckled light intensity patterns, an inflexion being defined by a negative edge followed by a positive edge (null) or by a positive edge followed by a negative edge (peak): characterized in that, before determining the inflexions, a selecting factor is introduced which promotes in at least said first area, respectively in at least said second area detection of one type of edge among positive or negative types rather than the other type, and in that the value of said selecting factor is adjustable, a first value being selected for promoting a first type of edge in the processing of a first detected light intensity pattern part corresponding to said first area of said illumination and a second value being selected for promoting the second type of edge in the processing of a second detected light intensity pattern part corresponding to said second area of said illumination. a) illuminating a portion of said surface at a determined flash rate by means of said coherent light source which produces a non-uniform illumination that has, when impinging on said portion of the surface, at least a first area with a positive intensity gradient along a given direction and at least a second area with a negative intensity gradient along this given direction; b) detecting, by means of said array of pixels, a speckled light intensity pattern of said illuminated portion of the surface for each flash; c) extracting, by means of said comparators, positive and negative edges from said detected speckled light intensity patterns by comparing light intensity between neighbouring pixels for each pattern, wherein a positive edge is defined as a condition wherein the light intensity of a first pixel is less than the light intensity of a second pixel and a negative edge is defined as a condition wherein the light intensity of the first pixel is greater than the light intensity of the second pixel: d) determining a relative motion between said optical sensing device and said surface based on a variation of inflexions between successive speckled light intensity patterns, an inflexion being defined by a negative edge followed by a positive edge (null) or by a positive edge followed by a negative edge (peak):