Part measurement method and device, storage medium and electronic equipment
By collecting part images and calculating the target scale factor, the part measurement is realized, and the problem of low measurement accuracy and efficiency of parts in the prior art is solved, especially the measurement of circular cross-section annular parts, which improves the measurement efficiency and accuracy.
Patent Information
- Application Number
- CN202410970600.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-11-08
AI Technical Summary
In the prior art, the measurement accuracy and efficiency of parts are low, especially for special parts such as ring-shaped parts with circular cross-sections, which affects industrial production efficiency and quality.
By collecting part images, obtaining the initial scale factor, calculating the target scale factor based on the image and scale factor, and performing part measurements, avoiding relying on traditional measurement tools to achieve fast and accurate size acquisition.
It improves the efficiency and accuracy of part measurement, especially the measurement of special parts, reduces the measurement complexity and time, and meets the strict requirements of modern industry.
Smart Images

Figure CN118913098A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of visual measurement technology, and in particular to a part measurement method, device, storage medium and electronic equipment. Background Art
[0002] As a branch of artificial intelligence, machine vision has become an indispensable technical support in modern industrial production with its unique advantage - using machines to replace human eyes for precise production activities. Through machine vision products, images containing target objects can be captured and transmitted to the image processing system. The system then uses the system to perform fine calculations on the pixel distribution, brightness, color and other information of the target in the image, thereby accurately obtaining the characteristics of the target object and further guiding the precise operation of the equipment.
[0003] Projection measurement is an important development direction of machine vision. Projection measurement technology is widely used in fields such as specimen plane dimension measurement and two-dimensional digital image correlation measurement.
[0004] In the related art, although the projection measurement methods using scales, rulers, marking points, etc. can establish the proportional relationship between the image and the actual size, such methods often rely on traditional measurement tools such as vernier calipers and rulers to obtain the actual distance between target features. When the target features change, tedious re-measurement is required, which undoubtedly increases the operational complexity of part measurement and reduces measurement efficiency and measurement accuracy. Summary of the invention
[0005] The main purpose of the present invention is to provide a part measurement method, device, storage medium and electronic device, aiming to solve the technical problems of low part measurement accuracy and low efficiency in the prior art.
[0006] To achieve the above objectives, the present disclosure provides a part measurement method, comprising:
[0007] Acquire a part image, wherein the part image includes a part to be tested;
[0008] Obtaining an initial scale factor corresponding to the part to be tested;
[0009] Determining a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor;
[0010] Based on the target scale factor, part measurement is performed on the part to be measured.
[0011] Optionally, determining a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor includes:
[0012] Determining a first part height of the part to be measured according to the part image and the initial scale factor;
[0013] Calculating a first proportional factor corresponding to the first part height according to the first part height and the initial proportional factor;
[0014] Determining whether the first scale factor meets a preset condition;
[0015] When the first scale factor meets a preset condition, the first scale factor is determined as the target scale factor.
[0016] Optionally, when the first proportional factor does not meet a preset condition, the method further includes:
[0017] Determining a second part height of the part to be measured according to the part image and the first scale factor;
[0018] Calculating a second proportional factor corresponding to the second part height according to the second part height and the first proportional factor;
[0019] Determining whether the second scale factor meets the preset condition;
[0020] When the second scale factor meets a preset condition, the second scale factor is determined as the target scale factor.
[0021] Optionally, determining a first part height of the part to be measured according to the part image and the initial scale factor includes:
[0022] Based on the part image, extracting part contour points of the part to be tested;
[0023] Determine a plurality of target points of the part to be measured according to the part contour points;
[0024] The first part height is calculated based on the multiple target points and the initial scale factor.
[0025] Optionally, determining a plurality of target points of the part to be measured according to the part contour points includes:
[0026] Performing a fitting calculation based on the part contour points to determine the part center point of the part to be measured;
[0027] Determine the intersection of the camera optical axis and the image plane corresponding to the part image according to the image size of the part image;
[0028] Based on the center point of the part and the intersection point of the camera optical axis and the image plane, a mask is produced to obtain a mask image of the part to be tested;
[0029] A mask screening calculation is performed based on the mask image to determine the plurality of target points.
[0030] Optionally, calculating the first part height according to the multiple target points and the initial scale factor includes:
[0031] Determine, according to the initial scale factor, a distance value set consisting of a distance between an intersection point of the camera optical axis and the image plane and each of the multiple target points;
[0032] The first part height is obtained by calculating according to the distance value set and the camera working distance corresponding to the part image.
[0033] Optionally, calculating a first proportionality factor corresponding to the first part height according to the first part height and the initial proportionality factor includes:
[0034] The first proportional factor is calculated by the following relationship:
[0035]
[0036] Among them, s1 represents the first scale factor, S represents the initial scale factor, H represents the camera working distance corresponding to the part image, d1 represents the first part height of the part to be measured, and h represents the height of the standard block corresponding to the part to be measured.
[0037] Optionally, obtaining an initial scale factor corresponding to the part to be tested includes:
[0038] Acquire a standard block image corresponding to the standard block corresponding to the part to be tested;
[0039] Extracting the size feature of the actual size of the standard block according to the standard block image;
[0040] Determining a pixel size corresponding to the size feature;
[0041] A ratio of the pixel size to the actual size is determined, and the ratio is determined as the initial scale factor.
[0042] Optionally, the part to be tested is an annular part with a circular cross-sectional shape.
[0043] In addition, to achieve the above-mentioned purpose, the present disclosure also provides a part measuring device, the part measuring device comprising:
[0044] An acquisition module, used for acquiring a part image, wherein the part image includes a part to be tested;
[0045] An acquisition module, used for acquiring an initial scale factor corresponding to the part to be tested;
[0046] A determination module, used for determining a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor;
[0047] The measuring module is used to measure the part to be measured based on the target scale factor.
[0048] In addition, to achieve the above objectives, the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and a processor executes the computer program to implement the above method.
[0049] In addition, to achieve the above-mentioned purpose, the present disclosure also provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-mentioned method.
[0050] In addition, to achieve the above objectives, the present disclosure also provides a computer program product, which implements the above method when executed by a processor.
[0051] The part measurement method, device, storage medium and electronic device proposed in the embodiments of the present disclosure. First, a part image containing a part to be measured is collected, and an initial scale factor corresponding to the part to be measured is obtained. Then, based on the part image and the initial scale factor, a target scale factor corresponding to the part to be measured is determined. Finally, based on the target scale factor, part measurement is performed on the part to be measured. In this way, without relying on traditional measuring tools, the target scale factor corresponding to the part to be measured can be determined directly based on a known part image containing real part features and an existing initial scale factor, and then part measurement is further performed on the part to be measured based on the calculated target scale factor. In this way, even if the target feature changes, the new actual size can be quickly obtained by recalculating the target scale factor, without having to repeat the tedious measurement process, and the actual size of the part to be measured can be quickly and accurately obtained, which greatly improves the efficiency and accuracy of part measurement, especially improves the measurement efficiency and measurement accuracy of special parts such as annular parts with circular cross-sections. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.
[0053] Figure 1 A schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present disclosure;
[0054] Figure 2 A schematic diagram of a process flow of a part measurement method according to an embodiment of the present disclosure;
[0055] Figure 3 A schematic diagram of an optical path between the optical center of a camera and a center cross section of a component involved in an embodiment of the present disclosure;
[0056] Figure 4 A schematic diagram of the relationship between the height of a ring-shaped part and a standard block under a camera viewing angle involved in an embodiment of the present disclosure;
[0057] Figure 5 The present invention is a structural block diagram of a part measuring device involved in an embodiment of the present disclosure.
[0058] The purpose, features and advantages of the present invention will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0060] Reference Figure 1 , Figure 1 The figure is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present disclosure.
[0061] Generally, the device includes: at least one processor 301 , a memory 302 , and a part measurement program stored in the memory 302 and executable on the processor 301 , wherein the part measurement program is configured to implement the steps of the part measurement method as described above.
[0062] The processor 301 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 301 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 301 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 301 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. The processor 301 may also include an AI (Artificial Intelligence) processor, which is used to process operations related to the part measurement method, so that the part measurement method model can be trained and learned autonomously to improve efficiency and accuracy.
[0063] The memory 302 may include one or more storage media, which may be non-transitory. The memory 302 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory storage medium in the memory 302 is used to store at least one instruction, which is used to be executed by the processor 301 to implement the part measurement method provided in the method embodiment of the present disclosure.
[0064] In some embodiments, the terminal may further optionally include: a communication interface 303 and at least one peripheral device. The processor 301, the memory 302 and the communication interface 303 may be connected via a bus or a signal line. Each peripheral device may be connected to the communication interface 303 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 304, a display screen 305 and a power supply 306.
[0065] The communication interface 303 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 301 and the memory 302. In some embodiments, the processor 301, the memory 302, and the communication interface 303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 301, the memory 302, and the communication interface 303 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0066] The radio frequency circuit 304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 304 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 304 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 304 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 304 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 304 may also include circuits related to NFC (Near Field Communication), which is not limited in the present disclosure.
[0067] The display screen 305 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 305 is a touch display screen, the display screen 305 also has the ability to collect touch signals on the surface or above the surface of the display screen 305. The touch signal can be input to the processor 301 as a control signal for processing. At this time, the display screen 305 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 305 can be one, the front panel of the electronic device; in other embodiments, the display screen 305 can be at least two, respectively arranged on different surfaces of the electronic device or in a folding design; in some embodiments, the display screen 305 can be a flexible display screen, arranged on a curved surface or a folding surface of the electronic device. Even, the display screen 305 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 305 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).
[0068] The power supply 306 is used to power various components in the electronic device. The power supply 306 can be AC power, DC power, a disposable battery, or a rechargeable battery. When the power supply 306 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology. Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation of the device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0069] In addition, the embodiment of the present disclosure further proposes a storage medium, on which a part measurement program is stored, and when the part measurement program is executed by a processor, the steps of the part measurement method described above are implemented. Therefore, it will not be described in detail here. In addition, the description of the beneficial effects of adopting the same method will not be described in detail. For technical details not disclosed in the storage medium embodiment involved in the present disclosure, please refer to the description of the method embodiment of the present disclosure. As an example, the program instructions can be deployed to be executed on one device, or on multiple devices located at one location, or on multiple devices distributed at multiple locations and interconnected by a communication network.
[0070] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the above-mentioned program can be stored in a storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the above-mentioned storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0071] In the related art, the proportional factor is calculated by the relationship between the height position of the known proportional factor and the height of the target feature, which usually requires the use of additional auxiliary components (such as laser displacement sensors, etc.) to measure the height of the target feature. This method has achieved good results when dealing with parts with parallel upper and lower surfaces, by measuring the height of the parts to calculate the proportional factor. However, when facing some special parts, especially annular parts with circular cross-sections, it is difficult to accurately obtain the height at the maximum cross-section, which greatly reduces the accuracy and efficiency of this method.
[0072] Therefore, for circular cross-section annular parts, we urgently need a more optimized and efficient proportional factor calculation method to greatly improve the measurement accuracy and efficiency and meet the strict requirements of modern industrial production.
[0073] In view of this, the present disclosure proposes a part measurement method, device, storage medium and electronic device to solve the technical problems of low part measurement accuracy and poor efficiency in the related art.
[0074] Reference Figure 2 , Figure 2 The present invention is a schematic flow chart of a method for measuring a part according to an embodiment of the present invention, comprising the following steps:
[0075] Step S11: Acquire a part image, where the part image includes the part to be tested.
[0076] Step S12: Obtaining the initial scale factor corresponding to the part to be tested.
[0077] Step S13: Determine the target scale factor corresponding to the part to be tested according to the part image and the initial scale factor.
[0078] Step S14: Based on the target scale factor, measure the part to be measured.
[0079] For example, the part to be tested can be placed on the acquisition platform, and the industrial camera can be controlled to acquire images, or the part image stored in a local file or a cloud file can be directly read, and the embodiments of the present disclosure do not specifically limit this. After the part image is acquired, the acquired part image can be pre-processed by graying, filtering and denoising, so that the contour features of the part to be tested can be extracted through subsequent operations such as threshold segmentation and edge feature extraction.
[0080] It should also be understood that the part measurement performed on the part to be measured in the present disclosure may include linear dimension measurement, angular dimension measurement, and diameter dimension measurement of the part to be measured, and may also include auxiliary measurement operations for wall thickness calibration, roundness calibration, parallelism calibration, and verticality calibration for annular parts with a circular cross-section. The present disclosure does not specifically limit this.
[0081] Through the above technical solution, firstly, a part image containing the part to be measured is collected, and the initial scale factor corresponding to the part to be measured is obtained, then the target scale factor corresponding to the part to be measured is determined based on the part image and the initial scale factor, and finally the part to be measured is measured based on the target scale factor. In this way, without relying on traditional measuring tools, the target scale factor corresponding to the part to be measured can be determined directly based on the known part image containing the real part features and the existing initial scale factor, and then the part to be measured is further measured based on the calculated target scale factor. In this way, even if the target feature changes, the new actual size can be quickly obtained by recalculating the target scale factor, without having to repeat the tedious measurement process, and the actual size of the part to be measured can be quickly and accurately obtained, which greatly improves the efficiency and accuracy of part measurement, especially improves the measurement efficiency and measurement accuracy of special parts such as annular parts with circular cross-sections.
[0082] Possible ways to obtain the initial scale factor corresponding to the part to be tested include:
[0083] Obtain a standard block image corresponding to a standard block corresponding to the part to be tested;
[0084] According to the standard block image, the size feature of the actual size of the standard block is extracted;
[0085] Determine the pixel size corresponding to the size feature;
[0086] The ratio of the pixel size to the actual size is determined and the ratio is determined as an initial scale factor.
[0087] For example, the prepared standard block can be placed on the acquisition platform of the visual system, and then the industrial camera can be controlled to perform image acquisition to obtain a standard block image corresponding to the standard block. Then, based on the standard block image, the size feature of the known actual size is extracted, and the pixel size corresponding to the size feature is determined, and then the ratio of the pixel size to the actual size is determined as the scale factor corresponding to the height of the standard block, that is, the initial scale factor corresponding to the part to be measured. Of course, other methods can also be used to determine the initial scale factor, and the target scale factor can be determined based on the initial scale factor and the part image, which is not limited in the embodiments of the present disclosure.
[0088] For example, the embodiment of the present disclosure does not specifically limit the outline shape of the standard block. The standard block may not have a fixed outline shape, and may be a square, a circle, a polygon or other irregular shapes. And the standard block has the following properties:
[0089] (1) Parallel upper and lower surfaces: The upper and lower surfaces of the standard block are kept parallel to ensure stable support and reference during measurement, positioning or calibration.
[0090] (2) Have a certain hardness: The standard block has sufficient hardness to resist the wear and deformation that may occur during normal use.
[0091] (3) Anti-deformation properties: The standard block has good anti-deformation properties, so that the shape and size of the standard block should remain unchanged even when subjected to external forces.
[0092] In a possible manner, the part to be tested is an annular part with a circular cross-sectional shape. Of course, the part to be tested may also be a part of other shapes, which is not limited in the embodiment of the present disclosure.
[0093] In possible ways, according to the part image and the initial scale factor, a target scale factor corresponding to the part to be tested is determined, including:
[0094] Determine a first part height of the part to be measured according to the part image and the initial scale factor;
[0095] Calculate a first proportional factor corresponding to the first part height according to the first part height and the initial proportional factor;
[0096] Determining whether the first scale factor satisfies a preset condition;
[0097] When the first scale factor meets a preset condition, the first scale factor is determined as a target scale factor.
[0098] For example, the preset condition may be that the difference between the first scale factor and the initial scale factor is greater than a preset value, and when the difference between the first scale factor and the initial scale factor is greater than the preset value, it is determined that the first scale factor meets the preset condition. The preset value θ may be determined according to the accuracy requirements and hardware parameters of the measurement system, and may be adjusted according to the requirements, and may be specifically determined according to the calculation formula:
[0099]
[0100] Among them, P is the system measurement accuracy, and Q is the number of pixels on one side of the camera field of view corresponding to the part image.
[0101] In a possible manner, when the first scale factor does not meet a preset condition, the method further includes:
[0102] Determine a second part height of the part to be measured according to the part image and the first scale factor;
[0103] Calculate a second proportional factor corresponding to the height of the second part according to the height of the second part and the first proportional factor;
[0104] Determining whether the second scale factor meets a preset condition;
[0105] When the second scale factor meets a preset condition, the second scale factor is determined as a target scale factor.
[0106] For example, when the second proportional factor does not meet the preset condition, the method may further include:
[0107] Determine a third part height of the part to be measured according to the part image and the second scale factor;
[0108] According to the third part height and the second proportional factor, a third proportional factor corresponding to the third part height is calculated;
[0109] Determining whether the third scale factor meets a preset condition;
[0110] When the third scale factor meets a preset condition, the third scale factor is determined as a target scale factor.
[0111] It should be noted that, when the third scale factor does not meet the preset conditions, the above method can be continued to be used to further calculate the fourth scale factor according to the part image and the third scale factor. If the fourth scale factor does not meet the preset conditions, the calculation is performed in this way until the calculated new scale factor meets the preset conditions, and the last obtained scale factor is determined as the target scale factor.
[0112] In a possible manner, determining a first part height of the part to be measured according to the part image and the initial scale factor includes:
[0113] Extract part contour points of the part to be tested based on the part image;
[0114] According to the contour points of the parts, multiple target points of the parts to be tested are determined;
[0115] A first part height is calculated based on the multiple target points and the initial scale factor.
[0116] For example, the part contour points of the part to be measured refer to the points that define the outer boundary of the part to be measured. They can be determined by edge detection algorithms (such as Canny edge detection) or contour extraction algorithms (such as findContours function in OpenCV). Therefore, the contour features of the part to be measured can be extracted according to the part image, and the part contour points of the part to be measured can be determined according to the contour features, and then multiple target points of the part to be measured can be determined according to the part contour points.
[0117] In a possible manner, multiple target points of the part to be measured are determined according to the part contour points, including:
[0118] Perform fitting calculation based on the part contour points to determine the part center point to be measured;
[0119] According to the image size of the part image, determine the intersection point between the camera optical axis and the image plane corresponding to the part image;
[0120] Based on the center point of the part and the intersection of the camera optical axis and the image plane, a mask is made to obtain a mask image of the part to be tested;
[0121] A mask screening calculation is performed based on the mask image to determine a plurality of target points.
[0122] It should be understood that the camera optical axis is the line from the center of the camera lens to the center of the image sensor, and usually represents the direction of the camera's line of sight. The image plane is the plane where the camera image sensor is located, that is, where the image is captured. When the camera optical axis intersects the image plane, they will have an intersection point, which is usually called the principal point or optical center of the image, such as Figure 3 As shown. The center point of the part refers to the geometric center point of the part to be measured, which can be determined according to the shape, size or some algorithm of the part. Therefore, a straight line passing through the intersection and the center point of the part can be determined. In the present disclosure, among the multiple part contour points, the multiple part contour points closest to the straight line can be determined as the target points.
[0123] For example, the least square method can be used to fit multiple part contour points to determine the part center point O. The width W and height H of the part image are read by the algorithm, and the intersection point M of the camera optical axis and the image plane is determined according to the width W and height H, where the coordinates of the intersection point M are:
[0124]
[0125] Then, a new image with a width of W, a height of H, and a grayscale of 0 is created. In this image, a ray L1 with a grayscale of 255 is drawn in the direction of the intersection point M with the center point O of the part as the starting coordinate, and a ray L2 with a grayscale of 255 is drawn in the direction of the center point O of the part with the intersection point M as the starting coordinate. Then, a dilation operation is performed on the image, and the image obtained by the dilation operation is the mask image of the part to be tested. The number of iterations can be determined according to the situation of the contour points, and can be 2 times in the present disclosure.
[0126] Finally, the mathematical expression of the straight line MO is derived and calculated based on the mask image. Through mask screening calculation, the four part contour points closest to the straight line MO in the ROI area (Region of Interest) are determined as target points, which can be recorded as point A, point B, point C, and point D.
[0127] For example, the distance from each part contour point to the straight line MO can be determined first, and then the multiple part contour points are sorted according to the obtained distance values, and the four part contour points with smaller distance values are determined as target points. Of course, the four part contour points with less than the preset distance value can also be determined as target points. The preset distance value can be determined according to the standard block. The embodiment of the present disclosure does not specifically limit the method for determining the target point.
[0128] In a possible manner, the first part height is calculated according to the plurality of target points and the initial scale factor, including:
[0129] Determine, according to the initial scale factor, a distance value set consisting of a distance between an intersection point of the camera optical axis and the image plane and each of the plurality of target points;
[0130] The first part height is obtained by calculating according to the distance value set and the camera working distance corresponding to the part image.
[0131] For example, according to the initial scale factor, the distance between the intersection point M and point A, the distance between the intersection point M and point B, the distance between the intersection point M and point C, and the distance between the intersection point M and point D are calculated, which can be recorded as MA, MB, MC, and MD respectively. Then, the first part height is calculated according to the following calculation formula:
[0132]
[0133] Wherein, d represents the height of the first part, and H represents the camera working distance corresponding to the part image.
[0134] For example, Figure 4Schematic diagram of the relationship between the height of the part to be tested and the height of the standard block under the camera viewing angle involved in the embodiment of the present disclosure. Figure 4 As shown, d represents the first part height of the part to be measured, h represents the height of the standard block, and H represents the camera working distance corresponding to the part image.
[0135] In a possible manner, calculating a first proportional factor corresponding to the first part height according to the first part height and the initial proportional factor includes:
[0136] The first proportional factor is calculated by the following relationship:
[0137]
[0138] Wherein, s1 represents the first scale factor, S represents the initial scale factor, H represents the camera working distance corresponding to the part image, d1 represents the first part height of the part to be measured, and h represents the height of the standard block corresponding to the part to be measured.
[0139] For example, the second proportional factor can be calculated according to the following relationship:
[0140]
[0141] Wherein, s2 represents the second scale factor, s1 represents the first scale factor, H represents the camera working distance corresponding to the part image, d2 represents the second part height of the part to be measured, and h represents the height of the standard block corresponding to the part to be measured.
[0142] Reference Figure 5 , Figure 5 This is a structural block diagram of a part measuring device involved in an embodiment of the present disclosure. Based on the same inventive concept as the above embodiment, the device includes:
[0143] The acquisition module 10 is used to acquire a part image, wherein the part image includes a part to be tested;
[0144] An acquisition module 20 is used to acquire an initial scale factor corresponding to the part to be tested;
[0145] A determination module 30, configured to determine a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor;
[0146] The measuring module 40 is used to measure the part to be measured based on the target scale factor.
[0147] Optionally, the determining module 30 is used to:
[0148] Determining a first part height of the part to be measured according to the part image and the initial scale factor;
[0149] Calculating a first proportional factor corresponding to the first part height according to the first part height and the initial proportional factor;
[0150] Determining whether the first scale factor meets a preset condition;
[0151] When the first scale factor meets a preset condition, the first scale factor is determined as the target scale factor.
[0152] Optionally, the determining module 30 is further configured to:
[0153] When the first scale factor does not satisfy a preset condition, determining a second part height of the part to be measured according to the part image and the first scale factor;
[0154] Calculating a second proportional factor corresponding to the second part height according to the second part height and the first proportional factor;
[0155] Determining whether the second scale factor meets the preset condition;
[0156] When the second scale factor meets a preset condition, the second scale factor is determined as the target scale factor.
[0157] Optionally, the determining module 30 is used to:
[0158] Based on the part image, extracting part contour points of the part to be tested;
[0159] Determine a plurality of target points of the part to be measured according to the part contour points;
[0160] The first part height is calculated based on the multiple target points and the initial scale factor.
[0161] Optionally, the determining module 30 is used to:
[0162] Performing a fitting calculation based on the part contour points to determine the part center point of the part to be measured;
[0163] Determine the intersection of the camera optical axis and the image plane corresponding to the part image according to the image size of the part image;
[0164] Based on the center point of the part and the intersection point of the camera optical axis and the image plane, a mask is produced to obtain a mask image of the part to be tested;
[0165] A mask screening calculation is performed based on the mask image to determine the plurality of target points.
[0166] Optionally, the determining module 30 is used to:
[0167] Determine, according to the initial scale factor, a distance value set consisting of a distance between an intersection point of the camera optical axis and the image plane and each of the multiple target points;
[0168] The first part height is obtained by calculating according to the distance value set and the camera working distance corresponding to the part image.
[0169] Optionally, the first proportional factor is obtained by calculating through the following relationship: The first proportional factor is obtained by calculating through the following relationship:
[0170]
[0171] Among them, s1 represents the first scale factor, S represents the initial scale factor, H represents the camera working distance corresponding to the part image, d1 represents the first part height of the part to be measured, and h represents the height of the standard block corresponding to the part to be measured.
[0172] Optionally, obtaining an initial scale factor corresponding to the part to be tested includes:
[0173] Acquire a standard block image corresponding to the standard block corresponding to the part to be tested;
[0174] Extracting the size feature of the actual size of the standard block according to the standard block image;
[0175] Determining a pixel size corresponding to the size feature;
[0176] A ratio of the pixel size to the actual size is determined, and the ratio is determined as the initial scale factor.
[0177] Optionally, the part to be tested is an annular part with a circular cross-sectional shape.
[0178] It should be noted that, since the steps executed by the device of this embodiment are the same as the steps of the aforementioned method embodiment, its specific implementation method and the technical effects that can be achieved can refer to the aforementioned embodiment and will not be repeated here.
[0179] In addition, in one embodiment, an embodiment of the present disclosure further provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory, and the computer program implements the steps of the method in the aforementioned embodiment when executed by the processor.
[0180] In addition, in one embodiment, an embodiment of the present disclosure further provides a computer storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method in the aforementioned embodiment are implemented.
[0181] In some embodiments, the computer readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or various devices including one or any combination of the above memories. The computer may be various computing devices including intelligent terminals and servers.
[0182] In some embodiments, executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0183] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0184] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0185] It should be noted that, in this article, the terms "include", "may include" or any other variations thereof are intended to cover non-exclusive inclusions, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0186] The serial numbers of the above-mentioned embodiments of the present disclosure are only for description and do not represent the advantages or disadvantages of the embodiments.
[0187] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a multimedia terminal device (which can be a mobile phone, a computer, a television receiver, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0188] The above descriptions are only optional embodiments of the present disclosure, and are not intended to limit the patent scope of the present disclosure. All equivalent structural transformations made using the contents of the present disclosure and the drawings under the inventive concept of the present disclosure, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present disclosure.
Claims
1. A part measurement method, characterized in that: include: Acquire a part image, wherein the part image includes a part to be tested; Obtaining an initial scale factor corresponding to the part to be tested; Determining a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor; Based on the target scale factor, part measurement is performed on the part to be measured.
2. The method according to claim 1, characterized in that: Determining a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor includes: Determining a first part height of the part to be measured according to the part image and the initial scale factor; Calculating a first proportional factor corresponding to the first part height according to the first part height and the initial proportional factor; Determining whether the first scale factor meets a preset condition; When the first scale factor meets a preset condition, the first scale factor is determined as the target scale factor.
3. The method according to claim 2, characterized in that When the first proportional factor does not meet the preset condition, the method further includes: Determining a second part height of the part to be measured according to the part image and the first scale factor; Calculating a second proportional factor corresponding to the second part height according to the second part height and the first proportional factor; Determining whether the second scale factor meets the preset condition; When the second scale factor meets a preset condition, the second scale factor is determined as the target scale factor.
4. The method according to claim 2, characterized in that: Determining a first part height of the part to be measured according to the part image and the initial scale factor includes: Based on the part image, extracting part contour points of the part to be tested; Determine a plurality of target points of the part to be measured according to the part contour points; The first part height is calculated based on the multiple target points and the initial scale factor.
5. The method according to claim 4, characterized in that Determining a plurality of target points of the part to be measured according to the part contour points comprises: Performing a fitting calculation based on the part contour points to determine the part center point of the part to be measured; Determine the intersection of the camera optical axis and the image plane corresponding to the part image according to the image size of the part image; Based on the center point of the part and the intersection point of the camera optical axis and the image plane, a mask is produced to obtain a mask image of the part to be tested; A mask screening calculation is performed based on the mask image to determine the plurality of target points.
6. The method according to claim 5, characterized in that The step of calculating the first part height according to the plurality of target points and the initial scale factor comprises: Determine, according to the initial scale factor, a distance value set consisting of a distance between an intersection point of the camera optical axis and the image plane and each of the multiple target points; The first part height is obtained by calculating according to the distance value set and the camera working distance corresponding to the part image.
7. The method according to claim 2, characterized in that The step of calculating a first proportional factor corresponding to the first part height according to the first part height and the initial proportional factor includes: The first proportional factor is calculated by the following relationship: Among them, s1 represents the first scale factor, S represents the initial scale factor, H represents the camera working distance corresponding to the part image, d1 represents the first part height of the part to be measured, and h represents the height of the standard block corresponding to the part to be measured.
8. The method according to claim 1, characterized in that The obtaining of the initial scale factor corresponding to the part to be tested includes: Acquire a standard block image corresponding to the standard block corresponding to the part to be tested; Extracting the size feature of the actual size of the standard block according to the standard block image; Determining a pixel size corresponding to the size feature; A ratio of the pixel size to the actual size is determined, and the ratio is determined as the initial scale factor.
9. The method according to any one of claims 1 to 8, characterized in that: The part to be tested is an annular part with a circular cross-section.
10. A parts measuring device, characterized in that: include: An acquisition module, used for acquiring a part image, wherein the part image includes a part to be tested; An acquisition module, used for acquiring an initial scale factor corresponding to the part to be tested; A determination module, used for determining a target scale factor corresponding to the part to be measured according to the part image and the initial scale factor; The measuring module is used to measure the part to be measured based on the target scale factor.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the processor executes the computer program to implement the method according to any one of claims 1 to 9.
12. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method according to any one of claims 1 to 9.
