Method for measuring the distance of a camera from a reference object
By detecting and classifying corners in images, forming combinations, and measuring the imaging length of reference points, the accuracy and speed issues of distance measurement between cameras and reference objects in home environments are solved. This technology is applicable to devices such as smartphones and mirrors.
Patent Information
- Application Number
- CN202210606487.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-05-31
- Filing Date
- 2022-05-31
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-05-31
AI Technical Summary
Existing technologies struggle to quickly and accurately measure the distance between a camera and a reference object in a home environment, particularly due to image distortion and blurring caused by the short focal length of smartphone cameras and changes in ambient light, which affects the accuracy of distance measurements and computation time.
By detecting corners in the image and classifying them based on their orientation, corner combinations are formed. These combinations are then compared with reference objects of a predetermined pattern, the imaging length of the reference points is measured, and the distance is calculated by combining the camera's focal length.
It achieves improved accuracy and robustness in distance measurement with low computation time and low equipment requirements, reduces dependence on image distortion, and is easy to operate for home users.
Smart Images

Figure CN115479577B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present invention relates to a method for measuring the distance separating a camera from a reference object.
[0002] The present invention also relates to a computer program for implementing the method, to a computer-readable storage medium for implementing the program and to a device for implementing the method. BACKGROUND
[0003] Several existing methods exist for measuring the distance between a sensor and a reference object, which require devices of different complexity and bring various levels of accuracy to the measured distance.
[0004] There is also an interest in providing a method that can be implemented by an untrained user with a camera and a computer or a smartphone, by simple settings, preferably at home.
[0005] One example of an application requiring an accurate measurement of such a distance is the evaluation of the quality of vision of a user with optotypes to determine whether a corrective device is needed, and a method to achieve such an evaluation at home without specific equipment.
[0006] This application requires measuring the optical distance separating the eye of the user from the optotypes with sufficient accuracy to obtain an accurate evaluation of the quality of vision at a specific distance.
[0007] The distance can then be determined using a reference object of known size and a camera, for example a smartphone camera held close to the eye.
[0008] The reference object can be a physical object of known size, including for example a reference point that can be easily detected in the image based on the colorimetric method. Alternatively, the reference object can be detected in the image, manually or by algorithm, based on its shape, like a credit card or a customer card.
[0009] The distance is determined based on the size of the image of the reference object of known size taken by the camera, which depends on the focal length of said camera.
[0010] More specifically, after adjusting the pixel size, the ratio of the size of the real object and the image taken by the camera is equal to the ratio of the distance between the camera and the reference object and the focal length of the camera.
[0011] However, these methods have several limitations for home applications.
[0012] Indeed, most smartphone cameras have a short focal length, of the order of a few millimeters, while the distance to be measured is several meters. The image of the reference object is therefore small and only includes a few pixels in any direction, which makes the measured length of the reference object in the image inaccurate.
[0013] Furthermore, the image can be partially blurred, for example due to a hand-held smartphone, or distorted due to variations in brightness in the environment.
[0014] This makes the detection of the reference object in the image and the measurement of its length a complex process, requiring a large amount of computation time and being at risk of inaccuracy. SUMMARY
[0015] The proposed method improves these aspects by increasing the accuracy of the measurement and reducing the computation time, while keeping the required equipment and user training at a minimum level.
[0016] To this end, the invention relates to a method for measuring a distance of 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 the steps of:
[0017] - acquiring, with the camera, an image comprising the reference object,
[0018] - detecting the corners in the image,
[0019] - attributing to each corner a class selected from a plurality of classes based on the orientation of the corner,
[0020] - detecting the reference object in the image based on the corners and the attributed classes,
[0021] - 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
[0022] - comparing the reference length with the imaged length and obtaining the distance of the camera from the reference object.
[0023] The method allows a fast and robust detection of the reference object in the image by basing it on the detection of the corners of the object. This allows the detection of the reference object in a single step and is more reliable in case a part of the image is distorted or blurred.
[0024] Furthermore, the imaged length is not measured directly between the corners or the borders, but between the reference points based on the corners, and is therefore less dependent on the distortion and partial blurring of the image.
[0025] The step of detecting the reference object can comprise forming combinations of the predetermined number of corners based on the respective classes of each corner and comparing each combination with the pattern of the reference object based on the respective positions of the corners of the combination relative to each other.
[0026] This allows a faster detection of the reference object in the image, reducing the total computation time.
[0027] The combinations of corners can comprise the following sub-steps:
[0028] - forming sub-combinations comprising one less corner than the predetermined number of combinations of corners,
[0029] - selecting a sub-combination based on the likelihood that the sub-combination is part of the combination forming the pattern,
[0030] - completing the selected sub-combination by adding an additional corner to obtain a combination, and
[0031] - comparing each combination to the pattern of the reference object to detect the reference object in the image.
[0032] This feature further reduces the computation time for detecting the reference object in the image.
[0033] Each of the combinations of corners can comprise three or four corners, each taken from a different category.
[0034] The corners can be attributed to a category based on the direction of the luminance transition crossing the corner from a brighter part of the image to a darker part of the image, or vice versa.
[0035] This feature allows a robust classification of the corners with a reduced risk of errors.
[0036] The plurality of categories can comprise four categories corresponding to the direction of four luminance transitions along two perpendicular axes, and a fifth category for discarded corners that cannot be attributed to one of the four categories.
[0037] The reference point can be chosen equidistant to at least two edges or at least two corners of the reference object.
[0038] The reference point can be chosen as the center of two rectangles or squares of the reference object.
[0039] These features allow the positioning of the reference point independently of potential dilatation or distortion of the image based on the luminance level in the environment.
[0040] The imaging distance can be measured with a precision lower than the pixel size of the image.
[0041] This allows a better precision as the pixel size is not negligible compared to the reference length of the imaging.
[0042] The reference object can comprise at least twelve corners arranged in a pattern comprising two squares and a rectangle.
[0043] The reference object can be shaped as two squares of a first gray level on a field of a second gray level different from the first gray level, the squares sharing a common border.
[0044] This pattern allows the features described above in relation to the corners and the reference length, and is simple enough to be displayed on a screen, manufactured or printed.
[0045] The reference object can be an image displayed on the screen of a smartphone.
[0046] This allows an efficient control of the size of the reference object, and requires a minimum of external equipment.
[0047] The invention also relates to a computer program comprising instructions which, when the program is executed by processing circuitry, cause the processing circuitry to perform the method described above.
[0048] The invention also relates to a computer-readable storage medium comprising instructions which, when executed by processing circuitry, cause the processing circuitry to perform the method according to the above.
[0049] The invention also relates to a device comprising at least:
[0050] - a camera, and
[0051] - processing circuitry connected to the camera and configured to implement the method described above. BRIEF DESCRIPTION OF DRAWINGS
[0052] Figure 1 is a schematic view of a device for implementing the method according to the invention,
[0053] Figure 2 is a front view of a smartphone displaying a reference object for implementing the method according to the invention, and
[0054] Figure 3 is a schematic view of the method according to the invention. DETAILED DESCRIPTION
[0055] Figure 1 A device EQ for implementing the method according to the invention is shown.
[0056] The device comprises processing circuitry CIR comprising a processor PROC and a memory MEM, the processing circuitry being controlled by a clock CLK.
[0057] Information for executing a program implementing the method, and other data such as intermediate distance measurements, can be stored on the memory.
[0058] The processing circuitry is able to execute said computer program to implement the method as described below.
[0059] The device also comprises a camera CAM, which can be internal or external to the device. The camera is connected to and controlled by the processing circuitry.
[0060] The device can also comprise at least one screen SCR connected to and controlled by the processing circuit.
[0061] The device can be a smartphone.
[0062] As Figure 1 illustrated, 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.
[0063] The distance D is the optical distance from the reference object to the mirror and back to the camera, and is therefore approximately equal to twice the distance at which the device is separated from the mirror.
[0064] The device is also illustrated in Figure 2 this case, the smartphone has a screen and a camera.
[0065] The screen displays a reference object 12 facing the mirror.
[0066] In this example, the reference object is an image comprising two rectangles or squares 14 sharing a common edge 16, displayed in a first gray level on a field 18 having a second gray level different from the first gray level.
[0067] For example, the square is darker and the field is lighter, or vice versa. Preferably, the first gray level and the second gray level are separated from each other by at least 50% of the full amplitude of the gray level scale.
[0068] The first gray level and the second gray level are preferably not pure white or pure black, as the maximum contrast can lead to distortions in the image when the luminosity in the environment is too low or too high.
[0069] 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.
[0070] Each corner thus presents a transition direction from the lighter part of the image to the darker part of the image, and 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.
[0071] For example, the four directions can be designated +X, -X, +Y, -Y according to the direction of the transition from the lighter part to the darker part.
[0072] Figure 2 The illustrated pattern comprises three corners for each possible transition direction.
[0073] The reference object comprises two reference points P1, P2 separated by a reference length L.
[0074] The reference points are chosen as the center of two squares and equidistant from the four corners of the reference object, wherein the four different directions are arranged as a square.
[0075] This allows the position of the reference points to be independent of the brightness of the environment, which influences the width of the borders of the reference object on the image. Since the reference points are not chosen as the actual points of the borders or corners, but equidistant from them, they do not change due to brightness variations
[0076] Reference will now be made to Figure 3 A method for measuring the distance of a reference object and a camera apart is described.
[0077] The method is implemented by the device as described above by instructions stored in the memory and executed by the processing circuitry.
[0078] The method comprises an acquisition step 100, during which an image comprising a reference object is acquired with a camera. The acquired image is stored in the memory.
[0079] The method comprises a detection step 200, during which corners are detected in the image.
[0080] The detection of the corners is achieved by a specific algorithm. Examples of such algorithms include the combined corner and edge detection disclosed by Harris in 1988 at the Alvey Vision Conference, the corner detection method disclosed by Shi-Tomasi in 1994 at the Proceedings of IEEE Conference on Computer Vision and Pattern Recognition, and the FAST corner detection entitled Machine Learning for High Speed Core Detection by Rosten et Drummond in 2006 at Volume 1 of the European Conference on Computer.
[0081] The latter choice is preferred for faster computation and more robust detection.
[0082] The method comprises an attribution step 300, during which a class chosen from a plurality of classes is attributed to each detected corner based on the orientation of the corner.
[0083] In this example, the detected corners are distributed in five categories, including the four categories for corners oriented in the four directions +X, -X, +Y, -Y as described above, and a fifth category for corners that cannot be attributed to one of these four categories.
[0084] The method then comprises a detection step 400, during which the reference object is detected in the image based on the corners and the attributed categories.
[0085] In the detection step 400, combinations of a predetermined number of corners are formed based on the respective categories of each corner, and successively compared with the pattern of the reference object to detect the reference object in the image.
[0086] For example, each combination of corners comprises four corners, each taken from a different category.
[0087] Advantageously, forming a combination of corners comprises the following four sub-steps.
[0088] In a first sub-step 410, a sub-combination is formed, comprising two corners, each taken from a different category.
[0089] The positions of the corners of the sub-combination relative to each other are tested, with respect to their respective categories and their expected arrangement in the pattern. For example, it is expected that a corner in the +X category is located lower in the image than a corner in the +Y category.
[0090] If the corners are in the expected pattern, the sub-combination is approved for the next sub-step. Otherwise, the sub-combination is discarded and another one is tested.
[0091] In a second sub-step 420, a third corner from a third, not yet represented category is added to the approved sub-combination.
[0092] The new sub-combination of three corners is then tested for the possibility of being part of a square or a rectangle in the pattern.
[0093] The relative positions of the corners of the sub-combination are also considered, based on their respective categories, as in the previous sub-step.
[0094] In addition, the three corners must be arranged in a triangle with right angles, and thus possibly be part of a square or a rectangle.
[0095] Criteria based on the relative distances between the corners can also be used to quickly discard sub-combinations with very incorrect aspect ratios.
[0096] In a third sub-step 430, the selected sub-combination is completed by adding an additional corner taken from a fourth, not yet represented category, to obtain a combination of four corners, and tested as previously described.
[0097] The position of the fourth corner relative to the other three corners is considered based on the category and the expected position of the fourth corner. The four corners are expected to form a square or a rectangle, with each corner being in a relative position depending on its category.
[0098] The third sub-step is repeated to test each possible fourth corner that would complete the sub-combination until a valid combination is detected. If no valid combination is found, another sub-combination is considered.
[0099] In a fourth sub-step 440, the completed sub-combination is compared to the pattern of the reference object.
[0100] The valid combinations corresponding to the square and the rectangle in the image are compared to the complete pattern of the reference object to detect the reference object in the image.
[0101] Advantageously, valid sub-combinations of three corners that would lead to a complete pattern when combined with other combinations are considered to accommodate possible blurring of one of the corners in the image.
[0102] The method then comprises a measuring step 500 during which reference points are placed in the image based on the corners of the reference object and the imaged length separating the reference points is measured.
[0103] The reference points P1, P2 are located in the middle of the two squares of the image. Thus, instead of measuring the imaged length between two visible points of the image, the imaged length between points that do not vary based on the brightness or partial blurring of the image is measured.
[0104] Furthermore, this allows a sub-pixel precision of the measurement of the imaged length, since the reference points are not based on pixel detection of the image.
[0105] The method finally comprises a computing step 600 in which the distance separating the camera and the reference object is computed based on the imaged length, the reference length and the focal length of the camera.
[0106] The described method allows to determine precisely and robustly the distance separating the reference object and the camera, requires low computation time and can be implemented with minimal equipment in a home setting, for example with only a smartphone and a mirror.
Claims
1. A method for measuring a distance (D) separating a camera (CAM) from a reference object (12), the reference object (12) comprising a predetermined number of corners (20) arranged in a pattern and at least two reference points (PI, P2) separated by a reference length (L), the method comprising the steps of: - acquiring an image comprising the reference object (12) with the camera (CAM), - detecting the corners (20) in the image, - attributing to each corner (20) a class (+X, +Y, -X, -Y) selected from a plurality of classes based on the orientation of the corner (20), - detecting the reference object (12) in the image based on the corners (12) and the attributed classes (+X, +Y, -X, -Y), - placing the reference points (PI, P2) in the image based on the corners (20) of the reference object (12) and measuring an imaged length separating the reference points (PI, P2), and - comparing the reference length (L) with the imaged length and obtaining the distance (D) separating the camera (CAM) from the reference object (12), wherein the step of detecting the reference object (12) comprises forming combinations of the predetermined number of corners (20) based on the respective classes (+X, +Y, -X, -Y) of each corner (20) and comparing each combination with the pattern of the reference object (12) based on the respective positions of the corners (20) of the combination relative to each other, wherein forming combinations of corners (20) comprises the sub-steps of: - forming sub-combinations comprising one corner (20) less than the combinations of the predetermined number of corners (20), - selecting sub-combinations based on the likelihood that the sub-combinations are part of a combination forming the pattern, - completing the selected sub-combinations by adding additional corners (20) to obtain a combination, and - comparing each combination with the pattern of the reference object (12) to detect the reference object (12) in the image.
2. The method of claim 1, wherein, Each of the combinations of corners (20) comprises three or four corners (20), each taken from a different class (+X, +Y, -X, -Y).
3. The method of claim 1, wherein, The corners (20) are attributed to a class based on the direction of the luminance transition passing through the corner (20) from a lighter part of the image to a darker part of the image, or vice versa.
4. The method of claim 3, wherein, The plurality of classes (+X, +Y, -X, -Y) comprises four classes corresponding to the directions of four luminance transitions along two perpendicular axes (X, Y) and a fifth class for discarded corners (20) that cannot be attributed to one of the four classes (+X, +Y, -X, -Y).
5. The method of claim 1, wherein, The reference points (PI, P2) are selected to be equidistant from at least two edges or at least two corners (20) of the reference object (12).
6. The method of claim 5, wherein, The reference points (PI, P2) are selected to be the centers of two rectangles or squares (14) of the reference object (12).
7. The method of claim 1, wherein, measuring the imaging distance with a precision lower than a pixel size of the image.
8. The method of claim 7, wherein, The reference object (12) comprises at least twelve corners (20) arranged in a pattern comprising two squares (14) and a rectangle.
9. The method of claim 8, wherein, The reference object (12) is shaped as two squares (14) of a first gray level as if on a field (18) of a second gray level different from the first gray level, the squares (12) sharing a common border (16).
10. The method of claim 1, wherein, The reference object (12) is an image displayed on a screen (SCR) of a smartphone (EQ).
11. A computer program comprising instructions which, when the program is executed by processing circuitry (CIR), causes the processing circuitry (CIR) to carry out the method of any one of claims 1 to 10.
12. A computer-readable storage medium comprising instructions which, when executed by processing circuitry (CIR), causes the processing circuitry to carry out the method of any one of claims 1 to 10.
13. A device (EQ) comprising at least: - a camera (CAM), and - processing circuitry (CIR) connected to the camera (CAM) and configured to implement the method of any one of claims 1 to 10.
Citation Information
Patent Citations
Monocular vision target space positioning method based on template
CN106651957A
Object detection method, device and system and storage medium
CN108875723A
Position measuring system using solid marker
JP2011179980A
Calibration device, calibration method, and calibration program
JP2018179584A
Method for enhancing the fastness of feature matching with pre-determined classification
KR1020140140285A