A ranging method based on the proportion of object pixels in an image and its rate of change
The method of identifying the rate of change in the pixel ratio of objects by using a camera and processor solves the problem of high cost in existing technologies and achieves accurate ranging at low cost.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HARBIN INST OF TECH
- Filing Date
- 2023-04-19
- Publication Date
- 2026-05-26
AI Technical Summary
In existing robot ranging technologies, equipment such as lidar and infrared rangefinders are expensive, making it difficult to reduce equipment costs while ensuring accuracy.
Using a camera and processor, distance is measured by recognizing the proportion of object pixels in the image and their rate of change. The distance is derived using geometric optics formulas, simplifying the device structure.
While maintaining a certain level of accuracy, the equipment cost is significantly reduced, requiring only a camera and a processor to achieve distance measurement, thus simplifying the equipment structure.
Smart Images

Figure CN117008109B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an image ranging method, specifically a ranging method based on the proportion of pixels of an object in an image and its rate of change. Background Technology
[0002] With the development of robotics and automatic control technologies, after identifying and aligning a target object using machine vision to center it in the image, distance control is required. Currently, robot ranging technologies commonly use devices such as LiDAR and infrared rangefinders, but these devices are costly. Summary of the Invention
[0003] To reduce costs while maintaining a certain level of ranging accuracy, this invention provides a ranging method based on the proportion of pixels of the identified object in an image and its rate of change. This method utilizes low-cost devices such as cameras and processors, thus ensuring a certain level of ranging accuracy while reducing equipment costs.
[0004] The objective of this invention is achieved through the following technical solution:
[0005] A ranging method based on the proportion of pixels of an object in an image and its rate of change includes the following steps:
[0006] Step 1: Identify the target object using machine vision;
[0007] Step 2: Position the target object so that it is directly in front of the camera and remains stationary. The robot equipped with the camera then moves closer to the target object at a constant speed.
[0008] Step 3: Determine the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image, the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image, and the proportion y of the target object pixels in the image.
[0009] Step 4: Solve for y1, y2, and the rate of change of y with respect to time.
[0010] Step 5: From the geometric optics formula, we can derive that the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image is inversely proportional to the distance, and K1 is its proportionality coefficient; the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image is inversely proportional to the distance, and K2 is its proportionality coefficient; the proportion y of the target object pixels in the image is inversely proportional to the square of the distance, and K is its proportionality coefficient. Solving for K1, K2, and K, we can then obtain the distances s1, s2, and s between the camera and the target object, where:
[0011]
[0012]
[0013]
[0014] In the formula, s1 is the distance value calculated based on the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image and its rate of change; s2 is the distance value calculated based on the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image and its rate of change; s is the distance value calculated based on the proportion y of the target object pixels in the image and its rate of change; and v is the speed of uniform linear motion.
[0015] Step 6: Define the average value of s1, s2, and s, i.e. when If the values are all between 0.95 and 1.05, the three values are considered to be close, and the average of the three values is output as the final distance value; otherwise, the value of s1 is output as the final distance value.
[0016] Compared with the prior art, the present invention has the following advantages:
[0017] 1. This invention can significantly reduce equipment costs while maintaining a certain level of accuracy;
[0018] 2. This invention only requires a camera and a processor, which simplifies the device structure. Attached Figure Description
[0019] Figure 1 A flowchart of the ranging process based on the proportion of pixels of the identified object in the image and its rate of change;
[0020] Figure 2 This is a schematic diagram illustrating the derivation of the ranging principle formula based on the proportion of pixels of the identified object in the image and its rate of change. Detailed Implementation
[0021] The technical solution of the present invention will be further described below with reference to the accompanying drawings, but it is not limited thereto. Any modifications or equivalent substitutions to the technical solution of the present invention that do not depart from the spirit and scope of the technical solution of the present invention should be covered within the protection scope of the present invention.
[0022] This invention provides a ranging method based on the proportion of pixels of an object in an image and its rate of change. This method assumes that the target object is fixed in a position directly in front of the camera, while a robot equipped with the camera approaches the target object at a constant speed. Specifically, the target object is identified using machine vision technology, and its orientation is controlled to ensure it is centered in the image. Figure 1As shown, the method includes the following steps:
[0023] Step 1: Identify the target object using machine vision.
[0024] Step 2: Position the target object so that it is fixed in the center of the image, that is, the target object is positioned directly in front of the camera and remains stationary.
[0025] Step 3: Determine the proportion of the horizontal feature length (outline) pixels of the target object in the horizontal direction of the image (y1), the proportion of the vertical feature length (outline) pixels of the target object in the vertical direction of the image (y2), and the proportion of the target object pixels in the image (y).
[0026] Step 4: Use the difference to replace the differential to solve for y1, y2, and the rate of change of y with respect to time.
[0027] Step 5: From the geometric optics formula, we can derive that the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image is inversely proportional to the distance, and K1 is its proportionality coefficient; the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image is inversely proportional to the distance, and K2 is its proportionality coefficient; the proportion y of the target object pixels in the image is inversely proportional to the square of the distance, and K is its proportionality coefficient. Solve for the values of K1, K2, and K, and then obtain the values of s1, s2, and s.
[0028] Step 6: Define the average value of s1, s2, and s, i.e. Under normal circumstances, the processor calculates The values are all between 0.95 and 1.05, so the three values can be considered close. Therefore, the average of the three values is output as the final distance value. If any of the three values falls outside the range of 0.95 to 1.05, it can be considered that the three values differ significantly. It should be noted that the camera on the robot has a certain height, which will cause errors in the s2 and s values. Therefore, in this case, the output s1 value is the final distance value.
[0029] The measurement principle of this invention is based on the inverse proportionality between the length of the image of the target object in a certain direction and the distance *s* between the camera and the target object. Next, we will utilize... Figure 2 The derivation and explanation will be based on the geometric optics knowledge shown.
[0030] Assuming the characteristic length of the object is H, the characteristic length of the image is h, the object distance is u, the image distance is v, and the focal length of the convex lens is f, the focal length of the convex lens in current cameras is generally very small (because the camera is very small, so the image needs to be very small, therefore the focal length must be small enough).
[0031] The imaging formula of a convex lens:
[0032] Multiply both sides by u:
[0033] Based on similar triangles:
[0034] Solving for:
[0035] And because: u >> f;
[0036] According to the concept of limits in calculus:
[0037] Since H and f are both fixed values, h is inversely proportional to u, where u is the object distance and s is the horizontal distance from the camera to the object. Although they are not exactly equal, let's assume h0 represents the distance from the camera to the horizontal plane. However, since h0 is much smaller than s (so making h0 as small as possible will improve measurement accuracy), we can assume that u = s. Therefore, we can conclude that h is inversely proportional to s, that is, the length of the image of the target object in a certain direction is inversely proportional to the distance s between the camera and the target object. Since the image is two-dimensional, we can deduce from the knowledge of geometric optics that the proportion y of the target object's pixels in the image is inversely proportional to the square of the distance s.
[0038] The above can be expressed by the formula:
[0039] Let the initial distance be s0, and the robot's velocity in uniform linear motion be v, then:
[0040] Differentiating with respect to time, we get:
[0041] Then we have a system of equations:
[0042]
[0043] Solving for the given information yields:
[0044]
[0045] Calculate K1 and substitute it into the formula. In this way, the distance s1 corresponding to y1 can be calculated. Note: For To solve for the problem, we know that the frequency of images captured by the camera is consistent, so we can use the difference instead of the differential to solve it.
[0046] Similarly, K2 can be calculated using the method described above: Substitute into the formula In this way, the distance s2 corresponding to y2 can be calculated.
[0047] Recalculate:
[0048] Differentiating with respect to time, we get:
[0049] Then we have a system of equations:
[0050]
[0051] Solving for:
[0052]
[0053] Find the value of K and substitute it into the formula: The distance s corresponding to y can be obtained.
[0054] Generally, the distance s values obtained from the three formulas should be close. Of course, the distance s1 value obtained using the first formula is more accurate.
[0055] Example:
[0056] Taking the task of cleaning up floating debris on the water surface as an example, given that the camera captures 50 frames per second (meaning the time interval between two images is 0.02 seconds), and the robot moves at a constant speed of 5 m / s, with an initial value of y1 of 0.1 and a next value of y1 of 0.101, the rate of change with respect to time can be calculated. Substitute into the formula We can calculate that K1 is 1, s0 is 10m, and the distance corresponding to y1 = 0.101 is 9.90099m. Thus, we can calculate the distance s1 corresponding to each y1 value. Since the camera on the robot has a certain height, the s2 and s values have large errors; therefore, s1 is used as the final distance value.
Claims
1. A ranging method based on the proportion of pixels of an identified object in an image and the rate of change thereof, characterized in that The method includes the following steps: Step 1: Identify the target object using machine vision; Step 2: Position the target object so that it is directly in front of the camera and remains stationary. The robot equipped with the camera then moves closer to the target object at a constant speed. Step 3: Determine the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image, the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image, and the proportion y of the target object pixels in the image. Step four, solve for y1, y2 and the rate of change of y with respect to time , , ; Step 5: From the geometric optics formulas, we can derive that the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image is inversely proportional to the distance, and K1 is its proportionality coefficient; the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image is inversely proportional to the distance, and K2 is its proportionality coefficient; the proportion y of the target object pixels in the image is inversely proportional to the square of the distance, and K is its proportionality coefficient. Solving for K1, K2, and K, we can then obtain the distances s1, s2, and s between the camera and the target object, where: s1 is the distance calculated based on the proportion y1 of the horizontal feature length pixels of the target object in the horizontal direction of the image and its rate of change; s2 is the distance calculated based on the proportion y2 of the vertical feature length pixels of the target object in the vertical direction of the image and its rate of change; and s is the distance calculated based on the proportion y of the target object pixels in the image and its rate of change. The formulas for calculating the K1, K2, and K values are as follows: ; ; ; In the formula, v is the velocity of uniform linear motion; Step six, define the average value of s1, s2, s, that is s 平 = When , , , the values of all are between 0.95-1.05, it is considered that the three values are close, then output the average value of the three values as the final distance value, otherwise output the s1 value as the final distance value. 2.The method according to claim 1, wherein The formulas for calculating the values of s1, s2, and s are as follows: ; ; 。