METHOD FOR MEASURING A DISTANCE SEPARATING A CAMERA FROM A REFERENCE OBJECT

20220383526 · 2022-12-01

Assignee

Inventors

Cpc classification

International classification

Abstract

A method for measuring a distance separating a camera from a reference object including a predetermined number of corners arranged in a pattern and at least two reference points separated by a reference length. The method includes acquiring an image including the reference object with the camera, detecting corners in the image, attributing a class to each corner, based on an orientation of the corner, detecting the reference object in the image based on the corners and attributed classes, placing the reference points in the image based on the corners of the reference object and measuring an imaged length separating the reference points, and comparing the reference length to the imaged length and obtaining the distance separating the camera from the reference object.

Claims

1. A method for measuring a distance separating a camera from a reference object, the reference object comprising a predetermined number of corners arranged in a pattern and at least two reference points separated by a reference length, the method comprising steps of: acquiring an image comprising the reference object with the camera, detecting corners in the image, attributing a class to each corner, chosen from a plurality of classes, based on an orientation of the corner, detecting the reference object in the image based on the corners and attributed classes, placing the reference points in the image based on the corners of the reference object and measuring an imaged length separating the reference points, and comparing the reference length to the imaged length and obtaining the distance separating the camera from the reference object.

2. The method according to claim 1, wherein the step of detecting the reference object comprises forming combinations of a predetermined number of corners based on the respective class of each corner and comparing each combination to the pattern of the reference object, based on respective positions of the corners of the combination relative to each other.

3. The method according to claim 2, wherein forming combinations of corners comprises sub steps of: forming subcombinations comprising one less corner than the predetermined number of corners of the combinations, selecting subcombinations based on the possibility for the subcombination to be part of a combination in the pattern, completing the selected subcombinations by adding an additional corner to obtain a combination, and comparing each combination to the pattern of the reference object to detect the reference object in the image.

4. The method according to claim 2, wherein each combination of corners comprises three or four corners, each corner being taken from a different class.

5. The method according to claim 1, wherein the corners are attributed a class based on a direction of a brightness transition across the corner, from a lighter part of the image to a darker part of the image or vice-versa.

6. The method according to claim 5, wherein the plurality of classes comprises four classes corresponding to four directions of the brightness transition along two perpendicular axes, and a fifth class for discarded corners that cannot be attributed one of the four classes.

7. The method according to claim 1, wherein the reference points are selected as equidistant from at least two edges or at least two corners of the reference object.

8. The method according to claim 7, wherein the reference points are chosen as the centers of two rectangles or squares of the reference object.

9. The method according to claim 1, wherein the imaged distance is measured with an accuracy under a pixel size of the image.

10. The method according to claim 9, wherein the reference object comprises at least twelve corners arranged in a pattern comprising two squares and a rectangle.

11. The method according to claim 10, wherein the reference object is shaped like two squares of a first grey level, the squares sharing a common border, over a field of a second grey level different from the first grey level.

12. The method according to claim 1, wherein the reference object is an image displayed on a screen of a smartphone.

13. A computer program comprising instructions which, when the program is executed by a processing circuit, cause the processing circuit to carry out the method according to claim 1.

14. A computer-readable storage medium comprising instructions which, when executed by a processing circuit, cause the processing circuit to carry out the method according to claim 1.

15. An equipment comprising at least: a camera, and a processing circuit connected to said camera and configured to implement the method according to claim 1.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

[0052] FIG. 1 is a schematic representation of an equipment for implementing a method according to the invention,

[0053] FIG. 2 is a front view of a smartphone displaying a reference object for implementing a method according to the invention, and

[0054] FIG. 3 is a schematic representation of a method according to the invention.

DETAILED DESCRIPTION OF EMBODIMENTS

[0055] An equipment EQ for implementing a method according to the invention is shown on FIG. 1. The equipment comprises a processing circuit CIR comprising a processor PROC and a memory MEM, the processing circuit being cadenced by a clock CLK.

[0056] Information for executing a program implementing the method may be stored on the memory, as well as other data like intermediate distance measurements.

[0057] The processing circuit is able to execute said computer program to implement the method as described below.

[0058] The equipment further comprises a camera CAM, which may be internal to the equipment or external to the equipment. The camera is connected to and controlled by the processing circuit.

[0059] The equipment may further comprise at least one screen SCR, connected to and controlled by the processing circuit.

[0060] The equipment may be a smartphone.

[0061] As shown on FIG. 1, the method can be implemented in front of a mirror 10, in order to measure a distance D between a reference object 12 and the camera. In this example, the reference object is displayed on the screen of the device.

[0062] The distance D is an optical distance, from the reference object to the mirror and back to the camera and is thus roughly equal to twice the distance separating the device from the mirror.

[0063] The equipment is also shown on FIG. 2, in this case a smartphone with a screen and camera.

[0064] The screen displays the reference object 12 facing the mirror.

[0065] In this example, the reference object is an image comprising two rectangles or squares 14 sharing a common side 16, displayed with a first grey level, over a field 18 with a second grey level different from the first grey level.

[0066] For example, the squares are darker, and the field is brighter, or the opposite. The first grey level and second grey level are preferably taken separated from each other by at least 50% of a full amplitude of a grey level scale.

[0067] The first grey level and second grey level are preferably not either pure white or pure black, as a maximal contrast can cause distortion in the image when the brightness in the environment is too low or too high.

[0068] The reference object comprises twelve corners 20 arranged in a pattern, each corner separating a lighter part of the image from a darker part of the image.

[0069] Each corner thus presents a direction of transition from a lighter part of the image to a darker art of the image, or vice-versa. Said transition can be oriented along one of four possible directions, said directions extending along two diagonal axes X, Y perpendicular to each other.

[0070] For example, the four directions can be designated as +X, −X, +Y, −Y, depending on the orientation of the transition for the brighter part to the darker part.

[0071] The pattern shown on FIG. 2 comprises three corners of each possible transition direction.

[0072] The reference object comprises two reference points P1, P2, separated by a reference length L.

[0073] The reference points are selected as the centers of both squares and are equidistant from four corners of the reference object with four different orientation arranged as a square.

[0074] This allows the location of the reference points to be independent form the brightness of the environment, which affects the width of the borders of the reference object on the image. as the reference points are not chosen as actual points of said borders or corners but as equidistant from them, they do not vary due to brightness variations

[0075] The method for measuring the distance separating the reference object and the camera will now be described, in reference to FIG. 3.

[0076] The method is implemented by an equipment as described above, through instructions stored in the memory and executed by the processing circuit.

[0077] The method comprises an acquiring step 100, during which an image comprising the reference object is acquired with the camera. The acquired image is stored in the memory.

[0078] The method comprises a detection step 200, during which corners are detected in the image.

[0079] The detection of corners is implemented through a specific algorithm. Examples of such algorithms include the combined corner and edge detection by Harris published in 1988 at the Alvey Vision Conference, the corner detection method by Shi-Tomasi published in 1994 in the Proceedings of IEEE Conference on Computer Vision and Pattern Recognition, and the FAST corner detection by Rosten et Drummond published in 2006 in the European Conference on Computer, volume 1 titled «Machine learning for highspeed corner detection».

[0080] The latter choice is preferred for faster computing and more robust detection.

[0081] The method comprises an attributing step 300, during which a class, chosen from a plurality of classes, is attributed to each detected corner, based on an orientation of the corner.

[0082] In this example, the detected corners are distributed in five classes, comprising the four classes for corners oriented in the four directions +X, −X, +Y, −Y as described above, and a fifth class for corners that could not be attributed one of these four classes.

[0083] The method then comprises a detecting step 400, during which the reference object is detected in the image based on the corners and attributed classes.

[0084] During the detecting step 400, combinations of a predetermined number of corners are formed based on the respective class of each corner, and successively compared to the pattern of the reference object to detect the reference object in the image.

[0085] For example, each combination of corners comprises four corners, each corner being taken from a different class.

[0086] Advantageously, forming combinations of corners comprises the following four substeps.

[0087] In a first substep 410, subcombinations are formed comprising two corners each, each corner being taken from a different class.

[0088] The positions of the corners of the subcombinations relative to one another are tested, in relation to their respective classes and their expected arrangement in the pattern. For example, a corner in the +X class is expected to be located lower in the image than a corner with a +Y class.

[0089] If the corners are in the expected pattern, the subcombination is validated for the next substep. Else, it is discarded and another subcombination is tested.

[0090] In a second substep 420, a third corner from a third non represented class is added to the validated subcombination.

[0091] The new subcombination of three corners is then tested on the possibility for the subcombination to be part of a square or rectangle in the pattern.

[0092] The relative positions of the corners of the subcombination is also considered based on their respective classes, as in the previous substep.

[0093] Furthermore, the three corners have to be arranged in a triangle with a right angle, thus being potentially a part of a square or rectangle.

[0094] A criterion based on the relative distances between the corners can also be used to quickly discard subcombinations with a largely incorrect aspect ratio.

[0095] In a third substep 430, the selected subcombinations are completed by adding an additional corner taken from the fourth unrepresented class, to obtain a combination of four corners, and tested as previously.

[0096] The position of the fourth corner relative to the other three corners is considered based on its class and expected position. The four corners are expected to form a square or rectangle, with each corner in a relative position depending on its class.

[0097] The third substep are iterated to test every possible fourth corner completing the subcombination, until a valid combination is detected. If no valid combination can be found, another subcombination is then considered.

[0098] In a fourth substep 440, the completed subcombinations are compared to the pattern of the reference object.

[0099] The valid combinations, corresponding to squares and rectangle in the image, are compared to the complete pattern of the reference object to detect the reference object in the image.

[0100] Advantageously, valid subcombinations of three corners that would lead to a complete pattern when combined with other combinations are considered, to accommodate for an eventual obscuring of one of the corners in the image.

[0101] The method then comprises a measuring step 500, during which the reference points are placed in the image based on the corners of the reference object, and an image length separating the reference points is measured.

[0102] The reference points P1, P2 are placed in the middle of both squares in the image. The imaged length is thus not measured between two visible points of the image but between points that do not vary based on brightness or partial obscuring of the image.

[0103] Furthermore, this allows for a sub-pixel accuracy of the measurement of the imaged length, as the reference points are not detected on pixels of the image.

[0104] The method finally comprises a calculation step 600, in which the distance separating the camera from the reference object is calculated based on the imaged length, the reference length and the focal length of the camera.

[0105] The described method allows for an accurate and robust determination of the distance separating the reference object from the camera, that requires a low computing time, and can be implemented with minimal equipment in a home setup, for example with a smartphone and a mirror only.