Distance measurement method and device

By obtaining the parallax or depth information of the target image to perform point cloud conversion and calculate the three-dimensional coordinates, the portability and accuracy issues of tool-free ranging are solved, and simple and efficient distance measurement is achieved on the terminal device.

CN113781534BActive Publication Date: 2025-09-09HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110899192.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-03-05
Publication Date
2025-09-09
Estimated Expiration
2038-03-05

AI Technical Summary

Technical Problem

The existing technology requires the use of professional measuring tools when measuring the distance between two points in space, which makes it inconvenient to carry and expensive, and the measurement cannot be completed without the tools.

Method used

By acquiring the target image and its disparity image or depth image, performing point cloud conversion, calculating the three-dimensional coordinates corresponding to the image points, and calculating the spatial distance using the Euclidean distance formula or preset distance compensation value.

Benefits of technology

No professional tools are required, the measurement is accurate, and it has a wide range of applications without increasing the hardware cost of the terminal equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113781534B_ABST
    Figure CN113781534B_ABST
Patent Text Reader

Abstract

The present application discloses a distance measurement method and device. The method includes: obtaining a target image and a disparity image or depth image corresponding to the target image, and then performing point cloud conversion on the disparity image or depth image to obtain a point cloud image; and then, based on the point cloud image and the first image point and the second image point in the target image, obtaining the three-dimensional coordinates of a first scene point corresponding to the first image point and the three-dimensional coordinates of a second scene point corresponding to the second image point, as well as obtaining the spatial distance between the first scene point and the second scene point. In this way, the distance measurement method in the embodiment of the present application does not require the use of professional measurement tools, and can simply and conveniently complete distance measurement without increasing the hardware cost of the terminal device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of terminal technology, and in particular to a ranging method and device. Background Art

[0002] Currently, there are several main ways to measure the distance between two points in space: one is to use traditional measuring tools such as rulers and tape measures for manual measurement. Since you need to carry a ruler or tape measure with you, it is inconvenient to carry it with you, and when measuring a large distance (such as 10 meters), this method is relatively inconvenient to operate; the other is to use measuring tools such as infrared, laser, or ultrasonic waves to calculate the distance by calculating the time difference spent on the reflected signal. This method also requires carrying a measuring tool with you, and the measuring tool is usually a precision electronic instrument, which is expensive to measure. As can be seen from this, in the existing technology, when measuring the distance between two points, it is usually necessary to use professional measuring tools. If the user does not have the above professional measuring tools with him, it may be impossible to complete the measurement.

[0003] In summary, there is an urgent need for a distance measurement method that can be used to measure the distance between two points in space without the aid of professional measuring tools. Summary of the Invention

[0004] An embodiment of the present application provides a distance measurement method for measuring the distance between two points in space without the aid of a measuring tool.

[0005] In a first aspect, an embodiment of the present application provides a ranging method, the method comprising:

[0006] Acquire a target image and a disparity image or a depth image corresponding to the target image;

[0007] Performing point cloud conversion on the disparity image or the depth image to obtain a point cloud image;

[0008] Obtaining, based on the point cloud image and a first image point and a second image point in the target image, three-dimensional coordinates of a first scene point corresponding to the first image point and three-dimensional coordinates of a second scene point corresponding to the second image point;

[0009] A spatial distance between the first scene point and the second scene point is obtained according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point.

[0010] In this way, through the above-mentioned method, the distance measurement method in the embodiment of the present application does not require the aid of professional measuring tools, and can simply and conveniently complete the distance measurement without increasing the hardware cost of the terminal device; compared with the solutions in the prior art, this method does not need to limit the target image to a preset clarity, making the scope of application wider, and calculating the spatial distance through three-dimensional coordinates makes the measurement accuracy higher.

[0011] In one possible design, the target image is obtained based on a first image and / or a second image, wherein the first image is obtained by a first camera device photographing the target scene from a first position, and the second image is obtained by a second camera device photographing the target scene from a second position.

[0012] In one possible design, obtaining a disparity image corresponding to the target image includes:

[0013] A disparity image corresponding to the target image is determined according to disparity values ​​of scene points corresponding to each image point in the target image in the first image and the second image.

[0014] In one possible design, obtaining a depth image corresponding to the target image includes:

[0015] Determining a depth value of a scene point corresponding to each image point in the target image;

[0016] A depth image corresponding to the target image is determined according to the depth value of the scene point corresponding to each image point in the target image.

[0017] In one possible design, the focal length of the first camera device is the same as the focal length of the second camera device;

[0018] Determining a depth value of a scene point corresponding to each image point in the target image includes:

[0019] Determine a depth value of the scene point corresponding to each image point in the target image based on a disparity value of the scene point corresponding to each image point in the target image in the first image and the second image, a distance between the first position and the second position, and the focal length.

[0020] In one possible design, obtaining the spatial distance between the first scene point and the second scene point according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point includes:

[0021] Obtaining an initial spatial distance between the first scene point and the second scene point using a Euclidean distance formula according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point;

[0022] The initial spatial distance is used as the spatial distance between the first scene point and the second scene point; or the spatial distance between the first scene point and the second scene point is obtained according to the initial spatial distance and a preset distance compensation value.

[0023] In the above manner, the accuracy of the result can be effectively improved by considering the preset distance compensation value.

[0024] In a second aspect, an embodiment of the present application provides a distance measuring device, the distance measuring device comprising:

[0025] an acquisition unit, configured to acquire a target image and a disparity image or a depth image corresponding to the target image;

[0026] a conversion unit, configured to perform point cloud conversion on the disparity image or the depth image to obtain a point cloud image;

[0027] a processing unit configured to obtain, based on the point cloud image and the first image point and the second image point in the target image, the three-dimensional coordinates of a first scene point corresponding to the first image point and the three-dimensional coordinates of a second scene point corresponding to the second image point; and to obtain, based on the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point, a spatial distance between the first scene point and the second scene point.

[0028] In one possible design, the target image is obtained based on a first image and / or a second image, wherein the first image is obtained by a first camera device photographing the target scene from a first position, and the second image is obtained by a second camera device photographing the target scene from a second position.

[0029] In one possible design, the acquiring unit is specifically configured to:

[0030] A disparity image corresponding to the target image is determined according to disparity values ​​of scene points corresponding to each image point in the target image in the first image and the second image.

[0031] In one possible design, the acquiring unit is specifically configured to:

[0032] Determining a depth value of a scene point corresponding to each image point in the target image;

[0033] A depth image corresponding to the target image is determined according to the depth value of the scene point corresponding to each image point in the target image.

[0034] In one possible design, the focal length of the first camera device is the same as the focal length of the second camera device;

[0035] The acquisition unit is specifically configured to:

[0036] Determine a depth value of the scene point corresponding to each image point in the target image based on a disparity value of the scene point corresponding to each image point in the target image in the first image and the second image, a distance between the first position and the second position, and the focal length.

[0037] In one possible design, the processing unit is specifically configured to:

[0038] Obtaining an initial spatial distance between the first scene point and the second scene point using a Euclidean distance formula according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point;

[0039] The initial spatial distance is used as the spatial distance between the first scene point and the second scene point; or the spatial distance between the first scene point and the second scene point is obtained according to the initial spatial distance and a preset distance compensation value.

[0040] In one possible design, the distance measuring device is a semiconductor chip, and the semiconductor chip is disposed in the terminal device;

[0041] The first camera device and the second camera device are both rear-mounted camera devices of the terminal device; or the first camera device and the second camera device are both front-mounted camera devices of the terminal device.

[0042] In one possible design, the ranging device is a terminal device;

[0043] Wherein, the first camera device and the second camera device are both rear-mounted camera devices of the terminal device; or, the first camera device and the second camera device are both front-mounted camera devices of the terminal device.

[0044] Another embodiment of the present application provides a distance measuring device, comprising:

[0045] Memory for storing software programs;

[0046] The processor is used to read the software program in the memory and execute the ranging method in any of the above designs.

[0047] Yet another embodiment of the present application provides a computer storage medium storing a software program, which implements the ranging method in any of the above designs when read and executed by one or more processors.

[0048] Yet another aspect of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the methods described in the above aspects.

[0049] Yet another aspect of the present application provides a computer program, which, when executed on a computer, enables the computer to execute the methods described in the above aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A schematic structural diagram of a distance measuring device provided in an embodiment of the present application;

[0051] Figure 2 A flow chart of a distance measurement method according to an embodiment of the present application;

[0052] Figure 3a Schematic diagram of the target image captured by the terminal device;

[0053] Figure 3b is the disparity image corresponding to the target image;

[0054] Figure 3c is the point cloud image converted from the disparity image;

[0055] Figure 3d A schematic diagram showing spatial distance;

[0056] Figure 4 A schematic diagram of the principle of acquiring a depth image using two camera devices;

[0057] Figure 5 Schematic diagram of the overall execution flow of the ranging method in an embodiment of the present application;

[0058] Figure 6a This is a schematic diagram of the interface display of the terminal device in standby mode;

[0059] Figure 6b This is a schematic diagram of the interface of the terminal device entering the shooting state;

[0060] Figure 6c Displaying a target image schematic diagram for a terminal device;

[0061] Figure 6d A schematic diagram of the spatial distance between scene points corresponding to two image points selected by the user;

[0062] Figure 6e This is a schematic diagram of the updated spatial distance;

[0063] Figure 7 A schematic structural diagram of another distance measuring device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0064] The present application will be described in detail below with reference to the accompanying drawings. The specific operating methods in the method embodiments can also be applied to the device embodiments.

[0065] In the existing technology, the distance between different objects usually requires the use of professional measuring tools, which causes inconvenience to users. Considering that mobile phones and other terminal devices have become almost essential items that people carry with them, if these terminal devices are used to measure distance, users no longer need to carry professional measuring tools.

[0066] Currently, one solution for measuring distance using a mobile phone is to pre-establish a correspondence between the zoom ratio of the mobile phone photo and the camera parameters. When the user needs to know the actual geographical location distance of the target object, for example, the actual distance between two mountain peaks, the user can use the mobile phone to take a photo of the target object, that is, take a photo of the two mountain peaks, and obtain an image of the target object with the highest clarity, as well as the zoom ratio of the target object in the image at this time; the mobile phone obtains two target points to be measured input by the user on this image, calculates the image distance between the two target points to be measured in the image, and based on the image distance between the two target points to be measured in the image and the zoom ratio of the target object in the image, the actual geographical location distance between the two target points to be measured, that is, the actual geographical location distance between the two mountain peaks, can be calculated.

[0067] In the above solution, the terminal device can calculate the distance between two points based on the scaling ratio of the target object in the image. However, on the one hand, the applicability of the above solution is relatively limited. For example, areas with low clarity may not be able to be measured. On the other hand, estimating the distance by scaling ratio will result in low measurement accuracy.

[0068] Based on this, an embodiment of the present application provides a distance measurement method for measuring the distance between different objects without the aid of professional measuring tools.

[0069] Specifically, the method includes: obtaining a target image and a disparity image or depth image corresponding to the target image, and then obtaining a point cloud image by performing point cloud conversion on the disparity image or depth image; and then obtaining the three-dimensional coordinates of a first scene point corresponding to the first image point and the three-dimensional coordinates of a second scene point corresponding to the second image point based on the point cloud image and the first image point and the second image point in the target image, as well as obtaining the spatial distance between the first scene point and the second scene point. In the above manner, the distance measurement method in the embodiment of the present application does not require the aid of professional measuring tools, and can simply and conveniently complete the distance measurement without increasing the hardware cost of the terminal device; compared to the solutions in the prior art, this method does not need to limit the target image to a preset clarity, making it more applicable, and calculating the spatial distance through three-dimensional coordinates makes the measurement more accurate.

[0070] The ranging method in the embodiments of the present application can be performed by a ranging device. The ranging device can be a semiconductor chip disposed within a terminal device; alternatively, the ranging device can be a terminal device. As shown in FIG1 , a ranging device 100 provided in an embodiment of the present application includes at least one processor 11, a communication bus 12, a memory 13, and at least one communication interface 14.

[0071] The processor 11 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.

[0072] The communication bus 12 may include a path for transmitting information between the above components. The communication interface 14 may be any device such as a transceiver for communicating with other devices or a communication network.

[0073] The memory 13 can be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by the device, but is not limited thereto. The memory can exist independently and be connected to the processor via a bus. The memory can also be integrated with the processor.

[0074] Among them, the memory 13 is used to store the application code for executing the solution of the present application, and is controlled by the processor 11 to execute, that is, the processor 11 is used to execute the application code stored in the memory 13 to implement the ranging method in the embodiment of the present application.

[0075] In a specific implementation, as an embodiment, the processor 11 may include one or more CPUs, such as Figure 1 CPU0 and CPU1 in.

[0076] In a specific implementation, as an embodiment, the apparatus 100 may include multiple processors, such as Figure 1 1 and 15. Each of these processors can be a single-CPU processor or a multi-CPU processor. A processor here can refer to one or more circuits and / or processing cores for processing data (such as computer program instructions).

[0077] Furthermore, when the ranging device is a semiconductor chip arranged in the terminal device, the terminal device may also include a first shooting device and a second shooting device, and the first camera device and the second camera device are both rear cameras of the terminal device; or, the first camera device and the second camera device are both front cameras of the terminal device.

[0078] When the distance measuring device is a terminal device, the distance measuring device may further include a first shooting device and a second shooting device (not shown in FIG. Figure 1), the first camera device and the second camera device are both rear cameras of the terminal device; or the first camera device and the second camera device are both front cameras of the terminal device.

[0079] It should be noted that the terminal device described above may be a mobile phone, a tablet computer, etc.

[0080] Figure 2 A flow chart of a distance measurement method provided in an embodiment of the present application. The distance measurement method can be performed by Figure 1 The distance measuring device 100 shown in FIG. Figure 2 As shown, the method includes:

[0081] Step 201: Acquire a target image and a disparity image or a depth image corresponding to the target image.

[0082] Here, the target image is obtained based on the first image and / or the second image, wherein the first image is obtained by the first camera device shooting the target scene from a first position, and the second image is obtained by the second camera device shooting the target scene from a second position.

[0083] In one possible implementation, the first camera and the second camera are both rear cameras of the terminal device. Furthermore, the optical centers of the first camera and the second camera are separated laterally by a predetermined distance, and the first and second cameras have the same focal length. In one example, the first camera is a color camera and the second camera is an auxiliary camera, or vice versa. In another example, the first camera is a color camera and the second camera is a black-and-white camera, or vice versa.

[0084] The first camera device in the embodiment of the present application can be specifically a camera, and the second camera device can also be specifically a camera. In one example, after the user triggers the ranging function of the terminal device, the terminal device uses the first camera device to shoot the target scene from a first position to obtain a first image, and uses the second camera device to shoot the target scene from a second position to obtain a second image, and fuses the first image and the second image to obtain a target image, thereby improving the photographing effect. In other embodiments, the terminal device can also directly use the first image or the second image as the target image, without specific limitation. Figure 3a The following is a schematic diagram of the target image.

[0085] It should be noted that: the first image and the second image are obtained by the terminal device simultaneously starting the first camera device and the second camera device after the user triggers the ranging function of the terminal device; the above-mentioned first position can be understood as the optical center of the first camera device, and the second position can be the optical center of the first camera device, and the distance between the first position and the second position is the set distance.

[0086] Furthermore, obtaining a disparity image corresponding to a target image may include: determining the disparity image corresponding to the target image based on the disparity values ​​of the scene points corresponding to each image point in the target image in the first image and the second image. Obtaining a depth image corresponding to the target image includes: determining the depth value of the scene point corresponding to each image point in the target image; and determining the depth image corresponding to the target image based on the depth value of the scene point corresponding to each image point in the target image. Specifically, the depth value of the scene point corresponding to each image point in the target image may be determined based on the disparity values ​​of the scene point corresponding to each image point in the target image in the first image and the second image, the distance between the first position and the second position, and the focal length.

[0087] In the embodiments of the present application, a disparity image corresponding to a target image refers to an image having the same size as the target image and whose element values ​​are the disparity values ​​of scene points corresponding to image points in the target image. A depth image corresponding to a target image refers to an image having the same size as the target image and whose element values ​​are the depth values ​​of scene points corresponding to image points in the target image.

[0088] The following description takes a depth image as an example.

[0089] Figure 4 FIG. 1 is a schematic diagram showing the principle of obtaining a depth image using two camera devices. Figure 4As shown, OL is the optical center of the first camera (also called the left camera), and OR is the optical center of the second camera (also called the right camera). The set distance between the two optical centers is b, and the line segment between the two optical centers is the baseline of the first and second cameras. A line segment of length L on the left represents the imaging plane of the first camera, and a line segment of length L on the right represents the imaging plane of the second camera. The imaging planes of the first and second cameras are located on the same plane. The shortest distance from the optical center of the first camera to the imaging plane of the first camera is the focal length of the first camera, and the shortest distance from the optical center of the second camera to the imaging plane of the second camera is the focal length of the second camera. As shown in Figure 3, the focal lengths of the first and second cameras are both f. Let P be a scene point in the target scene. Its image point on the imaging plane of the first camera (i.e., the image point in the first image) is PL, and its image point on the imaging plane of the second camera (i.e., the image point in the second image) is PR. The distances PL and PR from the left edge of their respective image planes are XL and XR, respectively. The disparity value of scene point P (i.e., the disparity value of scene point P in the first and second images) is the difference between the horizontal coordinates of the image points PL and PR corresponding to scene point P in the image plane coordinate system, that is, XR - XL or XL - XR. The depth value of scene point P is the distance Z from scene point P to the baseline of the first and second cameras.

[0090] According to the triangle similarity principle, there is the following proportional relationship:

[0091]

[0092] It can also be written as:

[0093]

[0094] So we have:

[0095]

[0096] It can be deduced that:

[0097]

[0098] According to the above content, it can be known that the depth value of the scene point P can be calculated based on the disparity value of the scene point P, the set distance between the optical center of the first camera device and the optical center of the second camera device, and the focal length. In this way, by calculating the depth value of each scene point corresponding to the image point in the target image, the depth image corresponding to the target image can be obtained. Similarly, by calculating the disparity value of each scene point corresponding to the image point in the target image, the disparity image corresponding to the target image can be obtained, as shown in FIG. Figure 3b As shown, Figure 3a The disparity image corresponding to the target image in .

[0099] It should be noted that Figure 4 In this example, the two cameras of a terminal device are positioned side-by-side. Therefore, the disparity value of a scene point P is the difference between the horizontal coordinates of the image points PL and PR corresponding to the scene point P in the image plane coordinate system. In other possible embodiments, the two cameras of the terminal device may be positioned in other positions, such as above and below. In this case, the disparity value of the scene point P can still be calculated based on the coordinates of the image points PL and PR corresponding to the scene point P in the image plane coordinate system. The specific calculation method is not detailed here.

[0100] Furthermore, Figure 4 In the schematic diagram (ideal case) shown, the coordinates of the principal point of the first camera device correspond to the center of the imaging surface (L) of the first camera device, and the coordinates of the principal point of the second camera device correspond to the center of the imaging surface (L) of the second camera device. Therefore, the depth value of the scene point P is Z calculated in the above formula 4.

[0101] In reality, the coordinates of the principal point of the camera device may not correspond to the center of the imaging surface. In this case, the depth value of the scene point P can be obtained by the following formula:

[0102]

[0103] Among them, c′ x is the abscissa of the principal point of the second camera, c x is the abscissa of the principal point of the first camera device.

[0104] Step 202 : Perform point cloud conversion on the disparity image or the depth image to obtain a point cloud image.

[0105] Here, taking the point cloud conversion of the disparity image as an example, a mapping matrix Q is defined based on the triangle similarity principle to establish the relationship between the disparity value of the scene point and the real 3D coordinate. The expression of Q is as follows:

[0106]

[0107] Among them, c x and c y is the principal point coordinate of the first camera device, c′ x is the abscissa of the principal point of the second camera device.

[0108] Furthermore, for the coordinates (x, y) of any image point in the target image in the image plane coordinate system and the disparity value d of the scene point corresponding to any image point, the following formula is used for conversion to obtain the three-dimensional coordinates of the scene point corresponding to any image point in the reference coordinate system with the first camera device, thereby realizing three-dimensional reconstruction and obtaining a point cloud image.

[0109]

[0110] Among them, (X / W, Y / W, Z / W) are the three-dimensional coordinates of the scene point corresponding to the image point (x, y).

[0111] It should be noted that if the disparity image corresponding to the target image is obtained in step 201, the above-mentioned point cloud conversion of the disparity image can be used, such as Figure 3c As shown, based on Figure 3b If the depth image corresponding to the target image is obtained in step 201, the depth image can be converted into a point cloud to obtain a point cloud image. The specific conversion process is the same as the above-mentioned process of converting the disparity image into a point cloud. The difference is that the mapping matrix used when converting the depth image into a point cloud may be different from the mapping matrix used when converting the disparity image into a point cloud.

[0112] Step 203 : Obtain the three-dimensional coordinates of a first scene point corresponding to the first image point and the three-dimensional coordinates of a second scene point corresponding to the second image point based on the point cloud image and the first image point and the second image point in the target image.

[0113] Step 204: Obtain a spatial distance between the first scene point and the second scene point according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point.

[0114] In a possible implementation, the terminal device may further include a display screen, and the user may view the target image through the display screen. If the display screen is a touch screen, the user may select the first image point and the second image point by touching the target image with a finger. Accordingly, the terminal device detects the user's touch operation and determines that the user has selected the first image point and the second image point (see Figure 3d As shown in FIG20 , since the three-dimensional coordinates of the scene points corresponding to each image point have been obtained through point cloud conversion in step 202, the three-dimensional coordinates of the first scene point corresponding to the first image point and the three-dimensional coordinates of the second scene point corresponding to the second image point can be obtained respectively, and then the initial spatial distance between the first scene point and the second scene point can be obtained through the Euclidean distance formula.

[0115] In an example, the initial spatial distance may be directly used as the spatial distance between the first scene point and the second scene point.

[0116] In another example, to improve the accuracy of the result, the terminal device may further obtain a preset distance compensation value, and then obtain the spatial distance between the first scene point and the second scene point according to the initial spatial distance and the preset distance compensation value.

[0117] The preset distance compensation value can be obtained in various ways. One possible implementation is for a user to trigger the calibration function of the terminal device and then calibrate two image points in a preset image, where the spatial distance between the scene points corresponding to the two image points is a preset distance, such as 10 cm. In a specific implementation, the user can capture an image containing a ruler while in the terminal device's calibration mode to facilitate calibration of the preset distance. If the terminal device calculates that the distance between the scene points corresponding to the two image points is 9 cm, since the error value of the terminal device's calculation result is 1 cm, the preset distance compensation value can be set to 1 cm. During the subsequent distance measurement process, the calculated distance and the preset distance compensation value are added to obtain the final result. To further improve accuracy, the user can perform multiple calibrations, for example, calibrating two points at any distance of 10 cm, 20 cm, 40 cm, 80 cm, 160 cm, or 200 cm. The terminal device can then determine the preset distance compensation value based on the error values ​​obtained from the multiple calibrations. For example, the average of the error values ​​obtained from the multiple calibrations can be used as the preset distance compensation value.

[0118] In the embodiment of the present application, after the terminal device obtains the spatial distance between the first scene point and the second scene point, it can mark it on the target image and display it to the user, such as Figure 3d As shown, the spatial distance obtained by the terminal device is 9.72641cm. If the user determines that the accuracy of the result is not high, the auxiliary tuning function of the terminal device can be triggered. Accordingly, the terminal device can upload the target image and the information of the first image point and the second image point calibrated by the user to the server. The server may include a preset distance measurement model. Then, the server can use the preset distance measurement model to obtain the spatial distance based on the target image and the information of the first image point and the second image point, and return it to the terminal device, which is displayed to the user. Among them, the distance measurement model in the server can be obtained through artificial intelligence training, which is not specifically limited here.

[0119] The following combination Figure 5 The overall execution process of the ranging method in the embodiment of the present application is described. It should be noted that, Figure 5 The description is only based on the example of the distance measuring device as the terminal device. Figure 5 Shown, including:

[0120] Step 501: After the terminal device determines that the user has triggered the photographing function of the terminal device, the first camera and the second camera are activated and the terminal device enters a ready-to-shoot state.

[0121] In a specific implementation, taking the terminal device as a mobile phone with a touch screen as an example, Figure 6a This is a schematic diagram of the interface display of the terminal device in standby mode. The user can trigger the camera function of the terminal device through touch operation. Figure 6b This is a schematic diagram of the interface when the terminal device enters the shooting state.

[0122] In step 502 , after the terminal device determines that the user has turned on the shooting function switch, it determines whether the ranging function is turned on. If so, step 503 is executed; if not, step 508 is executed.

[0123] Here, after the terminal device enters the shooting state, the shooting function switch and the distance measurement function switch can be displayed on the shooting interface, see Figure 6b As shown, in this way, the user can turn on the shooting function switch and the distance measurement function switch through touch operations.

[0124] It should be noted that in the embodiment of the present application, the terminal device determines whether the ranging function is turned on before the user turns on the shooting function switch, and there is no specific limitation.

[0125] In step 503 , the terminal device uses the first camera and the second camera to shoot the target scene to obtain a target image and a disparity image or a depth image corresponding to the target image.

[0126] Here, the first camera device and the second camera device may both be rear cameras of the terminal device.

[0127] After the terminal device obtains the target image, it can display the target image to the user, such as Figure 6c As shown, the disparity image or depth image corresponding to the target image is only the result of the intermediate processing step performed by the terminal device during the ranging process and does not need to be displayed.

[0128] In step 504 , the terminal device performs point cloud conversion on the disparity image or the depth image to obtain the three-dimensional coordinates of the scene points corresponding to the image points in the target image.

[0129] Here, after the terminal device obtains the three-dimensional coordinates of the scene point corresponding to the image point in the target image, it can be stored first to facilitate subsequent calculation of the spatial distance after the user selects the image point.

[0130] Step 505: The terminal device measures the spatial distance between the scene points corresponding to the two image points selected by the user.

[0131] Here, the user can select two image points on the target image through touch operation, see Figure 6d As shown, there can be many specific selection methods, and the embodiments of the present application do not limit this.

[0132] Specifically, the three-dimensional coordinates of the scene points corresponding to the two image points can be obtained, the initial spatial distance can be obtained according to the Euclidean distance formula, and then the spatial distance can be obtained according to the initial spatial distance and the preset distance compensation value.

[0133] In the embodiment of the present application, after the terminal device enters the waiting state, the calibration function switch can be displayed on the waiting interface. Figure 6b As shown, in this way, the user can turn on the calibration function switch by touching, and accordingly, the terminal device can enter the calibration mode to obtain the preset distance compensation value. Please refer to the above description for details, which will not be repeated here.

[0134] In step 506 , the terminal device marks the measured spatial distance in the target image and displays it to the user.

[0135] Here, see Figure 6d , which illustrates the spatial distance between the scene points corresponding to the two image points selected by the user. The unit can be pre-set, such as cm.

[0136] In step 507, after the terminal device determines that the user has turned on the auxiliary tuning function, it sends the target image and the information of the two image points selected by the user to the server, receives the spatial distance returned by the server, and then updates the spatial distance marked in the target image according to the spatial distance returned by the server.

[0137] Here, after the terminal device enters the shooting state, the auxiliary tuning function switch can be displayed on the shooting interface, see Figure 6b As shown, in this way, the user can turn on the auxiliary tuning function switch through touch operation.

[0138] See also Figure 6e , indicating the updated spatial distance.

[0139] In step 508, the terminal device uses the first camera and the second camera to shoot the target scene to obtain a target image. Here, since the user does not trigger the distance measurement function, the normal shooting process can be performed to obtain the target image.

[0140] It should be noted that (1) the above step numbers are only a possible example of the execution process, and the order of the steps in the specific implementation is not limited; (2) Figure 6bThe positions and implementation methods of the multiple function switches shown are merely examples. In other embodiments, the multiple function switches may be located in other positions or implemented in other ways, without limitation. (3) With respect to the target image, the terminal device may calculate the spatial distance between the scene points of two image points selected by the user multiple times. That is, after the user selects image points a1 and a2 and the terminal device calculates the spatial distance of the corresponding scene, the user may continue to select image points b1 and b2 and the terminal device calculates the spatial distance of the corresponding scene. The specific number of times is not limited.

[0141] According to the above process, the embodiment of the present application realizes the distance measurement function based on the existing terminal camera function, thereby eliminating the need for measuring tools and completing the distance measurement simply and conveniently without increasing the hardware cost of the terminal device.

[0142] It should be noted that the scene point involved in the embodiment of the present application refers to the position corresponding to a certain three-dimensional coordinate in the target scene. For example, assuming Figure 6d The two peaks shown in the figure are the top of the first mountain and the top of the second mountain from left to right. The scene point corresponding to the first image point is the top of the first mountain in the three-dimensional space, and the scene point corresponding to the second image point is the top of the second mountain in the three-dimensional space.

[0143] In accordance with the above method flow, an embodiment of the present application further provides a distance measuring device, and the specific implementation of the distance measuring device can refer to the above method flow.

[0144] Based on the same inventive concept, Figure 7 This is a structural diagram of another distance measuring device provided in an embodiment of the present application. The distance measuring device can be a semiconductor chip (which can be set in a terminal device) or a terminal device. The distance measuring device can be used to perform the above Figure 2 The method flow shown is as follows: Figure 7 As shown, the distance measuring device 700 includes:

[0145] An acquisition unit 701 is configured to acquire a target image and a disparity image or a depth image corresponding to the target image;

[0146] A conversion unit 702 is configured to perform point cloud conversion on the disparity image or the depth image to obtain a point cloud image;

[0147] A processing unit 703 is configured to obtain, based on the point cloud image and the first and second image points in the target image, the three-dimensional coordinates of a first scene point corresponding to the first image point and the three-dimensional coordinates of a second scene point corresponding to the second image point; and obtain, based on the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point, a spatial distance between the first scene point and the second scene point.

[0148] In one possible design, the target image is obtained based on a first image and / or a second image, wherein the first image is obtained by a first camera device photographing the target scene from a first position, and the second image is obtained by a second camera device photographing the target scene from a second position.

[0149] In one possible design, the acquiring unit 701 is specifically configured to:

[0150] A disparity image corresponding to the target image is determined according to disparity values ​​of scene points corresponding to each image point in the target image in the first image and the second image.

[0151] In one possible design, the acquiring unit 701 is specifically configured to:

[0152] Determining a depth value of a scene point corresponding to each image point in the target image;

[0153] A depth image corresponding to the target image is determined according to the depth value of the scene point corresponding to each image point in the target image.

[0154] In one possible design, the focal length of the first camera device is the same as the focal length of the second camera device;

[0155] The acquisition unit 701 is specifically configured to:

[0156] Determine a depth value of the scene point corresponding to each image point in the target image based on a disparity value of the scene point corresponding to each image point in the target image in the first image and the second image, a distance between the first position and the second position, and the focal length.

[0157] In one possible design, the processing unit 703 is specifically configured to:

[0158] Obtaining an initial spatial distance between the first scene point and the second scene point using a Euclidean distance formula according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point;

[0159] The initial spatial distance is used as the spatial distance between the first scene point and the second scene point; or the spatial distance between the first scene point and the second scene point is obtained according to the initial spatial distance and a preset distance compensation value.

[0160] In one possible design, the distance measuring device 700 is a semiconductor chip, and the semiconductor chip is disposed in a terminal device;

[0161] The first camera device and the second camera device are both rear-mounted camera devices of the terminal device; or the first camera device and the second camera device are both front-mounted camera devices of the terminal device.

[0162] In one possible design, the distance measuring device 700 is a terminal device;

[0163] Wherein, the first camera device and the second camera device are both rear-mounted camera devices of the terminal device; or, the first camera device and the second camera device are both front-mounted camera devices of the terminal device.

[0164] It should be noted that the division of units in the embodiments of the present application is illustrative and represents only a logical functional division. Actual implementations may employ alternative division methods. The functional units in the embodiments of the present application may be integrated into a single processing unit, each unit may exist physically as a separate unit, or two or more units may be integrated into a single unit. These integrated units may be implemented in either hardware or software functional units.

[0165] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0166] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0168] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0170] Obviously, those skilled in the art may make various changes and modifications to the embodiments of the present invention without departing from the spirit and scope of this application. Thus, if these modifications and variations of the embodiments of the present invention fall within the scope of the claims of this application and their equivalents, this application is intended to include such modifications and variations.

Claims

1. A distance measurement method, characterized in that: The method comprises: Acquire a target image and a depth image corresponding to the target image; Performing point cloud conversion on the depth image to obtain a point cloud image; detecting a touch operation of a user and determining a first image point and a second image point selected by the user; Obtaining, based on the point cloud image and the first image point and the second image point in the target image, three-dimensional coordinates of a first scene point corresponding to the first image point and three-dimensional coordinates of a second scene point corresponding to the second image point; Obtaining a spatial distance between the first scene point and the second scene point according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point; The performing point cloud conversion on the depth image to obtain a point cloud image includes: The depth value of any image point among the plurality of image points in the target image and the scene point corresponding to the any image point is converted to obtain the three-dimensional coordinates corresponding to the scene point in the point cloud image.

2. The method according to claim 1, characterized in that The target image is obtained based on the first image and / or the second image.

3. The method according to claim 2, characterized in that The first image is obtained by a first camera device photographing a target scene from a first position, and the second image is obtained by a second camera device photographing the target scene from a second position.

4. The method according to any one of claims 1 to 3, characterized in that Obtaining a spatial distance between the first scene point and the second scene point according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point includes: Obtaining an initial spatial distance between the first scene point and the second scene point using a Euclidean distance formula according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point; The initial spatial distance is used as the spatial distance between the first scene point and the second scene point; or the spatial distance between the first scene point and the second scene point is obtained according to the initial spatial distance and a preset distance compensation value.

5. A distance measuring device, characterized in that: The distance measuring device comprises: An acquisition unit, configured to acquire a target image and a depth image corresponding to the target image; a conversion unit, configured to perform point cloud conversion on the depth image to obtain a point cloud image; a processing unit configured to detect a touch operation by a user and determine a first image point and a second image point selected by the user; obtain, based on the point cloud image and the first image point and the second image point in the target image, three-dimensional coordinates of a first scene point corresponding to the first image point and three-dimensional coordinates of a second scene point corresponding to the second image point; and obtain a spatial distance between the first scene point and the second scene point based on the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point; The conversion unit is specifically configured to perform point cloud conversion on any image point among a plurality of image points in the target image and a depth value of a scene point corresponding to the any image point to obtain a three-dimensional coordinate corresponding to the scene point in the point cloud image.

6. The device according to claim 5, characterized in that The target image is obtained based on the first image and / or the second image.

7. The device according to claim 6, characterized in that The first image is obtained by a first camera device photographing a target scene from a first position, and the second image is obtained by a second camera device photographing the target scene from a second position.

8. The device according to any one of claims 5 to 7, characterized in that The processing unit is specifically configured to: Obtaining an initial spatial distance between the first scene point and the second scene point using a Euclidean distance formula according to the three-dimensional coordinates of the first scene point and the three-dimensional coordinates of the second scene point; Using the initial spatial distance as the spatial distance between the first scene point and the second scene point; Alternatively, the spatial distance between the first scene point and the second scene point is obtained according to the initial spatial distance and a preset distance compensation value.

9. The device according to any one of claims 5 to 7, characterized in that The distance measuring device is a terminal device or a semiconductor chip in the terminal device.

10. The device according to claim 9, characterized in that The first camera device and the second camera device are both rear-facing camera devices of the terminal device; or, the first camera device and the second camera device are both front-facing camera devices of the terminal device.

11. A distance measuring device, characterized in that: The device comprises: Memory for storing software programs; A processor, configured to read the software program in the memory and execute the ranging method according to any one of claims 1 to 4.

12. A computer storage medium, characterized in that The storage medium stores a software program, which implements the ranging method according to any one of claims 1 to 4 when read and executed by one or more processors.

Citation Information

Patent Citations

  • Subject matter length measuring method and device

    CN105222717A

  • Anti-fraud face recognition system based on 3D scanning

    CN106384106A

  • Human body dimension measurement method based on Kinect depth camera

    CN106780619A