Distance measurement method, electronic equipment, camera equipment and computer readable medium
By displaying multiple areas on the camera device and combining lens magnification and distance information, users can click on the boundary range to calculate the length of a curve or straight line, which solves the problem of lens magnification and shape limitations in the existing technology and achieves flexible length measurement and simplification operate.
Patent Information
- Application Number
- CN202411219140.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing distance measurement method of camera equipment is only suitable for measuring the lens magnification of 1 times and measuring the length of line segments. It cannot be applied to the measurement of other lens magnifications and curve lengths, and the operation is cumbersome.
By displaying the image as multiple areas, the user clicks on the boundary range to input the target location information, and combines the actual magnification of the lens of the camera device, the single magnification focal length, the pixel size and the distance between the object and the device to calculate the length of the boundary to be measured, regardless of the boundary shape. It is a straight line or curve, suitable for any lens magnification and shape.
It realizes length measurement under any lens magnification and shape, simplifies user operations, and improves the flexibility and convenience of distance measurement.
Smart Images

Figure CN118730033A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular, to a distance measurement method, an electronic device, a camera device and a computer-readable medium. Background Art
[0002] Currently, the way in which a camera device implements a distance measurement function is usually that a user manually selects two points and then calculates the distance between the two points.
[0003] However, this distance measurement method has two major drawbacks. First, it is only applicable to cameras with a lens magnification of 1x, and cannot be applied to cameras with other lens magnifications. Second, it is only applicable to measuring the length of line segments, and cannot be applied to measuring the length of curves.
[0004] Therefore, there is an urgent need for a distance measurement method that is applicable to a camera device with any lens magnification and can measure the length of a curve. Summary of the invention
[0005] The present application aims to solve one of the technical problems in the related art to a certain extent. To this end, the present application provides a distance measurement method, an electronic device, a camera device and a computer readable medium.
[0006] As a first aspect of the present application, a ranging method is provided, wherein the method comprises: Displaying an image as a plurality of regions; wherein each of the regions has a boundary composed of pixels; Acquire externally input target location information, and determine a boundary to be measured that matches the target location information; Acquire distance information between the object in the image and the camera device; The length information of the boundary to be measured is determined according to the actual magnification information of the lens of the camera device, the single-rate focal length information, the pixel size information, the distance information between the object in the image and the camera device, and the number of pixels included in the boundary to be measured.
[0007] Optionally, the length information of the boundary to be measured is determined by the following formula: (1); In formula (1), Indicates the length information of the boundary to be measured. Indicates the number of pixels included in the boundary to be measured, Represents pixel size information, represents the distance information between the object in the image and the camera device, Indicates single-magnification focal length information. Indicates the actual lens magnification information.
[0008] Optionally, the pixels in the boundary have a first coordinate and a second coordinate, the target position information includes the target first coordinate and the target second coordinate, and determining the boundary to be measured that matches the target position information includes: From the boundaries of the multiple areas, a boundary containing matching pixels is determined as a boundary to be measured; wherein the matching pixels are pixels located on the boundary and the distance between the first coordinate and the first coordinate of the target and the distance between the second coordinate and the second coordinate of the target are both less than a preset threshold.
[0009] Optionally, the preset threshold is determined according to the resolution of the image.
[0010] Optionally, the shapes of the multiple regions include irregular shapes and / or regular shapes, and the number of boundaries of each region includes one or more.
[0011] Optionally, displaying the image as a plurality of regions comprises: Segment the image to obtain multiple regions; The boundaries of the plurality of regions are displayed in two different colors.
[0012] Optionally, after determining the length information of the boundary to be measured according to the actual magnification information of the lens of the camera device, the single-rate focal length information, the pixel size information, the distance information between the object in the image and the camera device, and the number of pixels included in the boundary to be measured, the method further includes: The length information of the boundary to be measured is displayed according to the target position information.
[0013] As a second aspect of the present application, an electronic device is provided, wherein the electronic device includes: one or more processors; A memory having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by the one or more processors, the one or more processors implement the ranging method according to the first aspect of the present application.
[0014] As a third aspect of the present application, a camera device is provided, wherein the camera device includes the electronic device according to the second aspect of the present application.
[0015] As a fourth aspect of the present application, a computer-readable medium is provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the ranging method according to the first aspect of the present application is implemented.
[0016] In the distance measurement method provided in the embodiment of the present application, an image is displayed as a plurality of regions each having a boundary composed of pixels, target position information inputted from the outside by a user by clicking on a boundary range is obtained, and then a boundary to be measured that matches the target position information is determined. Based on the actual lens magnification information of the camera device, the single-rate focal length information, and the distance information between the object in the image and the camera device, combined with the pixel size information of the camera device and the number of pixels included in the boundary to be measured, the length information of the boundary to be measured can be determined regardless of whether the shape of the boundary is a straight line or a curve, and regardless of the actual lens magnification. The method is applicable to camera devices with any lens magnification and length measurement of any shape, and simplifies user operations to bring convenience to users. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The present application is further described below in conjunction with the accompanying drawings: Figure 1 is a flow chart of an implementation method of the ranging method provided in an embodiment of the present application; Figure 2 It is a flowchart of an implementation method of determining a boundary to be measured that matches the target location information provided in an embodiment of the present application; Figure 3 It is a flowchart of an implementation method of displaying an image as multiple areas provided in an embodiment of the present application; Figure 4 is a flow chart of another implementation of the ranging method provided in an embodiment of the present application; Figure 5 It is a flow chart of an implementation of an electronic device provided in an embodiment of the present application; Figure 6 It is a schematic diagram of a computer-readable medium provided in an embodiment of the present application.
[0018] Description of Reference Numerals 101: Processor 102: Memory 103: I / O interface 104: bus DETAILED DESCRIPTION The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments based on the embodiments are intended to be used to explain the present application and cannot be understood as limiting the present application.
[0019] References to "one embodiment" or "an example" or "an example" in this specification mean that a particular feature, structure, or characteristic described in conjunction with the embodiment itself may be included in at least one embodiment disclosed in the present application. The appearance of the phrase "in one embodiment" in various places in the specification does not necessarily refer to the same embodiment.
[0020] Currently, the way that camera equipment realizes the distance measurement function is usually: the user manually selects two positioning points first, and then uses the pinhole imaging principle to calculate the distance between the two positioning points according to the focal length of the lens and the distance between the object and the camera equipment. However, this method is only applicable to camera equipment with a lens magnification of 1x and measuring the length of line segments, and the operation is also relatively cumbersome for users.
[0021] In view of this, the applicant of this application proposes that by displaying the image as multiple areas with boundaries, the user can select the boundary to be measured with just one click. Regardless of whether the shape of the boundary is a straight line or a curve, and regardless of the actual magnification of the lens, combined with the pixel size information and the number of pixels included in the boundary to be measured, the length information of the boundary to be measured can be determined.
[0022] As a first aspect of an embodiment of the present application, a distance measurement method is provided, wherein: Figure 1 As shown, the method may include the following steps: In step S110, the image is displayed as a plurality of regions, wherein each of the regions has a boundary composed of pixels; In step S120, externally input target location information is obtained, and a boundary to be measured that matches the target location information is determined; In step S130, the distance information between the object in the image and the camera device is obtained; In step S140, the length information of the boundary to be measured is determined according to the actual magnification information of the lens of the camera device, the single-rate focal length information, the pixel size information, the distance information between the object in the image and the camera device, and the number of pixels included in the boundary to be measured.
[0023] The single-ratio focal length information refers to the focal length information when the lens ratio is 1, and the pixel size information refers to the actual length or width represented by a unit pixel in the image sensor of the camera device.
[0024] Among them, the embodiments of the present application do not make specific limitations on how to obtain the distance information between the object in the image and the camera device. For example, the camera device can calculate the depth information (the distance information between the object and the camera device) based on the binocular principle, the time of flight (Time off light, ToF) principle, the structured light principle, etc.
[0025] It is understandable that, in addition to having a border composed of pixels, each region also has an internal portion composed of pixels surrounded by the border. In the embodiment of the present application, whether each region is a regular shape or an irregular shape, and whether the border of each region is one or more, is not specifically limited. The border of each region can be a complete curve and / or straight line connected end to end, or can include multiple curves and / or straight lines, and these multiple curves and / or straight lines are connected end to end to form a closed coil. After the image is displayed as multiple regions, the user can click on any boundary to input the target position information, and the boundary to be measured required by the user can be determined according to the target position information, and then the length information of the boundary to be measured can be determined.
[0026] In the distance measurement method provided in the embodiment of the present application, an image is displayed as a plurality of regions each having a boundary composed of pixels, target position information inputted from the outside by a user by clicking on a boundary range is obtained, and then a boundary to be measured that matches the target position information is determined. Based on the actual lens magnification information of the camera device, the single-rate focal length information, and the distance information between the object in the image and the camera device, combined with the pixel size information of the camera device and the number of pixels included in the boundary to be measured, the length information of the boundary to be measured can be determined regardless of whether the shape of the boundary is a straight line or a curve, and regardless of the actual lens magnification. The method is applicable to camera devices with any lens magnification and length measurement of any shape, and simplifies user operations to bring convenience to users.
[0027] According to the pinhole imaging principle, the displayed length z of the boundary to be measured in the image sensor is related to the actual magnification information of the lens. , Single ratio focal length information , the distance information between the object and the camera device And the length information of the boundary to be measured The following relationship is satisfied: (a).
[0028] The displayed length of the boundary to be measured in the image sensor The number of pixels included in the boundary to be measured With pixel size information The product of pixel size information The unit is usually micrometer, and the single-magnification focal length information The unit is usually millimeters, then the displayed length of the boundary to be measured in the image sensor is mm, further rewriting formula (a) can obtain the length information of the boundary to be measured The calculation formula for .
[0029] Correspondingly, in some embodiments, the length information of the boundary to be measured is determined by the following formula: (1); In formula (1), represents the length information of the boundary to be measured, represents the number of pixels included in the boundary to be measured, represents the pixel size information, represents the distance information between the object in the image and the imaging device, represents the single magnification focal length information, represents the actual magnification information of the lens.
[0030] For how to determine the boundary to be measured that meets the user's needs according to the target position information input from the outside, it can be achieved by comparing the coordinates of the target position information with the coordinates of the pixels in the image. Correspondingly, in some embodiments, the pixels in the boundary have a first coordinate and a second coordinate, and the target position information includes a target first coordinate and a target second coordinate. As Figure 2 shown, the steps for determining the boundary to be measured that matches the target position information (i.e., involved in step S120) may include the following steps: In step S121, from the boundaries of the multiple regions, the boundary containing the matching pixels is determined as the boundary to be measured; wherein, the matching pixels are the pixels located on the boundary and the distances between the first coordinate and the target first coordinate and between the second coordinate and the target second coordinate are both less than a preset threshold.
[0031] Taking , to represent the target first coordinate and the target second coordinate of the target position information respectively, and taking , to represent the first coordinate and the second coordinate of the pixel in the image respectively, then the difference between and and the distance between and can be determined from the pixels of each boundary to be less than the preset threshold as the matching pixels. The relationship between the first coordinate and the second coordinate of the matching pixels and the target first coordinate and the target second coordinate of the target position information can be expressed as: | - | < thr and | - | < thr, where thr represents the preset threshold.
[0032] In order to accurately locate the boundary to be measured required by the user according to the target position information, the preset threshold can be determined in combination with the resolution of the image. Accordingly, in some embodiments, the preset threshold is determined according to the resolution of the image.
[0033] The preset threshold is not specifically limited in the embodiment of the present application. For example, when the resolution of the image is 1080P, the preset threshold can be set to 5 pixels. Of course, the embodiment of the present application is not limited to this. It is feasible to set the preset threshold to any other reasonable value according to the resolution of the image.
[0034] As described above, the boundary of each region may be a complete curve and / or straight line connected end to end, or may include multiple curves and / or straight lines, and the multiple curves and / or straight lines are connected end to end to form a closed coil. Accordingly, in some embodiments, the shapes of the multiple regions include irregular shapes and / or regular shapes, and the number of boundaries of each region includes one or more.
[0035] To facilitate user selection, each boundary may be displayed in a different color. Figure 3 As shown, the step of displaying the image as multiple regions (ie, the step involved in step S110 ) may include the following steps: In step S111, the image is segmented to obtain multiple regions; In step S112, the boundaries of the plurality of regions are displayed in two different colors.
[0036] In the case where there are a large number of boundaries, each boundary may be displayed with a different color value, as long as different boundaries can be distinguished so that the user can recognize different boundaries with the naked eye.
[0037] In the distance measurement method provided in the embodiment of the present application, the image is segmented to obtain multiple areas, and the boundaries of the multiple areas are displayed as two different colors, so that different boundaries can be distinguished, so that the user can identify different boundaries with the naked eye, and input the target position information from the outside by clicking on the boundary range, thereby improving the interaction effect. The user only needs to click once to select the boundary to be measured, which simplifies the user operation and brings convenience to the user.
[0038] After determining the length information of the boundary to be measured, it can also be displayed at the location where the user clicks, further reducing the number of user interactions. Figure 4As shown, after determining the length information of the boundary to be measured according to the actual magnification information of the lens of the camera device, the single-rate focal length information, the pixel size information, the distance information between the object in the image and the camera device, and the number of pixels included in the boundary to be measured (i.e., step S140), the method may further include the following steps: In step S150, the length information of the boundary to be measured is displayed according to the target position information.
[0039] In the distance measurement method provided in the embodiment of the present application, an image is displayed as multiple areas each having a boundary composed of pixels, target position information input from the outside by a user by clicking on a boundary range is obtained, and then a boundary to be measured that matches the target position information is determined. On the basis of actual lens magnification information of a camera device, single-rate focal length information, and distance information between an object in an image and the camera device, combined with pixel size information of the camera device and the number of pixels included in the boundary to be measured, no matter whether the shape of the boundary is a straight line or a curve, and no matter what the actual magnification of the lens is, the length information of the boundary to be measured can be determined. The method is applicable to camera devices with any lens magnification and length measurement of any shape. Moreover, the length information of the boundary to be measured is displayed according to the target position information, that is, the determined length information of the boundary to be measured is directly displayed at the position clicked by the user, further simplifying the user operation and bringing convenience to the user.
[0040] As a second aspect of the embodiments of the present application, an electronic device is provided, wherein: Figure 5 As shown, the electronic device includes: One or more processors 101; The memory 102 stores one or more computer programs. When the one or more computer programs are executed by the one or more processors 101, the one or more processors 101 implement the ranging method provided in the first aspect of the embodiment of the present application.
[0041] The electronic device may further include one or more I / O interfaces 103 connected between the processor 101 and the memory 102 and configured to implement information interaction between the processor 101 and the memory 102 .
[0042] Among them, the processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU), etc.; the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) is connected between the processor and the memory, and can realize information exchange between the processor and the memory, including but not limited to a data bus (Bus), etc.
[0043] In some embodiments, the processor 101 , the memory 102 , and the I / O interface 103 are connected to each other via a bus 104 , and further connected to other components of the computing device.
[0044] As a third aspect of an embodiment of the present application, a camera device is provided, wherein the camera device includes the electronic device provided in the second aspect of the embodiment of the present application.
[0045] In the camera device provided in the embodiment of the present application, the image is displayed as multiple areas each having a boundary composed of pixels, and the target position information input from the outside by the user by clicking on the boundary range is obtained, and then the boundary to be measured that matches the target position information is determined. Based on the actual magnification information of the lens of the camera device, the single-rate focal length information, and the distance information between the object in the image and the camera device, combined with the pixel size information of the camera device and the number of pixels included in the boundary to be measured, no matter whether the shape of the boundary is a straight line or a curve, and no matter what the actual magnification of the lens is, the length information of the boundary to be measured can be determined. This is suitable for camera devices with any lens magnification and length measurement of any shape, and simplifies user operations to bring convenience to users.
[0046] The camera device can also segment the image to obtain multiple areas, and display the boundaries of the multiple areas in pairs of different colors, so that different boundaries can be distinguished, allowing the user to identify different boundaries with the naked eye, and thus input target position information from the outside by clicking on the boundary range, thereby improving the interactive effect. The user only needs to click once to select the boundary to be measured, which simplifies the user operation and brings convenience to the user.
[0047] The camera device can also display the length information of the boundary to be measured according to the target position information, that is, directly display the determined length information of the boundary to be measured at the position clicked by the user, further simplifying the user operation and bringing convenience to the user.
[0048] As a fourth aspect of the embodiment of the present application, Figure 6As shown, a computer-readable medium is provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the ranging method provided in the first aspect of the embodiment of the present application is implemented.
[0049] It will be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. Accordingly, the computer program can be stored in a non-volatile computer-readable storage medium, and the computer program can implement the method of any of the above-mentioned embodiments when executed. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the embodiments of the present application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0050] The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Those skilled in the art should understand that the present application includes but is not limited to the contents described in the drawings and the above specific embodiments. Any modification that does not deviate from the functional and structural principles of the present application will be included in the scope of the claims.
Claims
1. A distance measurement method, characterized in that: The method comprises: Displaying an image as a plurality of regions; wherein each of the regions has a boundary composed of pixels; Acquire externally input target location information, and determine a boundary to be measured that matches the target location information; Acquire distance information between the object in the image and the camera device; The length information of the boundary to be measured is determined according to the actual magnification information of the lens of the camera device, the single-rate focal length information, the pixel size information, the distance information between the object in the image and the camera device, and the number of pixels included in the boundary to be measured.
2. The method according to claim 1, characterized in that The length information of the boundary to be measured is determined by the following formula: (1); In formula (1), Indicates the length information of the boundary to be measured. Indicates the number of pixels included in the boundary to be measured, Represents pixel size information, represents the distance information between the object in the image and the camera device, Indicates single-magnification focal length information. Indicates the actual lens magnification information.
3. The method according to claim 1, characterized in that: The pixel in the boundary has a first coordinate and a second coordinate, the target position information includes the target first coordinate and the target second coordinate, and determining the boundary to be measured that matches the target position information includes: From the boundaries of the multiple areas, a boundary containing matching pixels is determined as a boundary to be measured; wherein the matching pixels are pixels located on the boundary and the distance between the first coordinate and the first coordinate of the target and the distance between the second coordinate and the second coordinate of the target are both less than a preset threshold.
4. The method according to claim 3, characterized in that The preset threshold is determined according to the resolution of the image.
5. The method according to claim 1, characterized in that The shapes of the multiple regions include irregular shapes and / or regular shapes, and the number of boundaries of each region includes one or more.
6. The method according to any one of claims 1 to 5, characterized in that Displaying the image as a plurality of regions comprises: Segment the image to obtain multiple regions; The boundaries of the plurality of regions are displayed in two different colors.
7. The method according to any one of claims 1 to 5, characterized in that After determining the length information of the boundary to be measured according to the actual magnification information of the lens of the camera device, the single-rate focal length information, the pixel size information, the distance information between the object in the image and the camera device, and the number of pixels included in the boundary to be measured, the method further includes: The length information of the boundary to be measured is displayed according to the target position information.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by the one or more processors, the one or more processors implement the ranging method according to any one of claims 1 to 7.
9. A camera device, characterized in that: The imaging device includes the electronic device according to claim 8.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the distance measurement method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for measuring distance
CN107687841A
Distance measuring method and device
CN112567201A
Object surface perimeter and area measurement method based on SLAM algorithm and image instance segmentation technology
CN114719759A
Monocular vision ranging method, camera and medium
CN116182786A
Structural crack detection method based on machine vision and human-computer interaction
CN117928487A
