Ranging method and apparatus
By acquiring multiple frames of images from foldable screen electronic devices and combining them with imaging focal length and distance information, the target distance is calculated using the least squares method and the Gauss-Newton method, which solves the problem of large errors in existing ranging methods and achieves higher measurement accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- VIVO MOBILE COMM CO LTD
- Filing Date
- 2022-09-23
- Publication Date
- 2026-04-10
AI Technical Summary
Existing ranging methods, which measure distance using the parallax of two cameras, are easily affected by external lighting conditions and camera angles, resulting in large measurement errors and low accuracy.
Electronic devices that employ foldable screens and camera modules can reduce computational complexity and the need for camera calibration by acquiring multiple frames of images and using the imaging focal length, preset distance, and distance from the imaging point to the axis, combined with the least squares method and the Gauss-Newton method to calculate the target distance.
It improves the accuracy of measuring the distance between the target object and the electronic device and reduces measurement errors.
Smart Images

Figure CN115545999B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of terminal devices, and particularly relates to a ranging method and device. BACKGROUND
[0002] With more and more functions of electronic devices, electronic devices are more and more indispensable in life. In combination with the shooting function of electronic devices, users can also use electronic devices for ranging, specifically the distance between a target object and an electronic device.
[0003] In existing ranging methods, applications of ranging by two cameras are more and more widely used. In specific measurement, the parallax of two cameras is taken as a basis, and a large amount of matching calculation is performed on images obtained by the two cameras, so as to obtain a measurement result. Since the external light conditions and the angle of view of the camera will affect the calculation in the measurement process, the existing ranging method is prone to large measurement errors, and the accuracy of the measurement result is low. SUMMARY
[0004] The purpose of the embodiments of the present application is to provide a ranging method and device, which can reduce measurement errors and improve the accuracy of the distance between a measurement target object and an electronic device.
[0005] In a first aspect, the embodiments of the present application provide a ranging method, which is executed by an electronic device, the electronic device comprising a folding screen and a camera module, the folding screen comprising a first screen and a second screen rotating along an axis, the camera module comprising a first camera and a second camera, the first camera rotating with the first screen, and the second camera rotating with the second screen; the method comprising:
[0006] obtaining a first image and N frames of second images, wherein the first image is obtained by the first camera according to first preset shooting parameters for shooting a target object, the N frames of second images are obtained by the second camera according to second preset shooting parameters for shooting the target object, the first preset shooting parameters comprise a first preset distance of the first camera from the axis and an imaging focal length, and the second preset shooting parameters comprise a second preset distance of the second camera from the axis and the imaging focal length;
[0007] obtaining a first distance from the axis of a first imaging point of the target object in the first image and a second distance from the axis of a second imaging point of the target object in each frame of the second images, wherein the first distance is the distance of the first imaging point from the axis along the extension direction of the first imaging plane, and the second distance is the distance of the second imaging point from the axis along the extension direction of the second imaging plane;
[0008] determining a target distance of the target object from the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and N second distances.
[0009] In a second aspect, an embodiment of the present application provides a ranging device, which is applied to an electronic device, the electronic device comprising a folding screen and a camera module, the folding screen comprising a first screen and a second screen rotating along an axis, the camera module comprising a first camera and a second camera, the first camera rotating with the first screen, and the second camera rotating with the second screen; the device comprising:
[0010] an acquisition module, configured to acquire a first image and N frames of second images, wherein the first image is obtained by the first camera from photographing a target object according to first preset photographing parameters, the N frames of second images are obtained by the second camera from photographing the target object according to second preset photographing parameters, the first preset photographing parameters comprise a first preset distance between the first camera and the axis and an imaging focal length, and the second preset photographing parameters comprise a second preset distance between the second camera and the axis and the imaging focal length;
[0011] the acquisition module is further configured to acquire a first distance from a first imaging point of the target object in the first image to the axis and a second distance from a second imaging point of the target object in each frame of the second images to the axis, wherein the first distance is a distance from the first imaging point to the axis along an extension direction of a first imaging plane, and the second distance is a distance from the second imaging point to the axis along an extension direction of a second imaging plane;
[0012] a processing module, configured to determine a target distance from the target object to the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance and the N second distances.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, which comprises a processor and a memory, the memory storing programs or instructions executable on the processor, and the programs or instructions are executed by the processor to implement the steps of the method according to the first aspect.
[0014] In a fourth aspect, an embodiment of the present application provides a readable storage medium, which stores programs or instructions, and the programs or instructions are executed by a processor to implement the steps of the method according to the first aspect.
[0015] In a fifth aspect, an embodiment of the present application provides a chip, which comprises a processor and a communication interface, the communication interface and the processor being coupled, the processor being configured to run programs or instructions to implement the method according to the first aspect.
[0016] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium, and the program product is executed by at least one processor to implement the method according to the first aspect.
[0017] In the embodiment of the present application, the electronic device includes a folding screen and a camera module, the folding screen includes a first screen and a second screen rotating along an axis, and the camera module includes a first camera and a second camera. In the distance measurement process, a first image and N frames of second images are obtained, wherein the first image is obtained by the first camera shooting the target object according to first preset shooting parameters, and the second image is obtained by the second camera shooting the target object according to second preset shooting parameters. Next, the distance information from the imaging point of the target object in the first image and the N frames of second images to the axis, and the first preset distance of the first camera to the axis, the second preset distance of the second camera to the axis and the imaging focal length included in the preset shooting parameters are used for calculation to determine the target distance from the target object to the electronic device. Wherein, by introducing multiple frames of second images for distance calculation, the requirement for calculation complexity and camera calibration when using two cameras for distance measurement is reduced, thereby reducing the measurement error and improving the accuracy of measuring the distance between the target object and the electronic device. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 is a structural schematic diagram of an electronic device provided by an embodiment of the present application;
[0019] Figure 2 is a flowchart of a distance measurement method provided by an embodiment of the present application;
[0020] Figure 3 is an imaging schematic diagram of a target object provided by an embodiment of the present application;
[0021] Figure 4 is a bounding box display schematic diagram provided by an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of a preset sliding window provided by an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of a target sliding window provided by an embodiment of the present application;
[0024] Figure 7 is a schematic diagram of a preset direction provided by an embodiment of the present application;
[0025] Figure 8 is a gradient direction schematic diagram of a pixel point provided by an embodiment of the present application;
[0026] Figure 9 is a sliding schematic diagram of a first target image provided by an embodiment of the present application;
[0027] Figure 10 is a structural schematic diagram of a distance measurement shooting device provided by an embodiment of the present application;
[0028] Figure 11 This is a schematic diagram of the structure of another electronic device provided in an embodiment of this application;
[0029] Figure 12 This is a schematic diagram of the hardware structure of another electronic device provided in the embodiments of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0031] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0032] As electronic devices become increasingly multifunctional, they are becoming more and more indispensable in our lives. Combined with their camera functions, users can also use electronic devices for distance measurement, such as the distance between a target object and the device itself.
[0033] Among existing distance measurement methods, the use of two cameras is becoming increasingly widespread. In practice, the parallax between the two cameras is used as a basis for extensive matching calculations on the images captured by both cameras to obtain the measurement result. However, because external lighting conditions and the camera's angle of view both affect the calculations during the measurement process, existing distance measurement methods are prone to significant measurement errors, resulting in low accuracy.
[0034] To address this, embodiments of this application provide a ranging method and apparatus that can reduce measurement errors and improve the accuracy of measuring the distance between a target object and an electronic device. The ranging method provided by these embodiments will be described in detail below with reference to the accompanying drawings and specific examples and application scenarios.
[0035] In the embodiments of the present application, the distance measurement method can be performed by an electronic device including a folding screen and a camera module. The folding screen of the electronic device can be inward folding or outward folding, for example. The folding mode of the folding screen of the electronic device can also be single folding or multiple folding. For example, the folding screen can be divided into at least two screens in the folded state. For example, the folding screen includes two screen areas, which can be obtained by folding the folding screen upward and downward, or by folding the folding screen leftward and rightward. In another example, the two screen areas can also be designed as an outer folding display screen or an inner folding display screen, or a combination of the outer folding display screen and the inner folding display screen, which is not limited here.
[0036] The camera module includes at least two cameras, which can be located in different folding parts of the electronic device. Specifically, the first camera rotates with the first screen, and the second camera rotates with the second screen.
[0037] For example, folding leftward and rightward, Figure 1 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. As shown in Figure 1 , the folding screen includes a first screen 102 and a second screen 103 which can rotate along an axis 101. The camera module can include a first camera and a second camera. For example, the first camera and the second camera can be rear cameras; the first camera and the second camera can also be front cameras, which are not limited here. The first camera rotates with the first screen 102, and the second camera rotates with the second screen 103.
[0038] Figure 2 is a flowchart of a distance measurement method provided by an embodiment of the present application. The distance measurement method can be applied to an electronic device including at least two screens, and the interface display method can include the following steps 210 to 230.
[0039] Step 210: obtaining a first image and N frames of second images.
[0040] The first image is obtained by the first camera according to a first preset shooting parameter, and the N frames of second images are obtained by the second camera according to a second preset shooting parameter. The first preset shooting parameter includes a first preset distance between the first camera and the axis and an imaging focal length, and the second preset shooting parameter includes a second preset distance between the second camera and the axis and an imaging focal length.
[0041] Specifically, the first camera can display a preview image of a target object based on a first preset shooting parameter in the first screen. The user can control the first camera to face the target object and input a target object that needs to be measured. For example, the user can control the first camera to face the target object and display the preview image of the target object in the center of the first screen to determine the target object that needs to be measured. Alternatively, a prompt box can be popped up in the first screen to prompt the user to confirm the target object that needs to be measured. If the preview image displayed in the first screen does not include the target object that the user wants to measure, the user can input to re-determine the target object. For example, the user can adjust the first camera or frame the preview image displayed in the first screen to determine the target object.
[0042] In some embodiments, the first screen and the second screen can rotate along the axis respectively. The user can rotate the second screen, and the second camera can rotate along with the second screen. During the rotation of the second screen, the second camera can capture a plurality of images at different angles based on the second preset shooting parameter and at a preset frame rate. The angle corresponding to each image captured by the second camera includes the included angle between the cameras.
[0043] Alternatively, the included angle between the cameras can be the included angle between the imaging planes of the captured images. Figure 3 is a schematic diagram of imaging of a target object provided by an embodiment of the present application. As shown in Figure 3 , P is the target object, the position of the optical center Ot of the first camera can be used to represent the position of the first camera, the position of the optical center Om of the second camera can be used to represent the position of the second camera, O is the position of the axis, the second screen rotates around the axis to change the position of the second camera, and the included angle θ between the first screen and the second screen is the included angle between the cameras.
[0044] After the first image captured by the first camera is obtained and the N images captured by the second camera are obtained, step 220 can be performed.
[0045] In step 220, a first distance from a first imaging point of the target object in the first image to the axis and a second distance from a second imaging point of the target object in each of the N images to the axis are obtained.
[0046] The first distance is the distance from the first imaging point to the axis along the extension direction of the first imaging plane, and the second distance is the distance from the second imaging point to the axis along the extension direction of the second imaging plane.
[0047] For example, in combination with Figure 3As shown, the first imaging point in the first image is the intersection point Ct of POt and the imaging plane, and the first imaging point in the second image is the intersection point Cm of POm and the imaging plane. The distance of the first imaging point to the axis along the extension direction of the first imaging plane is CtT, that is, the first distance of the first imaging point to the axis, and the distance of the second imaging point to the axis along the extension direction of the second imaging plane is CmT, that is, the second distance of the second imaging point to the axis.
[0048] In step 230, the target distance of the target object to the electronic device is determined according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and the N second distances.
[0049] In some embodiments, the first camera and the second camera are both located at the preset positions of the electronic device, so that the first preset distance of the first camera to the axis and the second preset distance of the second camera to the axis are known. Since the first camera and the second camera perform image shooting according to the first preset shooting parameter and the second preset shooting parameter respectively, the imaging focal length of the first image and the second image is known. In order to simplify the calculation process, the first camera and the second camera can use the same imaging focal length for shooting. In the process of calculating the target distance, the positional relationship among the target object, the electronic device, the first imaging point and the second imaging point can be combined.
[0050] According to the embodiments of the present application, in the calculation process, the distance information of the imaging point of the target object in the first image and the N frames of second images to the axis, and the first preset distance of the first camera to the axis, the second preset distance of the second camera to the axis and the imaging focal length included in the preset shooting parameter are used for calculation to determine the target distance of the target object to the electronic device. Among them, by introducing multiple frames of second images for distance calculation, the requirement for calculation complexity and camera calibration when using two cameras for distance measurement is reduced, thereby reducing the measurement error and improving the accuracy of measuring the distance between the target object and the electronic device.
[0051] In some embodiments, calculating the target distance between the target object and the electronic device can include: determining N initial distances of the target object to the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and the N second distances; and determining the target distance according to a preset residual function and the N initial distances.
[0052] As a specific example, in combination with Figure 3As shown, the first preset distance is the distance from point O to point Ot, denoted as Bt, the second preset distance is the distance from point O to point Om, denoted as Bm, and the imaging focal length of the first image and the second image is f, where the distance between the target object and the electronic device is denoted as Z, which is the distance from point O to point P. In the first image, At is the leftmost side of the image of the first image, and according to the position information of At and the position information of the first imaging point Ct, the distance St from the first imaging point to the leftmost side of the first image can be obtained, and then the distance from the first imaging point Ct to the axis can be determined. In the second image, Am is the leftmost side of the image of the second image, and according to the position information of Am and the position information of the second imaging point Cm, the distance Sm from the second imaging point to the leftmost side of the second image can be obtained, where the projection distance of Sm on the horizontal plane is S' m =S m ·cos(θ). Wherein the distance Z between the target object and the electronic device is calculated by formula (1), and formula (1) can be expressed as:
[0053]
[0054] An initial distance Z can be calculated by formula (1) from the first image and one frame of the second image.
[0055] In order to reduce the calculation error, the target distance can be determined according to the preset residual function and N initial distances. In some embodiments, the reason for the error in calculating the distance between the target object and the electronic device can be that the position information used by the first imaging point and the second imaging point can have an error from the actual imaging position; when the included angle between the first camera and the second camera is 0, the distance between the imaging point of the target object in the second image and the leftmost side of the second image has an error. The above errors can be attributed to Sm.
[0056] For example, during the second screen rotation process, when the included angle θ between the first camera and the second camera is different, the imaging point of the target object in the second image is different, that is, the position information of the second imaging point Cm of different second images is different, and thus the distance from the second imaging point to the leftmost side of the second image is different, and therefore a plurality of different Sm can be obtained, and the projection distance of Sm on the horizontal plane is S' m . Correspondingly, in the case of N frames of second images, N Zs can be obtained according to formula (1).
[0057] In order to improve the accuracy of the target distance, for N initial distances Z, a set of (a1, a2, … a n ) can be found, where n=N, so that the residual error between the target distance and the initial distance is minimized, that is, where n is the number of second images, Zi is the initial distance obtained according to the ith second image, The target distance.
[0058] For example, target distance It can be represented as The distance from the imaging point of the target object to the leftmost point of the second image is denoted as .
[0059] Alternatively, the N initial distances Z can be independent and identically distributed, and it can be assumed that the error follows a Gaussian distribution. Where ε and σ are the parameters of the Gaussian distribution. Therefore, minimizing the residuals can be transformed into maximizing the joint probability of all measurements, i.e., finding the target value according to formula (2). Formula (2) can be expressed as:
[0060]
[0061] For example, formula (2) can be solved using the Gauss-Newton method or the gradient descent method. As a specific example, when using the Gauss-Newton method, function J can represent the first derivative of function G. As the independent variable, H = J T J, B = -J T G. Random initialization during the solution process. S0 is obtained, and iterative calculations are performed. For the k-th iteration, J(s) and H(s) are calculated to obtain the increment Δs. k =H -1 B. Stopping conditions for iterative calculations, for example, setting a preset calculation threshold, if Δs k If it is less than this threshold, then Δs is considered to be... k If it is small enough, stop the calculation; otherwise, update s. k+1 =s k +Δs k The stopping condition for iterative calculations, for example, setting a preset number of iterations; the calculation stops when the preset number of iterations k is reached. The final calculated s... k Substitution In this way, the target distance can be obtained.
[0062] According to the embodiments of this application, when introducing multiple frames of second images for distance calculation, the distance calculation is performed by using least squares, which can reduce the computational complexity and camera calibration requirements when using two cameras for distance measurement, and improve the accuracy of measuring the distance between the target object and the electronic device.
[0063] In some embodiments, in order to reduce the amount of calculation, the N frames of second images in step 210 can be screened second images. For example, W frames of third images of the target object captured by the second camera according to the second preset shooting parameter are obtained, which can include steps 211 to 214.
[0064] In step 211, W frames of third images of the target object captured by the second camera according to the second preset shooting parameter are obtained.
[0065] Wherein, W is a positive integer greater than or equal to N.
[0066] Specifically, during the rotation of the second screen, the second camera can capture the target object according to the preset frame rate based on the second preset shooting parameter to obtain multiple images at different shooting angles, i.e., W frames of third images.
[0067] In step 212, in each third image, the correlation degree between the image corresponding to each preset sliding window and the first target image is calculated according to the preset sliding window and the preset sliding rule, and the correlation degree corresponding to each preset sliding window is obtained.
[0068] Wherein, the first target image is the image corresponding to the region of the target object in the first image.
[0069] For example, after determining the target object, the image corresponding to the region of the target object in the first image can be automatically framed, and the framed image can be used as the first target image. Optionally, during the framing process, an identification frame can be displayed, which can facilitate the user to understand the target object. The shape of the identification frame can be square, circle, oval, or other preset shapes, which are not specifically limited herein. Figure 4 is a schematic diagram of an identification frame provided by an embodiment of the present application, in combination with Figure 4 As shown in FIG. 4, an identification frame 402 is displayed in the first image 401, and the target object 403 is included in the identification frame 402.
[0070] As a specific example, the electronic device can also receive a first input of the first image; in response to the first input, a first target image in the first image is determined. Specifically, the first input is an input of selecting the target object. The user can preview the first image through the first screen, and in the case that the first image includes the target object, the user can also directly select the target object through manual input. For example, an identification frame is displayed in the first screen, and the user can adjust the size and position of the identification frame to select the target object, wherein the image framed by the adjusted identification frame in the first image is used as the first target image.
[0071] According to the embodiment of the present application, the user can select the target object according to the requirement, and the convenience of the ranging function of the electronic device can be improved.
[0072] In some embodiments, the size of the preset sliding window can be a preset size, or can be determined according to the size of the first target image.
[0073] For example, the first target image is a rectangle, the original length of the first target image is a0, and the original width is b0. The length and width of the preset window are obtained by multiplying the original length and width by α. The length of the preset sliding window can be represented as a, and the width can be represented as b.
[0074] In some embodiments, the preset sliding rule includes a sliding direction and a sliding step of the sliding window. For example, Figure 5 is a schematic diagram of a preset sliding window provided by an embodiment of the present application. As shown in Figure 5 The sliding step of the preset sliding window along the length direction of the third image is a / 2. When sliding to the leftmost side of the first image, the step of moving down is b / 2, and the preset sliding window continues to slide along the length direction of the third image with a step of a / 2.
[0075] For each frame of the third image, the correlation degree of the preset sliding window corresponding image and the first target image at each position is calculated in sequence to obtain the correlation degree corresponding to each preset sliding window. For example, the correlation degree calculation formula is shown in formula (3).
[0076]
[0077] wherein, S x,y (i,j) is the gray value of each pixel point in the preset sliding window corresponding image, g(i,j) is the gray value of each pixel point in the first target image, is the gray mean value of the first target image. ρ(x,y) is the correlation degree corresponding to the preset sliding window of the xth row and yth column.
[0078] According to the above steps of the embodiment of the present application, the correlation degree corresponding to each preset sliding window in each frame of the third image can be obtained.
[0079] Step 213, the first number of target sliding windows that overlap with each other in each frame of the third image is counted, wherein the correlation degree of the target sliding window is greater than the first threshold.
[0080] Specifically, the first threshold is used to determine the correlation between the preset sliding window corresponding image and the first target image. The higher the correlation, the greater the correlation between the preset sliding window corresponding image and the first target image. For example, the first threshold is preset as β, and the sliding window with p > β in each frame of the third image is regarded as a target sliding window.
[0081] Optionally, before counting the target sliding windows that overlap with each other, a third threshold can also be preset. For example, the third threshold is preset as δ, if the first number of the target sliding windows in the third image is greater than the third threshold δ, it is considered that the target object is included in the third image, and the third image is retained. If the first number of the target sliding windows in the third image is less than or equal to the third threshold δ, it is considered that the target object is not included in the third image, and the third image can be directly screened out, and the third image is no longer calculated or processed.
[0082] For example, Figure 6 is a schematic diagram of a target sliding window provided by an embodiment of the present application, which is combined with Figure 6 (a) shown, wherein it includes an independent sliding window 601 and a plurality of target sliding windows 602 that overlap with each other. The number of the target sliding windows that overlap with each other in each frame of the third image is counted to obtain a first number.
[0083] In step 214, from the W frames of the third images, the images with the first number greater than or equal to the second threshold are obtained to obtain N frames of the second images.
[0084] For example, the second threshold is preset as thr region When the first number of the target sliding windows that overlap with each other in the third image is greater than or equal to the second threshold thr region , the third image is retained; when the first number of the target sliding windows that overlap with each other in the third image is less than the second threshold thr region , the third image can be directly screened out, and the third image is no longer calculated or processed. Thus, the N frames of the second images can be quickly screened from the W frames of the third images.
[0085] According to the embodiments of the present application, by screening the third images captured by the second camera, N frames of the second images are obtained, so that the reliability of obtaining the target distance can be improved, and the calculation error of the target distance and the real distance can be reduced.
[0086] In some embodiments, in relation to the above-mentioned step 220, the first distance from the first imaging point of the target object to the axis and the second distance from the second imaging point of the target object to the axis in each frame of the second image can be obtained, which can refer to steps 221 to 223.
[0087] In step 221, position information of the center point of the first target image is obtained to obtain first position information of the first imaging point of the target object; and N second position information of the feature center point of the target object in the first image and N third position information of the feature center point of the target object in the second image are obtained.
[0088] The feature center point of the target object in the first image corresponds to the feature center point of the target object in the second image.
[0089] In step 222, first displacement of the feature center point of the target object in the first image to the first imaging point is determined according to the first position information and the second position information.
[0090] In step 223, second position information of the second imaging point in each frame of the second image is determined according to the first displacement and the third position information of the feature point of the target object in each frame of the second image.
[0091] In step 224, first distance from the first imaging point of the target object to the axis is determined according to the first position information; and second distance from the second imaging point in each frame of the second image to the axis is determined according to the second position information of the second imaging point in each frame of the second image.
[0092] In relation to step 221, the image corresponding to the region where the target object is located in the first image is the first target image, as shown in FIG. 4. Figure 4 The image corresponding to the recognition box 402 is taken as the first target image. Thus, the position information of the center point can be quickly determined, and the position information of the center point of the first target image is taken as the first position information Ct of the first imaging point of the target object.
[0093] In some embodiments, the first image and each second image can be matched according to a preset feature matching algorithm. Each time of feature matching calculation can obtain a matching information, and the matching information includes a plurality of feature point matching pairs. Each feature point matching pair includes a feature point in the first image and a feature point in the second image. For example, for N frames of second images, the first image and each second image are matched to obtain N matching information, and each matching information includes a plurality of feature point matching pairs.
[0094] The feature center point of the target object in the first image and the feature center point of the target object in the second image are calculated according to the N matching information.
[0095] Taking one of the N matching information as an example, the position information of each feature point in the first image in the matching information is obtained to obtain a plurality of position information; and the mean value of the plurality of position information is obtained to obtain the second position information The point corresponding to the second location information is then used as the feature center point of the target in the first image. Using the same calculation method, the location information of each feature point in the second image within the matching information is obtained, resulting in multiple location information points. The average of these multiple location information points is then calculated to obtain the third location information. The point corresponding to this third location information is then used as the feature center point of the target in the second image.
[0096] Based on the above steps, and using the matching information of N feature point matching pairs, N second location information of the feature center points of the target object in the first image can be obtained. N third position information of the feature center points of the target object in the second image
[0097] Regarding step 222 above, for each frame of the second image, based on the first position information and the second position information, the first displacement from the feature center point of the target object in the first image to the first imaging point is determined. For example, it could be... Indicates from the feature center point The distance C that needs to be moved to the center of the image t .
[0098] Next, in step 223, in conjunction with the first displacement The second position information C of the second imaging point in the second image can be determined. m Exemplary In step 224, a first distance from the first imaging point of the target object to the axis is determined based on the first position information; and a second distance from the second imaging point to the axis is determined based on the second position information of the second imaging point in each frame of the second image.
[0099] According to the embodiments of this application, the computational complexity and camera calibration requirements when using two cameras for distance measurement can be reduced, thereby improving the accuracy of measuring the distance between the target object and the electronic device.
[0100] In some embodiments, to improve the accuracy of determining feature center points and increase the speed of acquiring feature center points, feature point matching pairs can also be determined by extracting the image of the region where the target object is located in each frame of the second image, i.e., feature matching between the second target image and the first target image. Thus, N second positional information points of the feature center points of the target object in the first image and N third positional information points of the feature center points of the target object in the second image are obtained, as detailed in steps 301 to 303:
[0101] Step 301: Obtain the image corresponding to the region where the target object is located in each frame of the second image, and obtain the second target image corresponding to each frame of the second image.
[0102] At step 302, feature matching processing is performed on the first target image and each of the second target images respectively to obtain N pieces of matching information.
[0103] Each piece of matching information includes a plurality of feature point matching pairs, each feature point matching pair includes a first feature point located in the first target image and a second feature point located in the second target image, and a similarity of each feature point matching pair is greater than a third threshold.
[0104] At step 303, for each piece of matching information, second position information of a feature center point of the target object in the first image is determined according to position information of the plurality of first feature points in the first target image, and third position information of the feature center point of the target object in each of the second images is determined according to position information of the plurality of second feature points in the second target image.
[0105] Specifically, in relation to step 301, in order to determine the accuracy of the image corresponding to the region where the target object is located in the second image, the image corresponding to the region where the target object is located in each of the second images is obtained as the second target image, including: obtaining target sliding windows that overlap with each other in each of the second images; and determining the second target image corresponding to each of the second images according to position information of each of the target sliding windows that overlap with each other.
[0106] In one example, according to the position information of each of the target sliding windows that overlap with each other, the coverage area of the target sliding windows 602 that overlap with each other as shown in FIG. 6 can be directly taken as the second target image. Figure 6 In another example, by obtaining the position information of each of the target sliding windows that overlap with each other in each of the second images, for example, all corner points of each target detection frame, a coordinate set {x}, {y} is obtained, and the left upper, left lower, right upper and right lower coordinates are determined from the coordinate sets {x}, {y} as (min{x}, min{y}), (min{x}, max{y}), (max{x}, min{y}) and (max{x}, max{y}) respectively, and the image within the coordinates is taken as the second target image, as shown in FIG. 7. Figure 6
[0107] According to the embodiments of the present application, the second target image is determined by combining the target sliding window, the entire calculation process is simple, which is conducive to improving the accuracy of determining the feature center point and improving the speed of obtaining the feature center point.
[0108] At step 302, feature matching processing is performed on the first target image and each of the second target images respectively to obtain N pieces of matching information.
[0109] In relation to step 302 above, the feature matching process may specifically include first obtaining the feature vector representation of pixels in the first target image and the second target image, and then determining the matching information of the first target image and the second target image based on the feature vector representation of pixels.
[0110] For example, the calculation process for obtaining the feature vector representation of pixels in the first target image and each frame of the second target image is the same. The following uses the first target image as an example to introduce the feature vector representation of pixels.
[0111] Optionally, the horizontal gradient G of each pixel in the first target image is calculated using the Sobel operator. x and vertical gradient G y For each pixel, take the horizontal gradient G. x and vertical gradient G y The gradient corresponding to the largest absolute value is taken as the gradient of that pixel. If this gradient is less than a preset gradient value thr gradient If the pixel is not found to be true, it is discarded. For the remaining pixels, the horizontal gradient G is used to determine the appropriate pixel. x and vertical gradient G y Calculate the gradient direction of the retained pixels. in, At this time, the gradient direction of the pixel It could be any direction within 0° to 360°. To further reduce computational cost, the gradient direction of the pixel can be... The data is quantized to a preset number of preset directions to obtain the feature vector representation of each pixel. The preset number of preset directions is, for example... Figure 7 The eight directions shown.
[0112] Optionally, the gradient directions of pixels in the first target image can be filtered and / or expanded before quantization.
[0113] Optionally, to reduce noise interference, the gradient direction of the pixels can be adjusted. Perform filtering. For example, the gradient direction of pixels within each 5×5 pixel area. Statistical analysis is performed to determine the most frequent direction within a 5x5 pixel area, which is then used as the gradient direction for pixels within that 5x5 pixel area. However, if the most frequent direction within a 5x5 pixel area appears less than a preset number of times, then pixels within that area are not included in the calculation or processing. For example, if a 5x5 pixel area contains 15 upward directions, 6 downward-right directions, and 4 leftward directions, then the gradient direction for all pixels within that 5x5 pixel area will be set to the upward direction.
[0114] Optionally, to reduce the matching error caused by different shooting angles in subsequent matching calculation, the screened gradient direction can also be extended. For example, for each pixel point, the gradient direction of each pixel point in its 3x3 neighborhood is determined, and the gradient direction of each pixel point in its 3x3 neighborhood is compared with the gradient direction of the pixel point. Figure 8 The gradient direction of the pixel point is shown in the figure, wherein, Figure 8 (a) is the gradient direction of the pixel point without extension, and Figure 8 The 8 pixel points in region 801 in (a) are extended to obtain Figure 8 (b) is the gradient direction of the pixel point after extension. In combination with Figure 8 As shown in the figure, the "→" in region 801 is extended to each pixel point in its 3x3 neighborhood, and the "↑" in region 801 is extended in its 3x3 neighborhood. After the extension, the second row, second column, second row, third column, third row, second column, and third row in region 801 are superimposed with "→".
[0115] As shown in the figure, the 8 directions are taken as an example, with the horizontal left as the first, and the clockwise rotation is calculated. Figure 7 The similarity s of each vector and the gradient direction of the pixel point is calculated. For example, the similarity calculation formula of the i-th pixel is shown in formula (4).
[0116]
[0117] Where i={1,2,3…8}, M is the set of 8 gradient directions, and the vector form of M can be represented as M={(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)}; L is the gradient direction set of the pixel point, and l is one of the gradient directions.
[0118] For example, when the gradient direction L of the pixel point includes {↓,→}, the vector form of L can be represented as L={(0,-1),(1,0)}.
[0119] When i=1, the similarity between L and vector M1={-1,0} is calculated as:
[0120]
[0121] When i=4, when i=1, the similarity between L and vector M4={1,1} is calculated as:
[0122]
[0123] Based on the same calculation process, the feature vector expression form of the pixel point can be obtained as:
[0124]
[0125] According to the above embodiment, the feature vector expression form of the pixels in the first target image and each frame of the second target image can be obtained.
[0126] Next, the matching information of the first target image and the second target image can be determined based on the feature vector expression form of the pixel points.
[0127] In the matching process, in combination with Figure 9 the sliding schematic diagram of the first target image shown in FIG. 9, the first target image 901 can slide in the second target image 902 according to a preset sliding rule, wherein the sliding step can be min(d, max(4, d / 10)), and d is the width of the first target image. In order to improve the calculation speed and the calculation accuracy, the center pixel point 3*3 can be taken as the calculation region, and the center pixel is the pixel point 903 shown in Figure 9 the corresponding calculation region 904.
[0128] The feature vector cosine similarity of the first target image and the second target image is calculated pixel by pixel, and the mean value is taken as the final value of the pixel. For example, the calculation formula is shown in formula (5).
[0129]
[0130] wherein n is the number of pixel points in the calculation region, s i is the feature vector of the pixel to be matched, t i is the feature vector of the target image pixel, and ||·|| is the two norm.
[0131] If r i is greater than a preset threshold thr feature , the point is a feature point. The position p t of the feature point on the first target image and the position p m on the first target image are recorded.
[0132] Thus, after the matching calculation of the first target image and one second target image, a matching information can be obtained, which includes the feature point set Pt on the first target image and the feature point set Pm on the second target image, wherein Pt is the position set of the feature point on the first target image, and Pm is the position set of the feature point on the second target image. Optionally, if the number of feature point matching pairs is less than a preset threshold thr points after the scanning is completed, the second target image can not be continuously calculated. According to the above embodiment, N matching information can be obtained.
[0133] Corresponding to each matching information, the mean value of the position information of the plurality of first feature points in the first target image is obtained to obtain second position information of the feature center point of the target object in the first image The mean value of the position information of the plurality of second feature points in the second target image is obtained to obtain third position information of the feature center point of the target object in the second image
[0134] According to the embodiment of the present application, the hierarchical feature point fast calculation can reduce the calculation complexity and the camera calibration requirement when using two cameras for distance measurement, and improve the application scenario of distance measurement.
[0135] The distance measurement method provided by the embodiment of the present application can be executed by the distance measurement device. The distance measurement method executed by the distance measurement device is taken as an example to illustrate the distance measurement device provided by the embodiment of the present application.
[0136] Figure 10 FIG. 1 is a structural schematic diagram of a distance measurement device provided by an embodiment of the present application. The device is applied to an electronic device, and the electronic device includes a folding screen and a camera module. The folding screen includes a first screen and a second screen rotating along an axis. The camera module includes a first camera and a second camera. The first camera rotates with the first screen, and the second camera rotates with the second screen. Figure 10 As shown in the figure, the distance measurement device includes an acquisition module 1010 and a processing module 1020.
[0137] In the embodiment of the present application, the program distance measurement device can be a component of the electronic device, which can be an integrated circuit, a chip, a control device, an input unit or a display unit of the electronic device, and the present application does not make specific limitation here.
[0138] In the embodiment of the present application, the acquisition module 1010 is configured to acquire a first image and N frames of second images. The first image is obtained by the first camera according to first preset shooting parameters, and the N frames of second images are obtained by the second camera according to second preset shooting parameters. The first preset shooting parameters include a first preset distance between the first camera and the axis and an imaging focal length, and the second preset shooting parameters include a second preset distance between the second camera and the axis and the imaging focal length.
[0139] The acquisition module 1010 is further configured to acquire a first distance from an imaging point of the target object in the first image to the axis and a second distance from an imaging point of the target object in each of the N second images to the axis, where the first distance is a distance from the imaging point along an extension direction of a first imaging plane to the axis, and the second distance is a distance from the imaging point along an extension direction of a second imaging plane to the axis.
[0140] The processing module 1020 is configured to determine a target distance from the target object to the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and the N second distances.
[0141] According to embodiments of the present application, the target distance from the target object to the electronic device is determined by using distance information of imaging points of the target object in the first image and the N second images to the axis, and the first preset distance of the first camera to the axis, the second preset distance of the second camera to the axis, and the imaging focal length included in the preset shooting parameters. The distance calculation is performed by introducing the multiple second images, which reduces the requirement for calculation complexity and camera calibration when the distance is measured by using the two cameras, thereby reducing the measurement error and improving the accuracy of the distance between the target object and the electronic device.
[0142] In some embodiments, the processing module 1020 is further configured to determine N initial distances from the target object to the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and the N second distances.
[0143] The processing module 1020 is further configured to determine the target distance according to a preset residual function and the N initial distances.
[0144] According to embodiments of the present application, when the distance calculation is performed by introducing the multiple second images, the distance calculation is performed by using the least square, which reduces the requirement for calculation complexity and camera calibration when the distance is measured by using the two cameras, thereby improving the accuracy of the distance between the target object and the electronic device.
[0145] In some embodiments, the acquisition module 1010 is further configured to acquire W third images of the target object captured by the second camera according to second preset shooting parameters, where W is a positive integer greater than or equal to N.
[0146] The processing module 1020 is further configured to, in each of the W third images, sequentially calculate a correlation degree between a preset sliding window corresponding image and the first target image according to a preset sliding window and a preset sliding rule, to obtain a correlation degree corresponding to each preset sliding window, where the first target image is an image corresponding to a region of the target object in the first image.
[0147] The processing module 1020 is further configured to count a first number of target sliding windows that overlap with each other in each frame of the third images, wherein the correlation of the target sliding windows is greater than a first threshold value.
[0148] The acquisition module 1010 is further configured to acquire, from the W frames of the third images, images in which the first number is greater than or equal to a second threshold value, to obtain N frames of the second images.
[0149] According to embodiments of the present application, the N frames of the second images are obtained by screening the third images captured by the second camera, so that the reliability of obtaining the target distance can be improved, and the calculation error of the target distance and the real distance can be reduced.
[0150] In some embodiments, the receiving module is configured to receive a first input of the first image.
[0151] The processing module 1020 is further configured to determine, in response to the first input, a first target image in the first image.
[0152] According to embodiments of the present application, the user can select the target object according to the demand, and the convenience of the ranging function of the electronic device can be improved.
[0153] In some embodiments, the acquisition module 1010 is further configured to acquire position information of a center point of the first target image, to obtain first position information of a first imaging point of the target object.
[0154] The acquisition module 1010 is further configured to acquire N second position information of a feature center point of the target object in the first image and N third position information of the feature center point of the target object in the second image, wherein the feature center point of the target object in the first image and the feature center point of the target object in the second image correspond to each other in one-to-one correspondence.
[0155] The processing module 1020 is further configured to determine, according to the first position information and the second position information, a first displacement of the feature center point of the target object in the first image to the first imaging point.
[0156] The processing module 1020 is further configured to determine, according to the first displacement and third position information of a feature point of the target object in each frame of the second images, second position information of a second imaging point in each frame of the second images.
[0157] The processing module 1020 is further configured to determine, according to the first position information, a first distance from the first imaging point of the target object to the axis.
[0158] The processing module 1020 is further configured to determine, according to the second position information of the second imaging point in each frame of the second images, a second distance from the second imaging point in each frame of the second images to the axis.
[0159] According to the embodiments of this application, the computational complexity and camera calibration requirements when using two cameras for distance measurement can be reduced, thereby improving the accuracy of measuring the distance between the target object and the electronic device.
[0160] In some embodiments, the acquisition module 1010 is further configured to acquire the image corresponding to the region where the target object is located in each frame of the second image, and obtain the second target image corresponding to each frame of the second image;
[0161] The acquisition module 1010 is also used to perform feature matching processing on the first target image and each second target image respectively to obtain N matching information. Each matching information includes multiple feature point matching pairs. Each feature point matching pair includes a first feature point located in the first target image and a second feature point located in the second target image. The similarity of each feature point matching pair is greater than a third threshold.
[0162] The processing module 1020 is also configured to, for each matching information, determine the second position information of the feature center point of the target object in the first image based on the position information of multiple first feature points in the first target image; and, based on the position information of multiple second feature points in the second target image, determine the third position information of the feature center point of the target object in each frame of the second image.
[0163] According to the embodiments of this application, by rapidly calculating layered feature points, the computational complexity and camera calibration requirements when using two cameras for distance measurement can be reduced, thereby expanding the application scenarios of distance measurement.
[0164] In some embodiments, the acquisition module 1010 is further configured to acquire overlapping target sliding windows in each frame of the second image;
[0165] The processing module 1020 is also used to determine the second target image corresponding to each frame of the second image based on the position information of each target sliding window in the overlapping target sliding windows.
[0166] According to the embodiments of this application, the second target image is determined by combining the target sliding window. The entire calculation process is simple, which helps to improve the accuracy of determining the feature center point and increase the speed of obtaining the feature center point.
[0167] The ranging device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the scope of the device.
[0168] The ranging device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0169] The ranging device provided in this application can realize all the processes implemented in the embodiments of the ranging method of this application. To avoid repetition, it will not be described again here.
[0170] Optionally, such as Figure 11 As shown, this application embodiment also provides another electronic device 1100, including a processor 1101 and a memory 1102. The memory 1102 stores a program or instructions that can run on the processor 1101. When the program or instructions are executed by the processor 1101, they implement the various steps of the above-described ranging method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0171] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0172] Figure 12 A schematic diagram of the hardware structure of another electronic device to implement the embodiments of this application.
[0173] The electronic device 1200 includes, but is not limited to, a radio frequency unit 1201, a network module 1202, an audio output unit 1203, an input unit 1204, a sensor 1205, a display unit 1206, a user input unit 1207, an interface unit 1208, a memory 1209, and a processor 1210, etc.
[0174] Those skilled in the art can understand that the electronic device 1200 can also include a power supply (such as a battery) for supplying power to each component, and the power supply can be logically connected to the processor 1210 through a power management system, so as to realize the functions of managing charging, discharging, and power consumption management through the power management system. Figure 12 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than the figure, or combine certain components, or different component arrangements, which are not described here.
[0175] The processor 1210 is configured to acquire a first image and N frames of second images, wherein the first image is obtained by a first camera according to first preset shooting parameters for shooting a target object, and the N frames of second images are obtained by a second camera according to second preset shooting parameters for shooting the target object, the first preset shooting parameters include a first preset distance of the first camera from an axis and an imaging focal length, and the second preset shooting parameters include a second preset distance of the second camera from the axis and the imaging focal length.
[0176] The processor 1210 is further configured to acquire a first distance from the axis of a first imaging point of the target object in the first image and a second distance from the axis of a second imaging point of the target object in each frame of the second images, wherein the first distance is a distance of the first imaging point from the axis along an extension direction of a first imaging plane, and the second distance is a distance of the second imaging point from the axis along an extension direction of a second imaging plane.
[0177] The processor 1210 is configured to determine a target distance of the target object from the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and N second distances.
[0178] According to the embodiments of the present application, by using the distance information of the imaging points of the target object from the axis in the first image and the N frames of second images, and the first preset distance of the first camera from the axis, the second preset distance of the second camera from the axis, and the imaging focal length included in the preset shooting parameters, the target distance of the target object from the electronic device is determined by calculation. Wherein, by introducing multiple frames of second images for distance calculation, the requirement for calculation complexity and camera calibration when using two cameras for distance measurement is reduced, thereby reducing the measurement error and improving the accuracy of measuring the distance between the target object and the electronic device.
[0179] In some embodiments, the processor 1210 is further configured to determine N initial distances from the target object to the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and the N second distances.
[0180] The processor 1210 is further configured to determine the target distance according to the preset residual function and the N initial distances.
[0181] According to embodiments of the present application, when multiple second images are introduced for distance calculation, the least square method is used for distance calculation, thereby reducing the requirement for calculation complexity and camera calibration when using two cameras for distance measurement, and improving the accuracy of measuring the distance between the target object and the electronic device.
[0182] In some embodiments, the processor 1210 is further configured to obtain W third images of the target object captured by the second camera according to preset capture parameters, where W is a positive integer greater than or equal to N.
[0183] The processor 1210 is further configured to calculate, in each third image, the correlation degree between the image corresponding to each preset sliding window and the first target image according to a preset sliding window and a preset sliding rule, to obtain a correlation degree corresponding to each preset sliding window, where the first target image is an image corresponding to a region of the target object in the first image.
[0184] The processor 1210 is further configured to count a first number of target sliding windows that overlap with each other in each third image, where the correlation degree of the target sliding window is greater than a first threshold.
[0185] The processor 1210 is further configured to obtain, from the W third images, images with a first number greater than or equal to a second threshold, to obtain N second images.
[0186] According to embodiments of the present application, the third images captured by the second camera are screened to obtain N second images, thereby improving the reliability of obtaining the target distance and reducing the calculation error between the target distance and the real distance.
[0187] In some embodiments, the input unit 1204 is configured to receive a first input of the first image.
[0188] The processor 1210 is further configured to determine, in response to the first input, a first target image in the first image.
[0189] According to embodiments of the present application, the user can select the target object according to the demand, which can improve the convenience of the distance measurement function of the electronic device.
[0190] In some embodiments, the processor 1210 is further configured to obtain position information of a center point of the first target image, to obtain first position information of the first imaging point of the target object;
[0191] The processor 1210 is further configured to obtain N second position information of a feature center point of the target object in the first image and N third position information of the feature center point of the target object in the second image, wherein the feature center point of the target object in the first image and the feature center point of the target object in the second image correspond one-to-one.
[0192] The processor 1210 is further configured to determine, according to the first position information and the second position information, a first displacement of the feature center point of the target object in the first image to the first imaging point.
[0193] The processor 1210 is further configured to determine, according to the first displacement and the third position information of the feature point of the target object in each frame of the second image, second position information of the second imaging point in each frame of the second image.
[0194] The processor 1210 is further configured to determine, according to the first position information, a first distance from the first imaging point of the target object to the axis.
[0195] The processor 1210 is further configured to determine, according to the second position information of the second imaging point in each frame of the second image, a second distance from the second imaging point in each frame of the second image to the axis.
[0196] According to the embodiments of the present application, the requirement for calculation complexity and camera calibration when using two cameras to measure the distance can be reduced, and the accuracy of measuring the distance between the target object and the electronic device can be improved.
[0197] In some embodiments, the processor 1210 is further configured to obtain an image corresponding to a region where the target object is located in each frame of the second image, to obtain a second target image corresponding to each frame of the second image.
[0198] The processor 1210 is further configured to perform feature matching processing on the first target image and each second target image respectively, to obtain N matching information, each matching information including a plurality of feature point matching pairs, each feature point matching pair including a first feature point located in the first target image and a second feature point located in the second target image, and a similarity of each feature point matching pair being greater than a third threshold.
[0199] The processor 1210 is further configured to, for each matching information, determine, according to position information of the plurality of first feature points in the first target image, the second position information of the feature center point of the target object in the first image, and determine, according to position information of the plurality of second feature points in the second target image, the third position information of the feature center point of the target object in each frame of the second image.
[0200] According to the embodiment of the present application, the calculation complexity and the requirement of camera calibration when distance measurement is performed by using two cameras can be reduced by the hierarchical feature point fast calculation, and the application scenario of distance measurement is improved.
[0201] In some embodiments, the processor 1210 is further configured to acquire the target sliding windows that overlap with each other in each second image.
[0202] The processor 1210 is further configured to determine a second target image corresponding to each second image according to the position information of each target sliding window in the target sliding windows that overlap with each other.
[0203] According to the embodiment of the present application, the second target image is determined by combining the target sliding window, the whole calculation process is simple, which is conducive to improving the accuracy of determining the feature center point and improving the speed of obtaining the feature center point.
[0204] It should be understood that, in the embodiments of the present application, the input unit 1204 can include a graphics processing unit (GPU) 12041 and a microphone 12042. The graphics processing unit 12041 processes image data of a still picture or a video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 1206 can include a display panel 12061, which can be configured in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit 1207 includes at least one of a touch panel 12071 and other input devices 12072. The touch panel 12071 is also called a touch screen. The touch panel 12071 can include a touch detection device and a touch controller. The other input devices 12072 can include, but are not limited to, a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), trackballs, mice, joysticks, and the like, which will not be described here.
[0205] The memory 1209 can be used to store software programs and various data. The memory 1209 can mainly include a first storage area storing programs or instructions and a second storage area storing data, wherein the first storage area can store an operating system, application programs or instructions required by at least one function (such as a sound playing function, an image playing function, etc.), and the like. In addition, the memory 1209 can include a volatile memory or a non-volatile memory, or the memory 1209 can include both volatile and non-volatile memories. The non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synch link DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM). The memory 1209 in the embodiments of the present application includes but is not limited to these and any other suitable types of memories.
[0206] The processor 1210 can include one or more processing units; optionally, the processor 1210 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and an application program, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 1210.
[0207] The embodiments of the present application also provide a readable storage medium, the readable storage medium stores programs or instructions, the programs or instructions are executed by a processor to realize various processes of the above-mentioned ranging method embodiments, and the same technical effects can be achieved. To avoid repetition, details are not described here.
[0208] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes a computer readable storage medium, such as a computer readable only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0209] The embodiment of the present application further provides a chip, which comprises a processor and a communication interface, the communication interface is coupled with the processor, the processor is used for running programs or instructions to realize the processes of the ranging method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.
[0210] It should be understood that the chip mentioned in the embodiment of the present application can also be referred to as a system chip, a system chip, a chip system or a system on chip, etc.
[0211] The embodiment of the present application provides a computer program product, which is stored in a storage medium, and the program product is executed by at least one processor to realize the processes of the ranging method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.
[0212] It should be noted that in this document, the term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "comprises a" does not exclude the presence of additional identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present application is not limited to the order of performing the functions as shown or discussed, but can also include performing the functions in a substantially simultaneous manner or in the opposite order, for example, the described method can be performed in an order different from that described, and various steps can also be added, omitted or combined. In addition, the features described with reference to some examples can be combined in other examples.
[0213] Through the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned example methods can be realized by means of software and a necessary general hardware platform, and of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a computer software product in essence or in the form of a part that contributes to the prior art, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk) and includes a plurality of instructions for causing a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application.
[0214] The embodiments of the present application are described above in combination with the drawings, but the present application is not limited to the above-mentioned specific embodiments, and the above-mentioned specific embodiments are only illustrative and not restrictive. Those skilled in the art can make many forms under the inspiration of the present application without departing from the scope of the present application and the scope protected by the claims.
Claims
1. A distance measuring method, executed by an electronic device, the electronic device comprising a folding screen and a camera module, the folding screen comprising a first screen and a second screen rotating along an axis, the camera module comprising a first camera and a second camera, the first camera following the rotation of the first screen, the second camera following the rotation of the second screen; characterized in that, The method comprises: obtaining a first image and N frames of second images, wherein the first image is obtained by the first camera according to first preset shooting parameters, the N frames of second images are obtained by the second camera according to second preset shooting parameters, the first preset shooting parameters comprise a first preset distance of the first camera from the axis and an imaging focal length, the second preset shooting parameters comprise a second preset distance of the second camera from the axis and the imaging focal length, and N is a positive integer; obtaining a first distance from an imaging point of the target object in the first image to the axis and a second distance from an imaging point of the target object in each frame of the second image to the axis, wherein the first distance is a distance from the imaging point along an extension direction of a first imaging plane to the axis, and the second distance is a distance from the imaging point along an extension direction of a second imaging plane to the axis; determining a target distance of the target object from the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance and N second distances.
2. The method of claim 1, wherein, The method comprises: determining N initial distances of the target object from the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance and N second distances; determining the target distance according to a preset residual function and the N initial distances.
3. The method of claim 1, wherein, The method comprises: obtaining W frames of third images obtained by the second camera according to the second preset shooting parameters, wherein W is a positive integer greater than or equal to N; in each frame of the third image, a correlation degree between a preset sliding window corresponding image and a first target image is calculated according to a preset sliding window and a preset sliding rule, to obtain a correlation degree corresponding to each preset sliding window, wherein the first target image is an image corresponding to a region of the target object in the first image; a first number of target sliding windows in each frame of the third image is counted, wherein the correlation degree of the target sliding window is greater than a first threshold value; from the W frames of third images, an image with a first number greater than or equal to a second threshold value is obtained, to obtain the N frames of second images.
4. The method of claim 3, wherein, Before obtaining the N frames of second images, the method further comprises: receiving a first input of the first image; in response to the first input, determining a first target image in the first image.
5. The method of claim 3, wherein, The method comprises: obtaining position information of a center point of the first target image to obtain first position information of the imaging point of the target object; and obtain N second position information of the feature center points of the target object in the first image and N third position information of the feature center points of the target object in the second image, wherein the feature center points of the target object in the first image correspond to the feature center points of the target object in the second image one by one; determine a first displacement of the feature center points of the target object in the first image to the first imaging point according to the first position information and the second position information; determine second position information of the second imaging point in each frame of the second image according to the first displacement and the third position information of the feature points of the target object in each frame of the second image; determine a first distance from the first imaging point of the target object to the axis according to the first position information; and determine a second distance from the second imaging point in each frame of the second image to the axis according to the second position information of the second imaging point in each frame of the second image.
6. The method of claim 5, wherein, The obtaining of the N second position information of the feature center points of the target object in the first image and the N third position information of the feature center points of the target object in the second image comprises: obtaining an image corresponding to a region where the target object is located in each frame of the second image to obtain a second target image corresponding to each frame of the second image; performing feature matching processing on the first target image and each of the second target images respectively to obtain N matching information, each of the matching information comprising a plurality of feature point matching pairs, each of the feature point matching pairs comprising a first feature point located in the first target image and a second feature point located in the second target image, and a similarity of each of the feature point matching pairs being greater than a third threshold value; for each of the matching information, determining the second position information of the feature center points of the target object in the first image according to position information of a plurality of first feature points in the first target image, and determining the third position information of the feature center points of the target object in each frame of the second image according to position information of a plurality of second feature points in the second target image.
7. The method of claim 6, wherein, The obtaining of the image corresponding to the region where the target object is located in each frame of the second image to obtain the second target image corresponding to each frame of the second image comprises: obtaining target sliding windows that overlap with each other in each frame of the second image; determining the second target image corresponding to each frame of the second image according to position information of each of the target sliding windows that overlap with each other.
8. A ranging device, the device is applied to an electronic device, the electronic device comprises a folding screen and a camera module, the folding screen comprises a first screen and a second screen rotating along an axis, the camera module comprises a first camera and a second camera, the first camera rotates with the first screen, and the second camera rotates with the second screen; characterized in that, The device comprises: an obtaining module, configured to obtain a first image and N frames of second images, wherein the first image is obtained by a first camera according to first preset shooting parameters, the N frames of second images are obtained by a second camera according to second preset shooting parameters, the first preset shooting parameters comprise a first preset distance of the first camera from the axis and an imaging focal length, and the second preset shooting parameters comprise a second preset distance of the second camera from the axis and the imaging focal length; The acquisition module is further configured to acquire a first distance from a first imaging point of the target object in the first image to the axis and a second distance from a second imaging point of the target object in each of the second images to the axis, wherein the first distance is a distance from the first imaging point to the axis along an extension direction of a first imaging plane, and the second distance is a distance from the second imaging point to the axis along an extension direction of a second imaging plane. The processing module is configured to determine a target distance from the target object to the electronic device according to the imaging focal length, the first preset distance, the second preset distance, the first distance, and N second distances.
9. An electronic device, comprising: A processor and a memory are included, the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the ranging method according to any one of claims 1-7.
10. A readable storage medium, characterized by, The readable storage medium stores programs or instructions, and the programs or instructions, when executed by a processor, implement the steps of the ranging method according to any one of claims 1-7.
Citation Information
Patent Citations
Method and device for measuring distance of double-camera
CN103344213A
Binocular camera distance measurement method and device, distance measurement equipment and readable storage medium
CN113155083A