A monocular vision plane ranging method based on rectangle information
By using a rectangular information-based method in monocular visual ranging, the difficulty of measuring transparent objects is solved, and high-precision and low-cost measurement is achieved, which is suitable for a variety of scenarios.
Patent Information
- Application Number
- CN202310663492.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-06
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2043-06-06
AI Technical Summary
The existing monocular visual ranging method has difficulties in measuring transparent objects, and has low accuracy and complex calculations, making it difficult to meet the measurement requirements of cost-sensitive and low accuracy requirements.
A monocular visual plane distance measurement method based on rectangular information is adopted. By placing a known rectangular object on the plane to be measured, its coordinates and diagonal length on the picture are calculated, and preset parameters are obtained, which are used to calculate the distance of the point to be measured.
This method reduces the amount of calculation, can effectively measure transparent objects, with a micron level of accuracy, strong applicability, and is not affected by ambient light changes and object properties, and is used for a long time.
Smart Images

Figure CN116678370B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision, mainly to monocular vision, and specifically refers to a monocular vision plane ranging method based on rectangular information. Background Art
[0002] In practical applications, it is necessary to measure the moving distance of glass on a plane. Common ranging methods include binocular vision and laser ranging. However, the above methods have limitations when measuring transparent objects such as glass. Binocular ranging mainly estimates the distance by calculating the visual field difference between two pictures through two lenses with a fixed distance. However, the edges of the glass are often not obvious, and the visual field difference between the two pictures in binocular vision is very weak, making it difficult to calculate. After using an auxiliary light source for supplementary lighting to enhance the edge information, problems such as reflection and overexposure caused by the glass material make it difficult for binocular vision to measure the area in the above situation. Laser ranging mainly measures the distance by measuring the time required for the whole process of laser, ultrasonic wave, etc. to return to the light source point after contacting the object surface, and its accuracy is very high. However, due to the transparent material of the glass, very little light is reflected back to the light source point after the laser contacts the glass surface, so it is impossible to measure transparent material objects such as glass. At the same time, the costs and implementation thresholds of the above two measurement schemes are relatively high. Generally, a complete set of hardware equipment and algorithms are required, and it is difficult for ranging projects with low budget requirements to adopt the above two schemes. Monocular vision has the characteristic of low cost. In certain cases, its measurement error can reach the level of 0.26 mm. Therefore, monocular vision ranging is generally used for measurements that are sensitive to cost and have low accuracy requirements. However, compared with binocular vision and laser ranging, monocular vision still has a gap in accuracy, and monocular vision lacks the three-dimensional information of the object, and multiple parameters need to be input to establish three-dimensional vision, making the use process more cumbersome.
[0003] Most of the existing monocular vision schemes are based on deep learning. They use models with a large number of parameters to fit the depth values corresponding to the pictures, so that the models can have generality and then estimate the depth of pictures in different scenarios, thus avoiding the cumbersome process of presetting parameters. Currently, object ranging schemes based on deep learning are relatively common. However, they require a large number of accurately labeled datasets for training, and the inference time of the models is generally much longer than the running time of traditional algorithms. The characteristics of difficult dataset processing, high training cost, and long inference time limit the application scope of this scheme.
[0004] Traditional monocular vision ranging schemes have a relatively low time complexity and can calculate results in a short time, making them suitable for scenarios with real-time requirements. There are mainly two traditional monocular vision ranging schemes: those based on a single strain matrix and direct measurement based on constants. The calculation of single strain matrix measurement is sensitive to ambient light, and errors will occur in feature calculation after the light conditions change, affecting the final measurement accuracy. The application scope of the direct measurement method based on constants is limited, and it is generally only applicable to the scenario where the camera vertically shoots an object. Therefore, in view of the problems of limited application scenarios, difficulty in measuring transparent objects, low accuracy of monocular vision measurement, and complex calculation, it is necessary to design a ranging scheme with better applicability. Summary of the Invention
[0005] In view of the above technical problems existing in the prior art, the present invention provides a monocular vision plane ranging method based on rectangular prior information, which has less computation compared with traditional monocular vision calculation schemes, solves the problem of difficult measurement of transparent objects, and ensures sufficient accuracy at the same time.
[0006] To solve the above technical problems, the technical solution of the present invention is as follows:
[0007] A monocular vision plane ranging method based on rectangular information includes the following steps:
[0008] S1. Place a known rectangular object on the plane to be measured where the glass moves, obtain a picture through a shooting camera, and acquire the parameters of the shooting camera.
[0009] S2. Obtain the coordinates of the four vertices of the known rectangle on the picture and the actual diagonal length of the rectangle.
[0010] S3. According to the obtained rectangle vertex coordinates, diagonal length, and the parameters of the shooting camera, calculate and save the preset parameters of the plane where the shooting camera is located and the plane to be measured, and remove the known rectangle from the field of view.
[0011] S4. Read the coordinates of the first measurement point on the glass in the picture, obtain the corresponding vector of the first measurement point according to the obtained preset parameters, and find the modulus of the vector to obtain the distance from this point to the camera focus.
[0012] S5. Read the coordinates of the second measurement point on the glass in the picture, obtain the corresponding vector of the second measurement point according to the obtained preset parameters, subtract the vector corresponding to the second measurement point from the vector of the obtained first measurement point and find the modulus, to obtain the real distance between the two measurement points.
[0013] Preferably, the parameters of the shooting camera include focal length, camera CCD size parameters, and picture resolution.
[0014] Preferably, in step S3, the method for calculating the preset parameters is as follows:
[0015] According to the picture resolution and the CCD size of the camera, calculate the sizes of unit pixels in the horizontal and vertical directions, that is, the proportional coefficient for converting the pixel length on the picture to the actual length on the CCD; take the focus of the shooting camera as the coordinate origin, the direction perpendicular to the camera imaging plane as the Z-axis, and the horizontal and vertical directions of the camera imaging plane as the X and Y axes to establish a three-dimensional coordinate system. At the same time, calculate the parameters of the shooting camera plane and the plane to be measured, and save them as preset parameters.
[0016] Preferably, in step S4, using the preset parameters obtained in step S3 and the established three-dimensional coordinate system, the three-dimensional coordinates of the corresponding point of the first point to be measured on the picture on the actual plane to be measured are obtained through linear operations, and then the vector corresponding to the first point to be measured is obtained from the three-dimensional coordinates of the focus and the first point to be measured.
[0017] Preferably, the method for calculating the vector corresponding to the second point to be measured is the same as the method for calculating the vector corresponding to the first point to be measured.
[0018] The present invention has the following characteristics and beneficial effects:
[0019] Adopting the above technical solution, this algorithm is based on monocular vision pictures, has low requirements for the used equipment and environment, strong applicability, and can calculate objects in various scenarios including overexposed areas and transparent objects. Only one calculation is required to obtain the preset parameters, and subsequent calculations can be directly based on the preset parameters. The preset parameters are only affected by the position of the plane to be measured and the camera, and are not changed by factors such as environmental light changes and the nature of the object to be measured, and have the characteristic of long-term use. The theoretical accuracy value of this algorithm depends on the coordinates when the preset parameters are selected and the coordinate values when the object to be measured is selected. Since calculations are performed using pictures, the pixel coordinates can be accurate to the individual digit at most. Therefore, the theoretical accuracy is the size of the unit pixel on the imaging element CCD, that is, the actual length corresponding to the unit pixel, and this value can generally be accurate to μm and below. Therefore, this algorithm can achieve high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0021] Figure 1 It is the calculation flow chart of the embodiment of the present invention.
[0022] Figure 2 Schematic diagram of imaging according to an embodiment of the present invention.
[0023] Figure 3 Diagram showing the relationship between the imaging plane and the plane to be measured according to an embodiment of the present invention.
[0024] Figure 4 Simplified plane relationship diagram according to an embodiment of the present invention.
[0025] Figure 5 Experimental scenario diagram for setting plane preset parameters according to an embodiment of the present invention.
[0026] Figure 6 Experimental scenario diagram for measuring the length of the high-exposure area of the glass according to an embodiment of the present invention. Detailed implementation manners
[0027] It should be noted that, without conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other.
[0028] In the description of the present invention, it should be understood that the orientation or positional relationship indicated by the terms "center", "longitudinal", "transverse", "up", "down", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation to the present invention. In addition, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined with "first", "second", etc. may explicitly or implicitly include one or more of such features. In the description of the present invention, unless otherwise specified, the meaning of "a plurality" is two or more.
[0029] In the description of the present invention, it should be noted that, unless otherwise clearly defined and limited, the terms "mounted", "connected", "coupled" should be understood in a broad sense, for example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection, an electrical connection; it may be directly connected, or indirectly connected through an intermediate medium, and it may be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.
[0030] The present invention provides a monocular vision plane ranging method based on rectangular information. The specific flowchart is referred to Figure 1 , and includes the following steps:
[0031] Step 1: Obtain the CCD size w of the camera CCD , h CCD , focal length f, all in millimeters. Place a known rectangle on the plane to be measured, take a photo, and obtain the resolution size w, h of the image, in pixels. In this embodiment, the CCD size of the used camera is 7.4112mm × 4.9536mm, the resolution is 3088pixel × 2064pixel, and the focal length is 12mm.
[0032] Step 2: Let the CCD imaging plane be plane α, the actual plane where the point to be measured is located be plane β, and the focus O be the coordinate origin. The imaging relationship is as Figure 2 shown. The four vertices of the known rectangle on the imaging plane are A, B, C, D respectively, and the four corresponding points of the four vertices on the actual plane β to be measured are A′, B′, C′, D′ respectively.
[0033] According to the obtained image, obtain the pixel coordinates x pixel , y pixel of points A, B, C, D on the image.
[0034] Step 3: According to the CCD size and the picture resolution, calculate the proportionality coefficients μ x , μ y in the horizontal and vertical directions corresponding to the actual length on the CCD:[[]]
[0035]
[0036]
[0037] According to the proportionality coefficients μ x , μ y , the pixel coordinates on the image, and the focal length, calculate the three-dimensional coordinates of points A, B, C, D on plane α. The Z-axis value is the focal length f, and the calculation formulas for the horizontal and vertical coordinates are as follows.
[0038] x mm = x pixel ·μ x
[0039] y mm = y pixel ·μ y
[0040] The actual diagonal length of the known rectangle is L millimeters, which is a known parameter value.
[0041] Let the calculated coordinates of points A and B be: A = (x a , y a , f), B = (x b , y b, f), the corresponding point P=(x of the point P' to be measured on the plane α p , y p , f). After calculation, the coordinates of each point are shown in the following table.
[0042]
[0043]
[0044] Simplify the model into a relationship diagram of the imaging plane α and the plane β to be measured as shown in Figure 3 . The point M' is the intersection of A'C' and B'D', and the point M is the intersection of AC and BD. Translate the β plane so that the point A coincides with the point A'. Only focus on the plane composed of O, A, C, A', and C', and obtain a simplified plane relationship diagram as shown in Figure 4 . Let ∠AOM = γ, ∠MOC = θ, ∠AMO = δ, ∠A'M'O = δ'. According to the sine theorem, we can get:
[0045]
[0046]
[0047]
[0048]
[0049] From equations (1) and (2), we can get:
[0050]
[0051] From equations (3) and (4), we can get:
[0052]
[0053] Because A'B'C'D' is a rectangle and the diagonal lengths are equal, that is, A'M' = C'M'. Combining equations (5) and (6), we can get:
[0054]
[0055] Similarly, by making the point B coincide with the point B', we can get:
[0056]
[0057] Let:
[0058]
[0059]
[0060] On the plane α, the pixel lengths of AM, CM, BM, and DM can be measured, and then the values of λ1 and λ2 can be obtained.
[0061] Actually, point A and point A' do not coincide, and point B' and point B' do not coincide. Therefore, there are the following relationships:
[0062]
[0063]
[0064] Furthermore, there is:
[0065]
[0066]
[0067]
[0068]
[0069] In the rectangle A'B'C'D', the diagonal length is L = 104.95 mm, that is Figure 5 the rectangle shown by the four points A, B, C, and D in
[0070]
[0071] For and taking the modulus, we can get:
[0072]
[0073]
[0074] From equations (11), (12), (13), (14), (17), (18) and (19), we can obtain
[0075] From equations (15) and (16), the normal vector of plane β can be expressed as:
[0076]
[0077] Let Then plane β can be represented by point A'=(x A′ , y A′ , z A′ ) and the plane normal vector as:
[0078] Planeβ: x n ·(x - x A′ ) + y n·(yy A′ )+z n ·(zz A′ )=0 (21)
[0079] Plane β is saved as a preset parameter. In subsequent calculations, the step of calculating plane β can be omitted and the parameter can be read directly. All points to be calculated are obtained from the imaging plane perpendicular to the Z axis, that is, plane α. Plane α can be calculated from its position perpendicular to the Z axis and the focal length f, so there is no need to save plane α separately. The coordinates and normal vector of point A′ are saved at the same time. The value of Figure 5 shown.
[0080] Step 4: Points O, A, A′, P, and P′ are coplanar. Let the plane be γ, and its normal vector for:
[0081]
[0082] Then the plane equation of plane γ is: Planeγ: A γ x+b γ y+C γ z+D γ = 0, because the plane passes through the origin O, so D γ =0, so the plane equation of plane γ is:
[0083] Planeγ: A γ x+B γ y+C γ z=0 (23)
[0084] By combining plane γ and plane β, we can get the intersection of the two planes, that is, the straight line Line A′P′ The equation of a straight line. A′P′ Through point A' = (A' x , A′ y , A′ z ), and the direction vector is perpendicular to both planes, which is:
[0085]
[0086] Line A′P′ The equation is:
[0087]
[0088] Line OP The direction vector is Passing point P = (x p ,y p , f), the equation of the straight line is:
[0089]
[0090] Combining equations (25) and (26), we can obtain four linear equations:
[0091]
[0092] Assuming the intersection point P′ = (x, y, z), equation (27) can be converted to:
[0093]
[0094] Formula (28) is:
[0095] AP′=B (29)
[0096] Multiply both sides of the equation by (A T A) -1 A T , which translates to:
[0097] P′=(A T A) -1 A T B (30)
[0098] That is, the coordinates of point P' are obtained. Then the distance from the focus O to point P', that is, the depth of point P' is:
[0099]
[0100] Step 5: If there are two test points P i , P j , the corresponding points P′i of the two points on plane β are calculated by step 4 respectively , P′ j , then the true distance between the two points is:
[0101]
[0102] In this embodiment, the specific scenario is as follows Figure 6 As shown in the figure, the distance and point to be measured are marked in the figure. Use a measuring ruler to measure the length and the depth distance from the point to the lens, in millimeters, and keep it to an integer. The estimated value calculated by the algorithm is kept to 2 decimal places, and the relative error value is calculated.
[0103]
[0104]
[0105] From the data in the table, we can see that this algorithm is not affected by the actual plane and object material when calculating the distance and depth of the overexposed area and the transparent area, and the relative error is small.
[0106] The embodiments of the present invention have been described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, without departing from the principle and spirit of the present invention, various changes, modifications, substitutions, and variations can be made to these embodiments, including components, and still fall within the protection scope of the present invention.
Claims
1. A monocular vision plane ranging method based on rectangular information, characterized in that, It includes the following steps: S1. Place a known rectangular object on the plane to be measured where the glass moves. Obtain a picture through a camera and acquire the parameters of the camera. S2. Obtain the coordinates of the four vertices of the known rectangle on the picture and the actual diagonal length of the rectangle. S3. Based on the obtained coordinates of the rectangle vertices, the diagonal length, and the parameters of the camera, calculate and save the preset parameters of the plane where the camera is located and the plane to be measured, and remove the known rectangle from the field of view. The calculation method of the preset parameters is as follows: According to the picture resolution and the CCD size of the camera, calculate the size of a unit pixel in the horizontal and vertical directions, that is, the proportional coefficient for converting the pixel length on the picture to the actual length on the CCD. Taking the focus of the camera as the coordinate origin, the direction perpendicular to the camera imaging plane as the Z-axis, and the horizontal and vertical directions of the camera imaging plane as the X and Y axes, establish a three-dimensional coordinate system. At the same time, calculate the parameters of the camera plane and the plane to be measured as the preset parameters for saving. S4. Read the coordinates of the first measurement point on the glass in the picture, and based on the obtained preset parameters, obtain the vector corresponding to the first measurement point. Calculate the modulus of the vector to get the distance from this point to the camera focus. S5. Read the coordinates of the second measurement point on the glass in the picture, and based on the obtained preset parameters, obtain the vector corresponding to the second measurement point. Subtract the vector corresponding to the second measurement point from the vector corresponding to the obtained first measurement point and calculate the modulus to get the actual distance between the two measurement points.
2. The monocular vision plane ranging method based on rectangular information according to claim 1, wherein The parameters of the camera include the focal length, the CCD size parameter of the camera, and the picture resolution.
3. The monocular vision plane ranging method based on rectangular information according to claim 2, wherein In step S4, using the preset parameters obtained in step S3 and the established three-dimensional coordinate system, obtain the three-dimensional coordinates of the corresponding point of the first measurement point on the picture in the actual plane to be measured through linear operations, and then obtain the vector corresponding to the first measurement point from the focus and the three-dimensional coordinates of the first measurement point.
4. A monocular vision planar ranging method based on rectangular information according to any one of claims 1-3, characterized in that, The method for calculating the vector corresponding to the second measurement point is the same as the method for calculating the vector corresponding to the first measurement point.
Citation Information
Patent Citations
Depth extraction method based on monocular vision
CN109035320A
Monocular Visual Odometry: Speed And Yaw Rate Of Vehicle From Rear-View Camera
US20190347808A1