Object measurement method, device, equipment and storage medium
Through image analysis technology, the proportion of the reference object is used to measure the size of the object being measured, which solves the problem of difficulty in measurement when taking photos with a smartphone, enables fast and accurate object size measurement without tools, and improves convenience.
Patent Information
- Application Number
- CN202110895442.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-05
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-08-05
AI Technical Summary
When users use smartphones to take photos, it is difficult to quickly and accurately measure the length or width of the object being photographed. They need to carry measuring tools, which affects convenience.
By obtaining an image containing the measured object and a reference object of known actual size, determine the ratio of the reference size and the actual size of the reference object in the image, and use this ratio value to measure the actual size of the measured object, achieving no-carry measurement Tools for fast and accurate measurements.
It improves the convenience and accuracy of object measurement, and users can quickly measure the size of objects without carrying additional tools.
Smart Images

Figure CN113592833B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image analysis technology, and in particular to an object measurement method, device, equipment and storage medium. Background Art
[0002] With the continuous development of handheld terminal devices, users have put forward higher and higher requirements on the functions of handheld terminal devices.
[0003] Taking a smartphone as an example, when a user is taking photos with a smartphone, if he wants to know the length or width of an object being photographed, he needs to use a special measuring tool to measure the object. However, in practice, it is difficult for the user to carry a measuring tool with him just to measure a certain object being photographed, which brings certain inconveniences to the user.
[0004] Therefore, there is an urgent need to improve the problems existing in the prior art. Summary of the invention
[0005] The present application provides an object measurement method, device, equipment and storage medium to improve the convenience of object measurement.
[0006] In a first aspect, an embodiment of the present application provides an object measurement method, the method comprising:
[0007] Acquire a current image to be identified including the object to be measured and a reference object with known actual size;
[0008] Determining a ratio between the current reference size and the actual size according to a current reference size of the reference object in the current image to be recognized and an actual size of the reference object;
[0009] The actual size of the object to be measured is determined according to the ratio value and the current reference size of the object to be measured in the current image to be identified.
[0010] In a second aspect, an embodiment of the present application further provides an object measuring device, the device comprising:
[0011] The module for acquiring an image to be identified is used to acquire a current image to be identified including the object to be measured and a reference object of known actual size;
[0012] a ratio value determination module, configured to determine a ratio value between the current reference size and the actual size according to the current reference size of the reference object in the current image to be recognized and the actual size of the reference object;
[0013] The object size measurement module is used to determine the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be identified.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, the device comprising:
[0015] one or more processors;
[0016] a storage device for storing one or more programs,
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement any one of the object measurement methods provided in the first aspect embodiment.
[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any one of the object measurement methods provided in the embodiment of the first aspect.
[0019] The embodiment of the present application obtains a current image to be identified that includes the object to be measured and a reference object of known actual size; determines the ratio between the current reference size and the actual size according to the current reference size of the reference object in the current image to be identified and the actual size of the reference object; determines the actual size of the object to be measured according to the ratio and the current reference size of the object to be measured in the current image to be identified. Through the above technical solution, the present application determines the actual size of the object to be measured only by performing image analysis on the current image to be identified, so that the size of the object can be measured quickly and accurately without carrying a measuring tool, thereby improving the convenience of measurement. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of an object measurement method provided in Example 1 of the present application;
[0021] Figure 2 is a flow chart of an object measurement method provided in Embodiment 2 of the present application;
[0022] Figure 3 This is a schematic diagram of measuring an object at different shooting angles provided in Embodiment 2 of the present application;
[0023] Figure 4 It is a schematic diagram of measuring an object at different shooting distances provided in the second embodiment of the present application;
[0024] Figure 5 is a flow chart of an object measurement method provided in Embodiment 3 of the present application;
[0025] Figure 6 This is a schematic diagram of a terminal screen displaying a virtual ruler provided in Embodiment 3 of the present application;
[0026] Figure 7 is a schematic diagram of an object measuring device provided in Embodiment 4 of the present application;
[0027] Figure 8 This is a schematic diagram of an electronic device provided in Example 5 of the present application. DETAILED DESCRIPTION
[0028] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only the parts related to the present application, rather than all structures, are shown in the accompanying drawings.
[0029] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0030] Embodiment 1
[0031] Figure 1 A flowchart of an object measurement method provided in Embodiment 1 of the present application. Embodiments of the present application may be applicable to the case of measuring an object to be measured in an image. The method may be performed by an object measurement device, which may be implemented by software and / or hardware and specifically configured in an electronic device, which may be a mobile terminal or a fixed terminal.
[0032] See also Figure 1 , the object measurement method provided in the embodiment of the present application includes:
[0033] S110, obtaining a current image to be recognized including the object to be measured and a reference object with a known actual size.
[0034] The current image to be identified refers to the image to be identified that is currently captured and includes the object to be measured and a reference object with a known actual size.
[0035] Specifically, the current image to be recognized may be acquired by taking a photo or recording a video based on a shooting terminal with a shooting function, such as a smart phone or a tablet computer.
[0036] In this embodiment, the reference object may be a specific reference object pre-placed in the shooting scene, such as a ruler with scales. Of course, the reference object may also be other objects with scales. Depending on the shooting scene, different types of reference objects may be placed accordingly to achieve the adaptation of the reference object to the shooting scene. For example, when the shooting scene is an underwater environment, a stone with scales may be placed instead of a ruler as a reference object.
[0037] In some embodiments, objects such as one-dollar coins or hundred-dollar bills may also be used as reference objects, because these objects are easy to identify and users generally carry them with them.
[0038] In this embodiment, different reference objects have different actual sizes. Therefore, the categories of reference objects and their actual sizes can be stored in a one-to-one correspondence. When the current image to be identified is acquired, the actual size of the reference object can be determined by identifying the category of the reference object in the current image to be identified.
[0039] S120 , determining a ratio between the current reference size and the actual size according to the current reference size of the reference object in the current image to be recognized and the actual size of the reference object.
[0040] The current reference size refers to the size of the reference object in the current image to be identified. Specifically, the current reference size can be determined by determining the number of pixels of the reference object in the current image to be identified.
[0041] Optionally, after acquiring the current image to be identified including the object to be measured and a reference object of known actual size, it may also include: determining a gradient image and an angle image of the current image to be identified; determining the object edge of the object to be measured and the object edge of the reference object based on the gradient image and the angle image; determining the current reference size of the object to be measured based on the object edge of the object to be measured, and determining the current reference size of the reference object based on the object edge of the reference object.
[0042] It can be understood that by effectively identifying the object edges of the reference object and the object to be measured from the image to be identified based on the gradient image and the angle image of the current image to be identified, it is helpful to accurately determine the reference sizes of the reference object and the object to be measured.
[0043] In order to improve the accuracy of determining the edge of an object, optionally, determining the gradient image and the angle image of the current image to be identified includes: using a preset Gaussian filter to filter the image to be identified to obtain the current image to be identified after filtering; and determining the gradient image and the angle image of the current image to be identified based on the current image to be identified after filtering.
[0044] The preset Gaussian filter may be a Gaussian filter with a two-dimensional Gaussian distribution.
[0045] In this embodiment, the preset Gaussian filter may be a Gaussian filter predetermined according to actual conditions. For example, different Gaussian filters may be predetermined according to different shooting scenes, and different Gaussian filters may have different parameters, such as different standard deviations of Gaussian distributions.
[0046] It can be understood that filtering and denoising the current image to be identified using a preset Gaussian filter is beneficial to the subsequent determination of the object edges of the reference object and the object to be detected in the current image to be identified. Since noise will affect the accuracy of edge detection, the noise can be filtered out first.
[0047] Optionally, before using a preset Gaussian filter to filter the image to be identified, it can also include: performing grayscale transformation on the image to be identified to obtain a grayscale image after grayscale transformation; based on a preset grayscale threshold, binarizing the grayscale image to obtain the image to be identified after binarization.
[0048] Specifically, the grayscale transformation can use a preset grayscale transformation formula to calculate each pixel in the current image to be identified, so as to transform the color current image to be identified into a grayscale image. The preset grayscale transformation formula can be expressed as:
[0049] Gray=0.299R+0.587G+0.114B;
[0050] Among them, R, G and B respectively represent the color values of the three channels of the current image to be identified before the grayscale transformation, and Gray represents the grayscale value of each pixel in the current image to be identified after the grayscale transformation.
[0051] In this embodiment, the preset grayscale threshold may be a grayscale threshold pre-set based on an empirical value. More specifically, the grayscale threshold may be determined based on features such as a shooting scene, a reference object, and a measured object.
[0052] Specifically, after obtaining the grayscale image after grayscale transformation, by selecting an appropriate preset grayscale threshold, pixels with grayscale values greater than or equal to the preset grayscale threshold are judged to belong to a specific object, and their grayscale values are set to 255, representing the reference object and the object to be measured; pixels with grayscale values less than the preset grayscale threshold are excluded from the specific object area, and their grayscale values are set to 0, representing the shooting background or an area different from the reference object and the object to be measured.
[0053] Of course, it should be noted that there may be multiple specific objects in the current image to be identified, and the object to be measured can be specified by the terminal user's trigger operation such as clicking or touching, and then the object to be measured can be measured.
[0054] It can be understood that by performing grayscale transformation and binarization processing on the current image to be identified, the amount of data of the current image to be identified is reduced, the image becomes simpler, and the target object of interest in the image can be highlighted, which is beneficial to further processing of the current image to be identified.
[0055] S130 , determining the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be identified.
[0056] Specifically, after the ratio value is determined, the ratio value can be used as a magnification factor to magnify the current reference size of the object to be measured in the current image to be identified, thereby determining the actual size of the object to be measured.
[0057] The embodiment of the present application obtains a current image to be identified that includes the object to be measured and a reference object of known actual size; determines the ratio between the current reference size and the actual size according to the current reference size of the reference object in the current image to be identified and the actual size of the reference object; determines the actual size of the object to be measured according to the ratio and the current reference size of the object to be measured in the current image to be identified. Through the above technical solution, the present application determines the actual size of the object to be measured only by performing image analysis on the current image to be identified, so that the size of the object can be measured quickly and accurately without carrying a measuring tool, thereby improving the convenience of measurement.
[0058] Embodiment 2
[0059] Figure 2 This is a flow chart of an object measurement method provided in Embodiment 2 of the present application. This embodiment is an optimization of the above-mentioned solution based on the above-mentioned embodiment.
[0060] Furthermore, before obtaining the current image to be identified including the object to be measured and a reference object of known actual size, an operation of "obtaining at least one frame of historical image to be identified including the object to be measured and a reference object of known actual size" is added; accordingly, the operation of "determining the ratio between the current reference size and the actual size based on the current reference size of the reference object in the current image to be identified and the actual size of the reference object" is refined into "determining the reference size of the reference object based on the historical reference size of the reference object in the historical images to be identified and the current reference size of the reference object in the current image to be identified; determining the ratio between the reference size and the actual size based on the reference size and the actual size" so as to clarify the process of determining the ratio value when the image to be identified includes at least one frame of historical image to be identified and the current image to be identified.
[0061] The explanations of the terms that are the same as or corresponding to the above embodiments will not be repeated here.
[0062] See also Figure 2 , the object measurement method provided in this embodiment includes:
[0063] S210, obtaining at least one frame of historical image to be identified including the object to be measured and a reference object of known actual size.
[0064] The historical image to be identified refers to an image to be identified that is taken at any time in the past and includes a measured object and a reference object with a known actual size.
[0065] Optionally, the historical image to be identified and the current image to be identified have different shooting angles and / or shooting distances.
[0066] Among them, the shooting angle refers to the shooting angle between the shooting terminal and the object to be measured; the shooting distance refers to the facing distance between the shooting terminal and the object to be measured.
[0067] Specifically, see Figure 3 A schematic diagram of measuring an object at different shooting angles is shown. Figure 3 The following example shows the case where the same shooting device is at different shooting angles A and B. Figure 4 A schematic diagram of measuring an object at different shooting distances is shown. Figure 4 The case where the same photographing device is at different photographing distances L1 and L2 is exemplified.
[0068] The difference in shooting angle between the historical image to be identified and the current image to be identified may be that, when other conditions such as shooting distance remain unchanged, only the shooting angle between the shooting terminal and the object to be measured is changed, for example, the shooting angle may be increased by 0.1 degree, 0.5 degree or 0.8 degree on the basis of the previous shooting angle; the difference in shooting distance between the historical image to be identified and the current image to be identified may be that, when other conditions such as shooting angle remain unchanged, only the facing distance between the shooting terminal and the object to be measured is changed, for example, the facing distance may be 10 meters, 10.1 meters or 10.2 meters.
[0069] In order to ensure the accuracy of measurement, typically, the historical image to be recognized and the current image to be recognized are shot at different angles; or, the historical image to be recognized and the current image to be recognized are shot at different distances.
[0070] It is understandable that in order to avoid the influence of changes in multiple factors on the captured images and ultimately on the measurement results, only the shooting angle or shooting distance between the historical image to be identified and the current image to be identified may be changed.
[0071] In this embodiment, in order to improve the accuracy of object edge determination, after obtaining at least one frame of historical image to be identified including the object to be measured and a reference object of known actual size, it is also possible to determine the gradient image and angle image of the historical image to be identified; determine the object edge of the object to be measured and the object edge of the reference object based on the gradient image and the angle image; determine the historical reference size of the object to be measured based on the object edge of the object to be measured, and determine the historical reference size of the reference object based on the object edge of the reference object.
[0072] S220: Acquire a current image to be identified including the object to be measured and a reference object with a known actual size.
[0073] S230 , determining a reference size of the reference object according to a historical reference size of the reference object in a historical image to be recognized and a current reference size of the reference object in a current image to be recognized.
[0074] The historical reference size refers to the size of the reference object in the historical image to be identified. Specifically, the historical reference size can be determined by determining the number of pixels of the reference object in the historical image to be identified.
[0075] It can be understood that in order to improve the accuracy of determining the reference size of the reference object, the reference size of the reference object can be determined based on the historical reference size and the current reference size of the reference object.
[0076] In this embodiment, if there are multiple frames of historical images to be recognized, the historical reference sizes of the reference object in different historical images to be recognized can be determined respectively.
[0077] Optionally, different confidence values may be assigned to the historical images to be identified and the current images to be identified according to the positional relationship between the historical images to be identified and the current images to be identified, and the reference size of the reference object may be determined by weighted sum and averaging according to the different confidence values according to the historical reference size of the reference object in the historical images to be identified and the current reference size of the reference object in the current images to be identified. The positional relationship includes a shooting distance relationship and / or a shooting angle relationship.
[0078] Typically, the average value of the historical reference size and the current reference size can be directly determined as the reference size of the reference object.
[0079] S240: Determine a ratio between the reference size and the actual size according to the reference size and the actual size of the reference object.
[0080] S250: Determine the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be identified.
[0081] In this embodiment, after the ratio value is determined, the ratio value can be directly used as a magnification factor to magnify the current reference size of the object to be measured in the current image to be identified, thereby determining the actual size of the object to be measured.
[0082] Optionally, in order to improve the accuracy of measurement, the actual size of the object to be measured is determined according to the ratio value and the current reference size of the object to be measured in the current image to be identified, including: determining the actual size of the object to be measured according to the ratio value, the historical reference size of the object to be measured in the historical images to be identified, and the current reference size of the object to be measured in the current image to be identified.
[0083] In this embodiment, the historical reference value of the object to be measured can be determined based on the ratio value and the historical reference size of the object to be measured in the historical image to be identified, and the current reference value of the object to be measured can be determined based on the ratio value and the current reference size of the object to be measured in the current image to be identified; the current reference value is adjusted based on the historical reference value, and the adjusted current reference value is used as the actual size of the object to be measured.
[0084] Specifically, adjusting the current reference value according to the historical reference value and determining the adjusted current reference value as the actual size of the object to be measured includes: taking the average value of the historical reference value and the current reference value as the actual size of the object to be measured.
[0085] In some embodiments, multiple ratio values may also be determined based on at least one frame of the historical image to be identified and the current image to be identified. Specifically, a first ratio value is determined based on the historical reference size of the reference object in the historical image to be identified and its actual size; a second ratio value is determined based on the current reference size of the reference object in the current image to be identified and its actual size; and the actual size of the object to be identified is determined based on the first ratio value and the second ratio value, as well as the historical reference size of the object to be identified in the historical image to be identified and the current reference size of the object to be identified in the current image to be identified.
[0086] Specifically, the actual size of the object to be measured is determined according to the first ratio value and the second ratio value, as well as the historical reference size of the object to be measured in the historical image to be identified and the current reference size of the object to be measured in the current image to be identified, including: determining the historical measurement value according to the first ratio value and the historical reference size of the object to be measured in the historical image to be identified; determining the current measurement value according to the second ratio value and the current reference size of the object to be measured in the current image to be identified; and determining the actual size of the object to be measured according to the historical measurement value and the current measurement value.
[0087] Typically, the average of the historical measurement value and the current measurement value can be taken as the actual size of the measured object.
[0088] Optionally, when there are multiple frames of historical images to be identified, multiple first ratio values may be determined according to historical reference sizes of the reference object in different historical images to be identified and its actual sizes.
[0089] Based on the above embodiments, the present application embodiment clarifies the process of determining the ratio value when the image to be identified includes at least one frame of historical image to be identified and the current image to be identified. Before obtaining the current image to be identified including the object to be identified and the reference object with known actual size, at least one frame of historical image to be identified including the object to be identified and the reference object with known actual size is obtained, and the reference size of the reference object is determined according to the historical reference size of the reference object in the historical image to be identified and the current reference size of the reference object in the current image to be identified; and the ratio value between the reference size and the actual size is determined according to the reference size and the actual size of the reference object. Through the above technical solution, the reference size of the reference object is comprehensively determined based on at least one frame of historical image to be identified and the current image to be identified, and the ratio value is calculated according to the reference size and the actual size of the reference object, thereby improving the calculation accuracy of the ratio value, so that the size of the object can be quickly and accurately measured without carrying a measuring tool, thereby improving the accuracy of the measurement.
[0090] Embodiment 3
[0091] Figure 5This is a flow chart of an object measurement method provided in Example 3 of the present application. This embodiment is an optimization of the above-mentioned solution based on the above-mentioned embodiment.
[0092] Furthermore, the operation of "determining the actual size of the object to be measured based on the ratio value and the current reference size of the object to be measured in the current image to be identified" is refined into "constructing a virtual ruler in the terminal screen based on the ratio value; aligning the virtual ruler with one end of the length of the object to be measured based on the trigger operation of the terminal user on the terminal screen; determining the actual size of the object to be measured based on the virtual ruler" to clarify the process of determining the actual size of the object to be measured.
[0093] The explanations of the terms that are the same as or corresponding to the above embodiments will not be repeated here.
[0094] See also Figure 5 , the object measurement method provided in this embodiment includes:
[0095] S310: Acquire a current image to be identified including the object to be measured and a reference object with known actual size.
[0096] S320: Determine a ratio between the current reference size and the actual size according to the current reference size of the reference object in the current image to be recognized and the actual size of the reference object.
[0097] S330. Construct a virtual ruler on the terminal screen according to the scale value.
[0098] In this embodiment, a virtual ruler may be placed horizontally below the terminal screen.
[0099] Of course, in some embodiments, two pairs of mutually perpendicular virtual rulers may be constructed on the terminal screen, and the two pairs of virtual rulers intersect at the lower left corner of the terminal screen. Figure 6 A schematic diagram of a terminal screen displaying a virtual ruler is shown.
[0100] Optionally, the process of constructing a virtual ruler on the terminal screen may also include: determining a color attribute of a preset reference point in the background of the current image to be identified; and determining a display color of the virtual ruler on the terminal screen according to the color attribute of the preset reference point.
[0101] The preset reference point is a pixel point in the background of the current image to be identified. In order to accurately extract the background color of the current image to be identified, the number of preset reference points can be at least one or more. In the case of multiple preset reference points, the average value of the color attributes of the multiple preset reference points can be used as the background color of the current image to be identified, wherein the color attribute is the RGB value.
[0102] Specifically, the inverse color value of the color attribute of the preset reference point can be used as the display color of the virtual ruler on the terminal screen. The inverse color is also called the complementary color, and the inverse color can be calculated by the following formula:
[0103] Inverted color flux = 255 - original color flux;
[0104] For example, red is represented by RGB (255, 0, 0) and cyan is represented by RGB (0, 255, 255). Red and cyan are opposite colors.
[0105] It is understandable that the display color of the virtual ruler will automatically invert according to the background color of the current image to be identified. When the color of the background object changes, the display color of the virtual ruler will also change accordingly. The display color of the virtual ruler has a large color difference from the background color, which makes it easier for users to clearly see the scale value.
[0106] S340: According to a triggering operation of the terminal user on the terminal screen, align the virtual ruler with one end of the length of the object to be measured.
[0107] The trigger operation may be a click operation, a touch operation, or a drag operation on the terminal screen by the terminal user. Of course, the trigger operation may also be performed by the terminal user through voice.
[0108] It should be noted that the trigger operation proposed above is not the only trigger mode, and other trigger modes can also be determined according to actual needs, all of which are within the protection scope of the present invention.
[0109] In this embodiment, the virtual ruler may be aligned with a width end to be measured and / or a length end to be measured of the object to be measured.
[0110] Optionally, after a virtual ruler is constructed on the terminal screen according to the scale value, the object to be measured may be automatically aligned with the virtual ruler according to a preset alignment rule.
[0111] Among them, the preset alignment rule can be predetermined according to actual conditions.
[0112] In this embodiment, if the object to be measured is an irregular object, the minimum circumscribed rectangle of the object to be measured may be used as the end to be aligned.
[0113] In this embodiment, the object to be measured and the virtual ruler are automatically aligned according to preset alignment rules, which can be understood as a default alignment operation; and the terminal user triggers the operation on the terminal screen to align the virtual ruler with one end of the length of the object to be measured. It can be understood that the terminal user performs a secondary alignment adjustment based on the above-mentioned default alignment.
[0114] S350: Determine the actual size of the object to be measured according to the virtual ruler.
[0115] Specifically, the terminal user can determine the actual size of the measured object by reading the virtual ruler.
[0116] Continue to see Figure 6 The figure shows an example of dragging the virtual ruler to the edge of the measured object, the turtle. From the figure, it can be seen that the height of the measured object, the turtle, is 66 cm and the width is 122 cm.
[0117] It can be understood that the practicality of the measurement is improved through the interactive measurement between the virtual ruler and the end user, and it is not limited to directly giving the measurement results of the measured object, and the operability of the end user is greatly improved.
[0118] Based on the above embodiments, the embodiment of the present application clarifies the process of determining the actual size of the object to be measured, by constructing a virtual ruler on the terminal screen according to the ratio value; aligning the virtual ruler with one end of the length of the object to be measured according to the trigger operation of the terminal user on the terminal screen; and determining the actual size of the object to be measured according to the virtual ruler. Through the above technical solution, by drawing a virtual ruler on the terminal screen and responding to the trigger operation of the terminal user on the terminal screen, the measurement of the object to be measured is achieved, which improves the interaction between the terminal device and the terminal user, and brings great convenience to the user's measurement.
[0119] Embodiment 4
[0120] Figure 7 Schematic diagram of the structure of an object measuring device provided in the fourth embodiment of the present application. Figure 7 An embodiment of the present application provides an object measuring device, which includes: an image acquisition module 410 for identification, a ratio value determination module 420 and an object size measurement module 430.
[0121] The to-be-recognized image acquisition module 410 is used to acquire a current to-be-recognized image including a measured object and a reference object of known actual size;
[0122] A ratio value determination module 420, configured to determine a ratio value between the current reference size and the actual size according to the current reference size of the reference object in the current image to be recognized and the actual size of the reference object;
[0123] The object size measurement module 430 is used to determine the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be recognized.
[0124] The embodiment of the present application obtains a current image to be identified that includes the object to be measured and a reference object of known actual size; determines the ratio between the current reference size and the actual size according to the current reference size of the reference object in the current image to be identified and the actual size of the reference object; determines the actual size of the object to be measured according to the ratio and the current reference size of the object to be measured in the current image to be identified. Through the above technical solution, the present application determines the actual size of the object to be measured only by performing image analysis on the current image to be identified, so that the size of the object can be measured quickly and accurately without carrying a measuring tool, thereby improving the convenience of measurement.
[0125] Furthermore, the device also includes:
[0126] A historical image acquisition module for acquiring a to-be-recognized image, used to acquire at least one frame of a historical image to-be-recognized image including the to-be-recognized object and a reference object with a known actual size before acquiring a current image to-be-recognized image including the to-be-recognized object and a reference object with a known actual size;
[0127] Accordingly, the ratio value determination module 420 includes:
[0128] A reference size determination unit, configured to determine a reference size of the reference object according to a historical reference size of the reference object in the historical image to be identified and a current reference size of the reference object in the current image to be identified;
[0129] The ratio value determining unit is used to determine the ratio value between the reference size and the actual size according to the reference size and the actual size of the reference object.
[0130] Furthermore, the object size measurement module 430 includes:
[0131] The object size determination unit is used to determine the actual size of the object to be detected based on the ratio value, the historical reference size of the object to be detected in the historical image to be identified, and the current reference size of the object to be detected in the current image to be identified.
[0132] Furthermore, the historical image to be identified and the current image to be identified have different shooting angles and / or shooting distances.
[0133] Furthermore, the device also includes:
[0134] A gradient image acquisition module, used to determine a gradient image and an angle image of the current image to be identified after acquiring a current image to be identified including the object to be detected and a reference object of known actual size;
[0135] An object edge determination module, used to determine the object edge of the measured object and the object edge of the reference object according to the gradient image and the angle image;
[0136] The reference size determination module is used to determine the current reference size of the measured object according to the object edge of the measured object, and to determine the current reference size of the reference object according to the object edge of the reference object.
[0137] Furthermore, the object size measurement module 430 includes:
[0138] A virtual ruler constructing unit, used to construct a virtual ruler on the terminal screen according to the ratio value;
[0139] A virtual ruler alignment unit, used to align the virtual ruler with one end of the length of the measured object according to a triggering operation of the terminal user on the terminal screen;
[0140] The object size measuring unit is used to determine the actual size of the measured object according to the virtual ruler.
[0141] Furthermore, the device also includes:
[0142] A background color determination module, used to determine the color attribute of a preset reference point in the background of the current image to be identified;
[0143] The ruler color determination module is used to determine the display color of the virtual ruler on the terminal screen according to the color attribute of the preset reference point.
[0144] The object measuring device provided in the embodiments of the present application can execute the object measuring method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0145] Embodiment 5
[0146] Figure 8 This is a structural diagram of an electronic device provided in Example 5 of the present application. Figure 8 A block diagram of an exemplary electronic device 512 suitable for implementing embodiments of the present application is shown. Figure 8 The electronic device 512 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0147] like Figure 8 As shown, the electronic device 512 is in the form of a general purpose computing device. The components of the electronic device 512 may include, but are not limited to: one or more processors or processing units 516, a system memory 528, and a bus 518 connecting different system components (including the system memory 528 and the processing unit 516).
[0148] Bus 518 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MCA) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0149] The electronic device 512 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 512, including volatile and non-volatile media, removable and non-removable media.
[0150] The system memory 528 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 530 and / or cache memory 532. The electronic device 512 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 534 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 not shown, usually called a "hard drive"). Although Figure 8 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 518 via one or more data medium interfaces. The system memory 528 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0151] A program / utility 540 having a set (at least one) of program modules 542 may be stored, for example, in system memory 528, such program modules 542 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 542 generally perform the functions and / or methods of the embodiments described herein.
[0152] The electronic device 512 may also communicate with one or more external devices 514 (e.g., keyboards, pointing devices, displays 524, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 512, and / or may communicate with any device that enables the electronic device 512 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 522. Furthermore, the electronic device 512 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 520. As shown, the network adapter 520 communicates with other modules of the electronic device 512 via a bus 518. It should be understood that although Figure 8 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 512, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0153] The processing unit 516 executes various functional applications and data processing by running at least one of the other programs among the multiple programs stored in the system memory 528, such as implementing any object measurement method provided in the embodiments of the present application.
[0154] Embodiment 6
[0155] Embodiment 6 of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, an object measurement method provided in any embodiment of the present application is implemented. The method includes:
[0156] Acquire a current image to be identified including the object to be measured and a reference object with known actual size;
[0157] Determining a ratio between the current reference size and the actual size according to a current reference size of the reference object in the current image to be recognized and an actual size of the reference object;
[0158] The actual size of the object to be measured is determined according to the ratio value and the current reference size of the object to be measured in the current image to be identified.
[0159] Through the above description of the implementation method, the technicians in the relevant field can clearly understand that the present application can be implemented with the help of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0160] It is worth noting that in the embodiment of the above-mentioned object measuring device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.
[0161] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A method for measuring an object, characterized in that: include: Acquire at least one frame of historical image to be identified including the object to be measured and a reference object of known actual size; Acquire a current image to be identified including the object to be measured and a reference object with known actual size; Determining a reference size of the reference object according to a historical reference size of the reference object in the historical image to be recognized and a current reference size of the reference object in the current image to be recognized; wherein the historical image to be recognized and the current image to be recognized have different shooting angles and / or shooting distances; Determining a ratio between the reference size and the actual size according to the reference size and the actual size of the reference object; Determining the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be identified; Wherein, determining the reference size of the reference object according to the historical reference size of the reference object in the historical image to be identified and the current reference size of the reference object in the current image to be identified includes: Assigning different confidence values to the historical image to be recognized and the current image to be recognized according to the positional relationship between the historical image to be recognized and the current image to be recognized; According to different confidence values, the reference size of the reference object is determined by weighted summing and averaging the historical reference size of the reference object in the historical image to be identified and the current reference size of the reference object in the current image to be identified; Wherein, determining the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be identified includes: Determining a historical reference value of the object to be detected based on the ratio value and a historical reference size of the object to be detected in the historical image to be identified, and determining a current reference value of the object to be detected based on the ratio value and a current reference size of the object to be detected in the current image to be identified; The current reference value is adjusted according to the historical reference value, and the adjusted current reference value is used as the actual size of the object to be measured.
2. The method according to claim 1, characterized in that After obtaining the current image to be identified including the object to be measured and the reference object of known actual size, it also includes: Determine the gradient image and the angle image of the current image to be recognized; Determining the object edge of the measured object and the object edge of the reference object according to the gradient image and the angle image; The current reference size of the measured object is determined according to the object edge of the measured object, and the current reference size of the reference object is determined according to the object edge of the reference object.
3. The method according to any one of claims 1 to 2, characterized in that: Determining the actual size of the object to be detected according to the ratio value and the current reference size of the object to be detected in the current image to be identified includes: constructing a virtual ruler on the terminal screen according to the scale value; According to a triggering operation of the terminal user on the terminal screen, aligning the virtual ruler with one end of the length of the measured object; The actual size of the measured object is determined according to the virtual ruler.
4. The method according to claim 3, characterized in that The method further comprises: Determine the color attribute of a preset reference point in the background of the current image to be recognized; The display color of the virtual ruler on the terminal screen is determined according to the color attribute of the preset reference point.
5. An object measuring device, characterized in that: include: The module for acquiring an image to be identified is used to acquire a current image to be identified including the object to be measured and a reference object of known actual size; An object size measurement module, used to determine the actual size of the object to be measured according to the ratio value and the current reference size of the object to be measured in the current image to be identified; A historical image acquisition module for acquiring a to-be-recognized image, used to acquire at least one frame of a historical image to-be-recognized image including the to-be-recognized object and a reference object with a known actual size before acquiring a current image to-be-recognized image including the to-be-recognized object and a reference object with a known actual size; The ratio value determination module includes: a reference size determining unit, configured to determine the reference size of the reference object according to the historical reference size of the reference object in the historical image to be identified and the current reference size of the reference object in the current image to be identified; wherein the shooting angle and / or shooting distance of the historical image to be identified is different from that of the current image to be identified; a ratio value determining unit, configured to determine a ratio value between the reference size and the actual size according to the reference size and the actual size of the reference object; Wherein, the reference size determination unit is specifically used for: Assigning different confidence values to the historical image to be recognized and the current image to be recognized according to the positional relationship between the historical image to be recognized and the current image to be recognized; According to different confidence values, the reference size of the reference object is determined by weighted summing and averaging the historical reference size of the reference object in the historical image to be identified and the current reference size of the reference object in the current image to be identified; Among them, the object size measurement module is specifically used for: Determining a historical reference value of the object to be detected based on the ratio value and a historical reference size of the object to be detected in the historical image to be identified, and determining a current reference value of the object to be detected based on the ratio value and a current reference size of the object to be detected in the current image to be identified; The current reference value is adjusted according to the historical reference value, and the adjusted current reference value is used as the actual size of the object to be measured.
6. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement an object measurement method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, an object measurement method according to any one of claims 1 to 4 is implemented.
