Distance detection method and device, electronic equipment and computer readable storage medium
Obtain attitude information and images through the movement of terminal equipment, calculate the distance of the object to be tested, and solve the limitations of the implementation of non -contact measurement methods based on image processing at the measurement of the ranging, and achieve higher operating convenience and measurement accuracy.
Patent Information
- Application Number
- CN202411947560.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-01-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The non-contact measurement method based on image processing is susceptible to factors such as light and eye angle during distance measurement, and requires dependence on the cooperation of depth cameras or multiple cameras, which has implementation limitations.
Through the movement of the terminal equipment, obtain the attitude information and location of the camera module during the motion, and use the attitude information and the image to calculate the distance of the object to be tested, reduce the number of cameras required for calculation, and does not rely on the deep camera to perform Distance calculation.
Improve the limitations of the implementation of the distance measurement based on the image, improve the convenience of operation, reduce the hardware demand, and improve the accuracy of measurement.
Smart Images

Figure CN119379801A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of distance measurement technology, and specifically to a distance detection method, device, electronic device, and computer-readable storage medium. Background Art
[0002] Ranging technology refers to various methods and techniques used to measure the distance between two points. These technologies are widely used in many fields, including robot navigation, autonomous driving, geographic information system (GIS), building surveying, industrial automation, etc. According to different application scenarios and requirements, ranging technology can be divided into many types, including laser ranging, ultrasonic ranging, infrared ranging, radio ranging and visual ranging.
[0003] The pupil distance refers to the distance between the centers of the pupils of the two eyes. As an important physiological parameter, it plays an important role in ophthalmology, vision correction, virtual reality (VR), augmented reality (AR) and other fields. For example, in applications such as glasses fitting, visual monitoring, eye tracking, and virtual reality experience, accurate measurement of the pupil distance is of vital importance. Traditional physical measurement methods mainly rely on measuring tools, which are inconvenient to operate and have large errors. The non-contact measurement method based on image processing captures the eye image through a camera and uses image processing algorithms to extract the position of the pupil center to calculate the pupil distance, which can largely eliminate the influence of human operation and tool errors.
[0004] However, in the non-contact measurement method based on image processing, if two-dimensional information is used for distance measurement, it is easily affected by factors such as lighting and eye angle. When distance measurement is based on three-dimensional information, there is a problem of relying on a depth camera or the cooperation of multiple cameras, which leads to the implementation limitations of the non-contact measurement method based on image processing. Summary of the invention
[0005] The embodiments of the present application provide a distance detection method, device, electronic device, and computer-readable storage medium, which can improve the implementation limitations of image-based distance measurement and enhance operational convenience.
[0006] In a first aspect, an embodiment of the present application provides a distance detection method, which is applied to a terminal device, the terminal device including a camera module, and the method includes: During the movement of the terminal device, obtaining posture information of the camera module at at least one position; Acquire a position shot image, wherein the position shot image is an image obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device; The distance of the object to be measured is calculated according to the posture information of each position and the position shooting image to obtain the object distance information.
[0007] In a second aspect, an embodiment of the present application further provides a distance detection device, which is applied to a terminal device, the terminal device includes a camera module, and the device includes: A posture acquisition module, used to acquire posture information of the camera module at at least one position during the movement of the terminal device; An image acquisition module, used to acquire position-captured images, wherein the position-captured images are images obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device; The distance calculation module is used to calculate the distance of the object to be measured according to the posture information of each position and the position shooting image to obtain the object distance information.
[0008] Optionally, in some embodiments of the present application, the terminal device is provided with an inertial measurement module, and the acquiring of the posture information of the camera module at at least one position during the movement of the terminal device includes: During the movement of the terminal device, the posture information of the camera module at at least one position is calculated by the inertial measurement module.
[0009] Optionally, in some embodiments of the present application, the step of calculating the distance of the object to be measured according to the posture information of each position and the position captured image to obtain the object distance information includes: Determine the image object position information of the object to be measured in the images taken at each position; Calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position; Object distance information is generated according to the three-dimensional space coordinates.
[0010] Optionally, in some embodiments of the present application, the calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position includes: Acquire a three-dimensional coordinate solution model, wherein the three-dimensional coordinate solution model is constructed based on the two-dimensional coordinate representation, the three-dimensional coordinate representation and the intrinsic parameters of the camera module; The three-dimensional coordinate solution model is solved according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured.
[0011] Optionally, in some embodiments of the present application, the construction of the three-dimensional coordinate solution model includes: generating a first homogeneous coordinate representation corresponding to the two-dimensional coordinate representation, and generating a second homogeneous coordinate representation corresponding to the three-dimensional coordinate representation; Establishing a homogeneous coordinate conversion relationship according to the first homogeneous coordinate representation, the second homogeneous coordinate representation and the intrinsic parameters of the camera module; Determine the variable to be solved according to the second homogeneous coordinate representation; The two-dimensional coordinate representation and the variables to be solved are substituted into the homogeneous coordinate transformation relationship, and the homogeneous coordinate transformation relationship is subjected to formula transformation processing to obtain a three-dimensional coordinate solution model.
[0012] Optionally, in some embodiments of the present application, the second homogeneous coordinate representation includes a four-dimensional coordinate representation obtained by converting the three-dimensional coordinate representation, and the three-dimensional coordinate solution model is solved according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured, including: Solving the three-dimensional coordinate solution model according to the posture information of each position and the image object position information to obtain a four-dimensional solution vector, wherein the four-dimensional solution vector corresponds to the solution of the variable to be solved; The first three-dimensional vectors in the four-dimensional solution vector are respectively subjected to quotient operations with the last dimensional vector to obtain the three-dimensional space coordinates of the object to be measured.
[0013] Optionally, in some embodiments of the present application, the object to be measured includes two pupils, and generating the object distance information according to the three-dimensional space coordinates includes: The pupil distance between the two pupils is calculated according to the three-dimensional spatial coordinates of the two pupils.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps in the above-mentioned distance detection method when executed by the processor.
[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned distance detection method are implemented.
[0016] In a fifth aspect, the embodiments of the present application further provide a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations described in the embodiments of the present application.
[0017] The terminal device of the embodiment of the present application includes a camera module. During the movement of the terminal device, posture information of the camera module at at least one position is obtained, and a position-shot image is obtained. The position-shot image is an image obtained by photographing the object to be measured at various positions by the camera module during the movement of the terminal device. The distance to the object to be measured is calculated based on the posture information at each position and the position-shot image to obtain the object distance information.
[0018] Among them, the distance is calculated by moving the terminal device and taking images based on the posture information and positions of multiple positions during the movement, instead of the traditional solution that requires multiple cameras to be set up at multiple positions and take images separately to calculate the distance. The embodiment of the present application reduces the number of cameras required for distance calculation and does not need to rely on depth cameras for distance calculation, thereby improving the implementation limitations of image-based distance measurement and enhancing operational convenience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 is a schematic diagram of a scenario in which a terminal device according to an embodiment of the present application performs the distance detection method; Figure 2 is a flow chart of a distance detection method provided in an embodiment of the present application; Figure 3 is a schematic diagram of measuring pupil distance provided in an embodiment of the present application; Figure 4 is a schematic diagram of the structure of a distance detection device provided in an embodiment of the present application; Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0021] Description of Figure Numbers: 10-terminal device; A-left eye pupil center; B-right eye pupil center; 201-gesture acquisition module; 202-image acquisition module; 203-distance calculation module; 301-processor; 302-memory; 303-power supply; 304-input unit. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0023] The embodiments of the present application provide a distance detection method, device, electronic device and computer-readable storage medium. Specifically, the embodiments of the present application provide a distance detection device suitable for electronic devices, which is used to improve the implementation limitations of distance measurement based on images and improve the convenience of operation. Specifically, the electronic device includes a terminal device with image acquisition, posture information acquisition and data processing capabilities, and the terminal device includes an extended reality device, which includes but is not limited to a head-mounted display, wearable glasses, and the terminal device can also be an integrated terminal device built into a computing and processing unit, or a split terminal device external to the computing and processing unit. Among them, the terminal device includes but is not limited to an airborne optical display system, i.e., a head-up display system, applied to vehicles such as aircraft, cars, and ships, for example, an AR-HUD (Augmented reality hud-up display) mounted on an intelligent networked car, an extended reality application applied to handheld mobile devices such as mobile phones, laptops, and tablets (such as extended reality games, virtual tourism, telemedicine or virtual experiments, etc.), and a near-eye display system applied to wearable devices such as head-mounted displays and smart glasses.
[0024] See also Figure 1 , Figure 1 : is a schematic diagram of a scenario in which a terminal device according to an embodiment of the present application performs the distance detection method, wherein the specific execution process of the terminal device performing the distance detection method is as follows: During the movement of the terminal device 10, the posture information of the camera module of the terminal device at at least one position is obtained, and during the movement, the camera module is used to photograph the object to be measured to obtain position images of each position, and the distance of the object to be measured is calculated based on the posture information of each position and the position images of each position to obtain the object distance information.
[0025] Among them, during the movement of the terminal device, its movement trajectory includes multiple positions of movement, and the terminal device at each position is equivalent to the cameras set at multiple positions in the traditional solution, and the setting of multiple cameras is replaced by the movement of the terminal device.
[0026] In summary, the embodiments of the present application calculate the distance by moving the terminal device and taking images based on the posture information and positions of multiple positions during the movement, instead of the traditional solution that requires setting up multiple cameras at multiple positions and taking images separately to calculate the distance. The embodiments of the present application reduce the number of cameras required for distance calculation and do not need to rely on depth cameras for distance calculation, thereby improving the implementation limitations of image-based distance measurement and enhancing operational convenience.
[0027] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.
[0028] See also Figure 2 , Figure 2 A flow chart of a distance detection method provided in an embodiment of the present application. Although a logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in an order different from that shown in the flow chart. Specifically, the execution subject of the distance detection method is a terminal device, and the terminal device includes a camera module. Specifically, the process of the terminal device executing the distance detection method specifically includes: 101. During the movement of the terminal device, obtain posture information of the camera module at at least one position.
[0029] It is understandable that the movement of the terminal device drives the movement of the camera module, and the camera module will have multiple posture information at multiple positions during the movement of the terminal device. The posture information of the camera module at multiple positions is equivalent to the posture information of multiple cameras at multiple positions, so that the movement of a single camera module can replace multiple cameras at multiple positions, reducing the number of required cameras.
[0030] 102. Acquire a position-captured image, where the position-captured image is an image obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device.
[0031] It can be understood that the position captured image is obtained by photographing the object to be measured by the camera module during the movement of the terminal device, and the position captured image corresponds one-to-one with the aforementioned posture information, that is, during the movement of the terminal device, the camera module corresponds to the posture information and the position captured image at the same position at the same time.
[0032] The object to be measured is an object that needs to be distance measured or detected. For example, if the object to be measured includes a physical tool, the distance to be measured is the distance between the two ends of the physical tool, and if the object to be measured also includes pupils, the distance to be measured is the distance between the centers of the two pupils.
[0033] It should be noted that in the embodiment of the present application, the camera module includes a monocular camera, and distance measurement can be performed by obtaining a two-dimensional image through the monocular camera, without the need for a depth camera or a binocular camera, thereby further reducing the equipment requirements or equipment costs when performing distance measurement based on images.
[0034] 103. Calculate the distance of the object to be measured according to the posture information of each position and the position shot image to obtain object distance information.
[0035] The object distance information refers to the distance of the object to be measured, such as the distance between the centers of two pupils. It can be understood that by superimposing multiple sets of posture information and position-shot images at multiple positions, the distance to the object to be measured can be measured.
[0036] In summary, the embodiments of the present application calculate the distance by moving the terminal device and taking images based on the posture information and positions of multiple positions during the movement, instead of the traditional solution that requires setting up multiple cameras at multiple positions and taking images separately to calculate the distance. The embodiments of the present application reduce the number of cameras required for distance calculation and do not need to rely on depth cameras for distance calculation, thereby improving the implementation limitations of image-based distance measurement and enhancing operational convenience.
[0037] For example, taking pupil distance measurement as an example, see Figure 3 , Figure 3 It is a schematic diagram of measuring pupil distance provided in an embodiment of the present application. Specifically, the handheld terminal device moves in front of the eyes, and during the movement, the camera module is ensured to be able to capture the position of both eyes, and the posture information and position-shot images of multiple positions are obtained during the movement, and the pupil distance is calculated based on the posture information and position-shot images of the multiple positions.
[0038] Optionally, in an embodiment of the present application, an inertial measurement module may be used to obtain the posture information of the camera module. That is, optionally, in some embodiments of the present application, the terminal device is provided with an inertial measurement module, and the step of "obtaining the posture information of the camera module at at least one position during the movement of the terminal device" includes: During the movement of the terminal device, the posture information of the camera module at at least one position is calculated by the inertial measurement module.
[0039] For example, the inertial measurement module includes an inertial sensor IMU, which acquires the posture information of the camera module in a defined world coordinate system in real time through an inertial visual positioning algorithm (VIO, Visual-Inertial Odometry) based on the IMU and the camera module, that is, acquires the posture information of the camera module at multiple positions during the movement through the IMU.
[0040] For example, see Figure 3 , sample three different positions respectively, and the postures of these three positions in the world coordinate system G are , and The sampling time corresponding to each posture is , and , accordingly, the posture information of the camera module at each position during the movement of the terminal device can be expressed as:
[0041] Among them, R represents the rotation parameter, t represents the translation parameter, and R and t constitute the representation of the posture parameter.
[0042] Optionally, in an embodiment of the present application, in order to improve the accuracy of distance measurement of the object to be measured, the three-dimensional spatial coordinates of the object to be measured can be calculated, and the distance of the object to be measured can be calculated based on the three-dimensional spatial coordinates. Correspondingly, the position information of the object to be measured in the image can be extracted from the position-captured image, and the three-dimensional spatial coordinates can be calculated based on the position information and the posture information of the camera module. That is, optionally, in some embodiments of the present application, the step of "calculating the distance of the object to be measured according to the posture information of each position and the position-captured image to obtain the object distance information" includes: Determine the image object position information of the object to be measured in the images taken at each position; Calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position; Object distance information is generated according to the three-dimensional space coordinates.
[0043] The image object position information indicates the pixel coordinates of the object to be measured in the image. For example, taking the pupil as an example, during the movement of the terminal device, , and The pixel points of the left eye pupil center A and the right eye pupil center B at the moment are: , and Among them, the pupil center at each moment during the movement of the terminal device can be expressed as: and for the center of the pupil of the right eye . Where u and v represent the pixel coordinates in the image coordinate system.
[0044] Among them, the image object position information can be detected through image processing technology (including traditional methods or deep learning methods), which is not limited here.
[0045] Correspondingly, after obtaining the posture information and image object position information of each position, the three-dimensional space coordinates of the object to be measured can be calculated based on the visual processing solution, for example, the three-dimensional space coordinates of the object to be measured are solved by a three-dimensional coordinate solution model based on the parameters in the camera module, that is, optionally, in some embodiments of the present application, the step of "calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position" includes: Acquire a three-dimensional coordinate solution model, wherein the three-dimensional coordinate solution model is constructed based on the two-dimensional coordinate representation, the three-dimensional coordinate representation and the intrinsic parameters of the camera module; The three-dimensional coordinate solution model is solved according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured.
[0046] Among them, the three-dimensional coordinate solution model obtained based on the two-dimensional coordinate representation and the three-dimensional coordinate representation helps to realize the conversion between two-dimensional coordinates and three-dimensional coordinates, and realize the solution of three-dimensional space coordinates. Among them, the three-dimensional space coordinates are solved by using the three-dimensional coordinate solution model based on the intrinsic parameters of the camera module, thereby improving the accuracy of the solved three-dimensional space coordinates.
[0047] Accordingly, in order to facilitate the mapping transformation of coordinates, homogeneous coordinates can be combined for processing during the solution process, and a three-dimensional coordinate solution model is constructed based on the conversion relationship between the homogeneous coordinates corresponding to the two-dimensional coordinate identifier and the homogeneous coordinates corresponding to the three-dimensional coordinate identifier. That is, optionally, in some embodiments of the present application, the construction of the three-dimensional coordinate solution model includes: generating a first homogeneous coordinate representation corresponding to the two-dimensional coordinate representation, and generating a second homogeneous coordinate representation corresponding to the three-dimensional coordinate representation; Establishing a homogeneous coordinate conversion relationship according to the first homogeneous coordinate representation, the second homogeneous coordinate representation and the intrinsic parameters of the camera module; Determine the variable to be solved according to the second homogeneous coordinate representation; The two-dimensional coordinate representation and the variables to be solved are substituted into the homogeneous coordinate transformation relationship, and the homogeneous coordinate transformation relationship is subjected to formula transformation processing to obtain a three-dimensional coordinate solution model.
[0048] For example, the three-dimensional coordinates of the left eye pupil center A in the world coordinate system G are expressed as , the three-dimensional coordinates of the right eye pupil center B in the world coordinate system G are expressed as , taking the intrinsic parameters of the camera module (corresponding to the intrinsic parameter matrix, including focal length and principal point) K as an example, the three-dimensional coordinate representation of the left eye pupil center A corresponds to the second homogeneous coordinate representation as follows: , the first homogeneous coordinate corresponding to the pixel value (two-dimensional coordinate representation) of the left pupil center A is expressed as , then in At the moment (where i starts counting with the value 0 and continues until the end of the movement), for the left eye pupil center A, we have:
[0049] Where α is the scale factor, M is a 3×4 matrix, , T includes the rotation parameter R and the translation parameter t. Assume:
[0050] in, is the shorthand for the first homogeneous coordinate representation, The second homogeneous coordinates of the left pupil center A represent the corresponding variables to be solved, then:
[0051] Among them, since both sides in the above formula are vectors, the cross product of the vectors on the left and right sides is 0, so: Further simplifying the above formula yields: ,in,
[0052] Correspondingly, we can superimpose , and The observation values at three moments (such as the posture information of the terminal device at three moments during its motion and the pixel values of the object to be measured) are based on Solve to obtain the variable to be solved for the left eye pupil center A Similarly, the above method can also be used to solve the variables to be solved for the right eye pupil center B: .
[0053] Among them, since the variables to be solved are and the variables to be solved are homogeneous coordinates, as assumed above. , which corresponds to a 4×1-dimensional vector, therefore, the three-dimensional space coordinates of the object to be measured are obtained by dividing the first three-dimensional vector by the last dimensional vector. and .
[0054] That is, the second homogeneous coordinate representation includes a four-dimensional coordinate representation obtained by converting the three-dimensional coordinate representation, and the step of "solving the three-dimensional coordinate solution model according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured" includes: Solving the three-dimensional coordinate solution model according to the posture information of each position and the image object position information to obtain a four-dimensional solution vector, wherein the four-dimensional solution vector corresponds to the solution of the variable to be solved; The first three-dimensional vectors in the four-dimensional solution vector are respectively subjected to quotient operations with the last dimensional vector to obtain the three-dimensional space coordinates of the object to be measured.
[0055] Then, we get the three-dimensional space coordinates and After that, the distance of the object to be measured (such as pupil distance) can be calculated. .
[0056] Among them, it should be emphasized that since the inertial vision positioning algorithm based on IMU can provide a continuous positioning trajectory when detecting the pupil distance, multiple different positions (that is, more than three positions) can be used to measure the distance to the pupil distance center, thereby achieving the effect of improving accuracy, improving the accuracy of the calculated three-dimensional space coordinates, and thus improving the accuracy of the distance information of the object to be measured.
[0057] In summary, the embodiments of the present application calculate the distance by moving the terminal device and taking images based on the posture information and positions of multiple positions during the movement, instead of the traditional solution that requires setting up multiple cameras at multiple positions and taking images separately to calculate the distance. The embodiments of the present application reduce the number of cameras required for distance calculation and do not need to rely on depth cameras for distance calculation, thereby improving the implementation limitations of image-based distance measurement and enhancing operational convenience.
[0058] Among them, by calculating the posture information of the camera module based on the inertial measurement module, the accuracy of the posture information calculation is improved, and the calculation of the posture information of the camera module at various positions during the movement of the terminal device is realized, providing a feasible basis for the terminal device to realize distance measurement of the object to be measured based on movement.
[0059] Among them, in the embodiment of the present application, the camera module only needs to have the ability to capture images. Therefore, in the embodiment of the present application, the camera module can use a monocular camera to reduce the hardware requirements or equipment requirements for image-based distance measurement, improve the implementation limitations of image-based distance measurement, and enhance operational convenience.
[0060] In order to better implement the distance detection method of the present application, the present application also provides a distance detection device based on the above distance detection method. The meanings of the terms are the same as those in the above distance detection method, and the specific implementation details can refer to the description in the method embodiment.
[0061] See also Figure 4 , Figure 4: is a schematic diagram of the structure of a distance detection device provided in an embodiment of the present application. The distance detection device is applied to a terminal device, and the terminal device includes a camera module. The distance detection device can be specifically as follows: A posture acquisition module 201, used to acquire posture information of the camera module at at least one position during the movement of the terminal device; An image acquisition module 202 is used to acquire a position-captured image, wherein the position-captured image is an image obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device; The distance calculation module 203 is used to calculate the distance of the object to be measured according to the posture information of each position and the position shooting image to obtain the object distance information.
[0062] Optionally, in some embodiments of the present application, the terminal device is provided with an inertial measurement module, and the acquiring of the posture information of the camera module at at least one position during the movement of the terminal device includes: During the movement of the terminal device, the posture information of the camera module at at least one position is calculated by the inertial measurement module.
[0063] Optionally, in some embodiments of the present application, the step of calculating the distance of the object to be measured according to the posture information of each position and the position captured image to obtain the object distance information includes: Determine the image object position information of the object to be measured in the images taken at each position; Calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position; Object distance information is generated according to the three-dimensional space coordinates.
[0064] Optionally, in some embodiments of the present application, the step of calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position includes: Acquire a three-dimensional coordinate solution model, wherein the three-dimensional coordinate solution model is constructed based on the two-dimensional coordinate representation, the three-dimensional coordinate representation and the intrinsic parameters of the camera module; The three-dimensional coordinate solution model is solved according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured.
[0065] Optionally, in some embodiments of the present application, the construction of the three-dimensional coordinate solution model includes: generating a first homogeneous coordinate representation corresponding to the two-dimensional coordinate representation, and generating a second homogeneous coordinate representation corresponding to the three-dimensional coordinate representation; Establishing a homogeneous coordinate conversion relationship according to the first homogeneous coordinate representation, the second homogeneous coordinate representation and the intrinsic parameters of the camera module; Determine the variable to be solved according to the second homogeneous coordinate representation; The two-dimensional coordinate representation and the variables to be solved are substituted into the homogeneous coordinate transformation relationship, and the homogeneous coordinate transformation relationship is subjected to formula transformation processing to obtain a three-dimensional coordinate solution model.
[0066] Optionally, in some embodiments of the present application, the second homogeneous coordinate representation includes a four-dimensional coordinate representation obtained by converting the three-dimensional coordinate representation, and the three-dimensional coordinate solution model is solved according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured, including: Solving the three-dimensional coordinate solution model according to the posture information of each position and the image object position information to obtain a four-dimensional solution vector, wherein the four-dimensional solution vector corresponds to the solution of the variable to be solved; The first three-dimensional vectors in the four-dimensional solution vector are respectively subjected to quotient operations with the last dimensional vector to obtain the three-dimensional space coordinates of the object to be measured.
[0067] Optionally, in some embodiments of the present application, the object to be measured includes two pupils, and generating the object distance information according to the three-dimensional space coordinates includes: The pupil distance between the two pupils is calculated according to the three-dimensional spatial coordinates of the two pupils.
[0068] In the embodiment of the present application, the posture acquisition module 201 acquires the posture information of the camera module at at least one position during the movement of the terminal device, and the image acquisition module 202 acquires the position-captured image, which is an image obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device. The distance calculation module 203 calculates the distance of the object to be measured based on the posture information of each position and the position-captured image to obtain the object distance information.
[0069] Among them, the embodiments of the present application calculate the distance through the movement of the terminal device and the posture information and position images taken at multiple positions during the movement, instead of the traditional solution that requires multiple cameras to be set up at multiple positions and images to be taken separately to calculate the distance. The embodiments of the present application reduce the number of cameras required for distance calculation and do not need to rely on depth cameras for distance calculation, thereby improving the implementation limitations of image-based distance measurement and enhancing operational convenience.
[0070] In addition, the present application also provides an electronic device, such as Figure 5 As shown, it shows a schematic diagram of the structure of the electronic device involved in this application, specifically: The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will appreciate that Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. The processor 301 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301.
[0071] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and distance detection by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0072] The electronic device also includes a power supply 303 for supplying power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 303 can also include any components such as one or more DC or AC power supplies, recharging systems, power supply device debugging circuits, power converters or inverters, and power status indicators.
[0073] The electronic device may further include an input unit 304, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0074] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 301 in the electronic device will load the executable file corresponding to the process of one or more application programs into the memory 302 according to the following instructions, and the processor 301 will run the application program stored in the memory 302, thereby implementing the steps in any distance detection method provided in the embodiments of the present application.
[0075] Among them, in the embodiment of the present application, the electronic device (terminal device) can also be an extended reality device, and the distance measurement of the object to be measured is performed through the inertial measurement module and the camera module on the extended reality device. Among them, the extended reality device includes smart glasses in the form of natural glasses, and the smart glasses have at least the functions of extended reality display, wearing status detection, biometric recognition, human-computer interaction, data processing, etc. It includes a frame, temples, processors, sensors, optical display components, microphones, speakers, etc. There are cavities inside the temples and frames, and circuits and electronic components are placed in the cavities. Sensors include cameras, eye trackers, iris meters, IMUs, gyroscopes, etc. The optical display components include micro-projection optical machines and optical couplers. The micro-projection optical machine can be based on Micro-Oled, Micro-Led, LCOS, or LBS. The optical coupler can be an optical lens or an optical waveguide. The processor can be an XR professional processor or an ordinary general-purpose processor. The frame and temples are the supporting structure of the entire glasses. The temples have a certain degree of elasticity, and the length and clamping force can be adjusted to suit users with different head shapes; the camera can take pictures of the user's hands, face, eyes, etc., the microphone can listen to the user's voice, and the processor can calculate and process various data.
[0076] The terminal device of the embodiment of the present application includes a camera module. During the movement of the terminal device, posture information of the camera module at at least one position is obtained, and a position-shot image is obtained. The position-shot image is an image obtained by photographing the object to be measured at various positions by the camera module during the movement of the terminal device. The distance to the object to be measured is calculated based on the posture information at each position and the position-shot image to obtain the object distance information.
[0077] Among them, the distance is calculated by moving the terminal device and taking images based on the posture information and positions of multiple positions during the movement, instead of the traditional solution that requires multiple cameras to be set up at multiple positions and take images separately to calculate the distance. The embodiment of the present application reduces the number of cameras required for distance calculation and does not need to rely on depth cameras for distance calculation, thereby improving the implementation limitations of image-based distance measurement and enhancing operational convenience.
[0078] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0079] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0080] To this end, the present application provides a computer-readable storage medium, on which a computer program is stored. The computer program can be loaded by a processor to execute the steps in any distance detection method provided in the present application.
[0081] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0082] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0083] Since the instructions stored in the computer-readable storage medium can execute the steps in any distance detection method provided in the present application, the beneficial effects that can be achieved by any distance detection method provided in the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0084] The above is a detailed introduction to a distance detection method, device, electronic device and computer-readable storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A distance detection method, characterized in that: Applied to a terminal device, the terminal device includes a camera module, and the method includes: During the movement of the terminal device, obtaining posture information of the camera module at at least one position; Acquire a position shot image, wherein the position shot image is an image obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device; The distance of the object to be measured is calculated according to the posture information of each position and the position shooting image to obtain the object distance information.
2. The distance detection method according to claim 1, characterized in that: The terminal device is provided with an inertial measurement module, and during the movement of the terminal device, obtaining the posture information of the camera module at at least one position includes: During the movement of the terminal device, the posture information of the camera module at at least one position is calculated by the inertial measurement module.
3. The distance detection method according to claim 1, characterized in that: The step of calculating the distance of the object to be measured according to the posture information of each position and the position captured image to obtain the object distance information includes: Determine the image object position information of the object to be measured in the images taken at each position; Calculating the three-dimensional space coordinates of the object to be measured according to the posture information of each position and the image object position information of each position; Object distance information is generated according to the three-dimensional space coordinates.
4. The distance detection method according to claim 3, characterized in that: The step of calculating the three-dimensional spatial coordinates of the object to be measured according to the posture information of each position and the image object position information of each position includes: Acquire a three-dimensional coordinate solution model, wherein the three-dimensional coordinate solution model is constructed based on the two-dimensional coordinate representation, the three-dimensional coordinate representation and the intrinsic parameters of the camera module; The three-dimensional coordinate solution model is solved according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured.
5. The distance detection method according to claim 4, characterized in that: The construction of the three-dimensional coordinate solution model includes: generating a first homogeneous coordinate representation corresponding to the two-dimensional coordinate representation, and generating a second homogeneous coordinate representation corresponding to the three-dimensional coordinate representation; Establishing a homogeneous coordinate conversion relationship according to the first homogeneous coordinate representation, the second homogeneous coordinate representation and the intrinsic parameters of the camera module; Determine the variable to be solved according to the second homogeneous coordinate representation; The two-dimensional coordinate representation and the variables to be solved are substituted into the homogeneous coordinate transformation relationship, and the homogeneous coordinate transformation relationship is subjected to formula transformation processing to obtain a three-dimensional coordinate solution model.
6. The distance detection method according to claim 5, characterized in that: The second homogeneous coordinate representation includes a four-dimensional coordinate representation obtained by converting the three-dimensional coordinate representation, and solving the three-dimensional coordinate solution model according to the posture information of each position and the image object position information to obtain the three-dimensional space coordinates of the object to be measured includes: Solving the three-dimensional coordinate solution model according to the posture information of each position and the image object position information to obtain a four-dimensional solution vector, wherein the four-dimensional solution vector corresponds to the solution of the variable to be solved; The first three-dimensional vectors in the four-dimensional solution vector are respectively subjected to quotient operations with the last dimensional vector to obtain the three-dimensional space coordinates of the object to be measured.
7. The distance detection method according to claim 3, characterized in that: The object to be measured includes two pupils, and generating object distance information according to the three-dimensional space coordinates includes: The pupil distance between the two pupils is calculated according to the three-dimensional spatial coordinates of the two pupils.
8. A distance detection device, characterized in that: Applied to a terminal device, the terminal device includes a camera module, and the device includes: A posture acquisition module, used to acquire posture information of the camera module at at least one position during the movement of the terminal device; An image acquisition module, used to acquire position-captured images, wherein the position-captured images are images obtained by photographing the object to be measured at each position by the camera module during the movement of the terminal device; The distance calculation module is used to calculate the distance of the object to be measured according to the posture information of each position and the position shooting image to obtain the object distance information.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the distance detection method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the distance detection method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Image processing method and terminal
CN105376484A
Data processing method, MEC server and terminal equipment
CN109413409A
Fault positioning method, device and equipment for photovoltaic module and storage medium
CN117478065A
System and method for measuring location of moving object based on artificial intelligence
US20230186493A1