Method for measuring the height or the course of the height of an object, wherein the method comprises the following method steps: projecting a light pattern in form of coded image elements (11, 17), following one another, in an extension in direction of the transversal axis onto the object by means of a light source, wherein the image elements (11, 17) have, respectively, at least one coding feature and define together a code word (7, 16), wherein groups of image elements of a sequence of a predetermined number of consecutive image elements, respectively, define unique and individual partial code words (8, 13, 14, 15) existing exactly once within the code word (7, 16), wherein directly adjacent groups of image elements comprise partially the same image elements (11, 17), capturing the light pattern by means of an image sensor, which is arranged off-set to the light source, wherein each group of image elements is assigned to a specific reference position in the captured light pattern in direction of the transversal axis relative to a reference plane, wherein the reference plane is represented by a surface, on which the object is arranged, determining the positions in direction of the transversal axis of the groups of image elements in the captured light pattern and determining the height of the object by means of the determined position of the groups of image elements in comparison to the respective reference position, characterised in that the image elements (11, 17) are individual light points and that the coding feature is the position of the light points in direction transversally to the extension of the light pattern in direction of the sequence of the individual image elements (11, 17), wherein the light points are arranged in a plurality of lines along the extension of the light pattern. projecting a light pattern in form of coded image elements (11, 17), following one another, in an extension in direction of the transversal axis onto the object by means of a light source, wherein the image elements (11, 17) have, respectively, at least one coding feature and define together a code word (7, 16), wherein groups of image elements of a sequence of a predetermined number of consecutive image elements, respectively, define unique and individual partial code words (8, 13, 14, 15) existing exactly once within the code word (7, 16), wherein directly adjacent groups of image elements comprise partially the same image elements (11, 17), capturing the light pattern by means of an image sensor, which is arranged off-set to the light source, wherein each group of image elements is assigned to a specific reference position in the captured light pattern in direction of the transversal axis relative to a reference plane, wherein the reference plane is represented by a surface, on which the object is arranged, determining the positions in direction of the transversal axis of the groups of image elements in the captured light pattern and determining the height of the object by means of the determined position of the groups of image elements in comparison to the respective reference position, characterised in that the image elements (11, 17) are individual light points and that the coding feature is the position of the light points in direction transversally to the extension of the light pattern in direction of the sequence of the individual image elements (11, 17), wherein the light points are arranged in a plurality of lines along the extension of the light pattern.