Measurement line fitting method and apparatus, and device and computer-readable storage medium
By employing edge detection and outlier removal methods, combined with preset caliper screening, the problem of insufficient measurement line fitting accuracy in existing technologies has been solved, achieving higher accuracy and robustness in measurement line fitting.
Patent Information
- Application Number
- PCT/CN2024/123436
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-28
- Filing Date
- 2024-10-08
- Publication Date
- 2026-01-02
AI Technical Summary
Existing measurement line fitting methods have low robustness, resulting in insufficient measurement line fitting accuracy for high-precision detection requirements.
Edge detection is performed on the acquired raw image to determine edge points, establish edge standard lines, remove outliers, and use preset calipers to screen measurement points. Multiple outlier screenings are performed, and finally, straight line fitting is performed to improve the accuracy of the measurement line.
This improves the fitting accuracy and robustness of the measurement line, ensuring high-precision measurement line fitting results.
Smart Images

Figure CN2024123436_02012026_PF_FP_ABST
Abstract
Description
Fitting method and device of measurement line, equipment and computer readable storage medium
[0001] Cross-reference to related applications
[0002] The present disclosure is based on the Chinese patent application No. 202410865273.6, filed on June 28, 2024, entitled "Fitting method and device of measurement line, equipment and computer readable storage medium", and claims priority to the Chinese patent application, the whole content of which is incorporated herein by reference. TECHNICAL FIELD
[0003] The present disclosure relates to the field of computer vision, and particularly relates to a fitting method and device of measurement line, equipment and computer readable storage medium. BACKGROUND
[0004] In image sensor vision detection, whether in the field of 3C, the field of semiconductor or the field of new energy, the extraction and fitting of straight line is a necessary and particularly important link, especially in positioning and measurement, which often has a high requirement for precision.
[0005] At present, common fitting methods for measurement line include Hough transform straight line extraction, one-dimensional straight line caliper and two-dimensional straight line caliper. However, the robustness is relatively low, and there is a certain overkill and loss of precision for the high-precision detection requirement, thereby leading to low fitting precision of the measurement line.
[0006] SUMMARY
[0007] Embodiments of the present disclosure aim to provide a fitting method and device of measurement line, equipment and computer readable storage medium, which can improve the fitting precision of the measurement line.
[0008] The technical solution of the present disclosure is implemented as follows:
[0009] Edge detection is performed on the foreground image in the obtained original image to determine at least two edge points;
[0010] Based on the at least two edge points, an edge standard line of the foreground image is determined;
[0011] Based on the edge standard line and a preset caliper, abnormal points of the foreground image are removed to determine a first fitting point;
[0012] Straight line fitting is performed through the first fitting point to determine a measurement line for the foreground image.
[0013] It can be understood that the server performs edge detection on the foreground image in the obtained original image to determine at least two edge points. Based on the at least two edge points, an edge standard line of the foreground image is determined; based on the edge standard line and a preset caliper, the foreground image is subjected to outlier removal to determine a first fitting point. A straight line fitting is performed through the first fitting point to determine a measurement line for the foreground image. In this process, the points are disturbed by outliers in the process of fitting a straight line. Therefore, by establishing the edge standard line, the measurement points of the foreground image are subjected to outlier removal, which can reduce the influence of outliers on the straight line fitting, thereby improving the fitting accuracy of the measurement line for the foreground image.
[0014] In the above scheme, based on the edge standard line and the preset caliper, the foreground image is subjected to outlier removal to determine the first fitting point, including:
[0015] The foreground image is measured by calling the preset caliper to obtain a plurality of measurement points.
[0016] Based on the edge standard line, the plurality of measurement points are subjected to outlier removal to determine the first fitting point.
[0017] It can be understood that the server measures the foreground image by calling the preset caliper to obtain a plurality of measurement points, and then removes outliers from the plurality of measurement points through the edge standard line to determine the first fitting point, which can reduce the influence of outliers on the straight line fitting, thereby improving the fitting accuracy of the measurement line.
[0018] In the above scheme, after determining the first fitting point based on the edge standard line and the plurality of measurement points, the method further includes:
[0019] The first fitting point is screened according to a preset screening range to remove outliers to determine a second fitting point in the foreground image.
[0020] A straight line fitting is performed through the second fitting point to determine a measurement line for the foreground image.
[0021] It can be understood that the server screens the first fitting point according to a preset screening range to remove outliers to determine a second fitting point in the foreground image, which is subjected to secondary outlier screening, thereby making the second fitting point have higher accuracy. The straight line fitting is performed on the foreground image through the second fitting point to determine a measurement line for the foreground image, which has higher accuracy, and the overall robustness of the fitting algorithm is also improved.
[0022] In the above scheme, based on the edge standard line, the plurality of measurement points are subjected to outlier removal to determine the first fitting point, including:
[0023] Based on the edge standard line, a plurality of first distances between the plurality of measurement points are determined.
[0024] The server determines a plurality of first distances between the plurality of measurement points and the edge standard line, removes abnormal points from the plurality of measurement points by the preset distance and the plurality of first distances, and determines the first fitting points.
[0025] It can be understood that the server determines a plurality of first distances between the plurality of measurement points and the edge standard line, removes abnormal points from the plurality of measurement points by the preset distance and the plurality of first distances, and determines the first fitting points, which can filter out abnormal points, reduce the influence of abnormal points on linear fitting, and thus improve the fitting accuracy of the measurement line.
[0026] In the above scheme, the first fitting points are screened according to a preset screening range, abnormal points are removed, and the second fitting points in the foreground image are determined, including:
[0027] The first fitting points are screened along the first direction by the preset screening range, abnormal points outside the preset screening range are removed, and the second fitting points in the foreground image are determined; the first direction represents a dimension direction in the two-dimensional coordinates.
[0028] It can be understood that the server screens the first fitting points along the first direction by the preset screening range, removes abnormal points outside the preset screening range, and determines the second fitting points in the foreground image, so that the second fitting points have higher accuracy through secondary abnormal point screening of the measurement points.
[0029] In the above scheme, the foreground image in the obtained original image is edge detected to determine at least two edge points of the foreground image, including:
[0030] The original image is subjected to gray projection processing to determine the foreground image and the at least two edge points of the foreground image.
[0031] It can be understood that the server subjects the original image to gray projection processing to determine the foreground image and the at least two edge points of the foreground image, which can facilitate determination of the edge standard line through the at least two edge points.
[0032] In the above scheme, the original image is subjected to gray projection processing to determine the foreground image and the at least two edge points of the foreground image, including:
[0033] The obtained original image is cropped to determine a first image containing a foreground object.
[0034] The first image is subjected to gray projection processing to determine the foreground image and the at least two edge points of the foreground image.
[0035] It can be understood that the server crops the obtained original image to determine a first image containing the foreground object, performs a gray projection processing based on the first image to determine a foreground image and at least two edge points of the foreground image. Since the first image is smaller than the original image, the calculation on invalid regions can be reduced, thereby improving the fitting accuracy of the measurement line.
[0036] In the above scheme, the gray projection processing based on the first image to determine the foreground image and the at least two edge points of the foreground image comprises:
[0037] The first image is subjected to image enhancement superposition processing according to a cycle number to obtain a first enhanced image.
[0038] The first enhanced image is subjected to at least one gray scale operation to obtain the foreground image; wherein the at least one gray scale operation comprises a gray scale opening operation, a gray scale closing operation, a gray scale opening-closing operation and a gray scale closing-opening operation.
[0039] The foreground image is subjected to gray scale calculation along a second direction to determine the at least two edge points; the second direction is different from the first direction.
[0040] It can be understood that the server subjects the first image to image enhancement superposition processing according to a cycle number to obtain a first enhanced image, and subjects the first enhanced image to at least one gray scale operation to obtain the foreground image. Through the cyclic image enhancement processing and the gray scale processing on the first image, the definition of the image can be improved. The foreground image is subjected to gray scale calculation along a second direction to determine the at least two edge points, which facilitates subsequent determination of the edge standard line and screening of abnormal points.
[0041] In the above scheme, the foreground image is subjected to gray scale calculation along a second direction to determine the at least two edge points, comprising:
[0042] The foreground image is subjected to region division along the second direction to obtain at least two region images.
[0043] The at least two region images are subjected to gray scale calculation respectively to obtain extreme points corresponding to the at least two region images respectively.
[0044] The at least two edge points are determined based on the extreme points corresponding to the at least two region images respectively.
[0045] It can be understood that the server subjects the foreground image to region division along a second direction to obtain at least two region images, subjects the at least two region images to gray scale calculation respectively to obtain extreme points corresponding to the at least two region images respectively, and determines the at least two edge points based on the extreme points corresponding to the at least two region images respectively, thereby facilitating subsequent determination of the edge standard line and screening of abnormal points, and further improving the fitting accuracy of the measurement line.
[0046] In the above scheme, the gray scale of at least two region images is calculated respectively to obtain the extreme points corresponding to the at least two region images respectively, comprising:
[0047] For each region image, the unit gray scale mean in the second direction is calculated to determine the total gray scale mean of each region image; wherein the unit gray scale mean represents the gray scale mean in the corresponding dimension of the first direction;
[0048] Based on the total gray scale mean of each region image, the extreme points corresponding to each region image are determined by establishing a discrete function and performing smoothing processing and derivative processing respectively.
[0049] It can be understood that the server determines the extreme points corresponding to each region image for each region image, which facilitates the determination of at least two edge points, thereby facilitating the subsequent determination of the edge standard line and the screening of abnormal points, and further improving the fitting accuracy of the measurement line.
[0050] In the above scheme, for the first image, image enhancement superposition processing is performed according to the number of cycles to obtain a first enhanced image, comprising:
[0051] The first gray scale value and the second gray scale value of the first image in different directions are determined;
[0052] The first gray scale value and the second gray scale value are multiplied to determine the gray scale value of the initial enhanced image;
[0053] Based on the gray scale value of the initial enhanced image, image enhancement superposition processing is continued until the number of cycles is reached to determine the first enhanced image.
[0054] It can be understood that the server determines the first gray scale value and the second gray scale value of the first image in different directions; and multiplies the first gray scale value and the second gray scale value to determine the gray scale value of the initial enhanced image.
[0055] Based on the gray scale value of the initial enhanced image, image enhancement superposition processing is continued until the number of cycles is reached to determine the first enhanced image. In this process, the image is processed in a for loop manner, which can keep the Mult value unchanged, set the number of cycles, and perform superposition processing on the value. In addition, for example, when the image enhancement coefficient Mult value increases from 0.1 to 0.2, the result shows that the coefficient grows, and the span is large, which is easy to exceed the expected effect. This method can be proportional growth and coefficient growth.
[0056] In the above scheme, the method further comprises:
[0057] The first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image are determined;
[0058] Based on the first position information and the second position information, a rotation angle and a translation distance are calculated to determine the position transformation relationship.
[0059] It can be understood that the server determines the first position information of the original image corresponding to the first point and the second position information of the first image corresponding to the second point; by the first position information and the second position information, a rotation angle and a translation distance are calculated to determine the position transformation relationship, which facilitates subsequent transformation of the fitting image of the foreground image into a measurement line for the foreground image in the original image through the position transformation relationship.
[0060] In the above scheme, based on the first position information and the second position information, a rotation angle and a translation distance are calculated to determine the position transformation relationship, comprising:
[0061] Based on the first position information and the second position information, a rotation angle is calculated to determine a rotation matrix;
[0062] Based on the first position information and the second position information, a translation distance is calculated to determine a translation vector;
[0063] The rotation matrix and the translation vector are multiplied to determine the position transformation relationship.
[0064] It can be understood that the server can calculate a rotation angle based on the first position information and the second position information to determine a rotation matrix; calculate a translation distance based on the first position information and the second position information to determine a translation vector; multiply the rotation matrix and the translation vector to determine the position transformation relationship, and establish the position transformation relationship between the first image and the original image, which facilitates subsequent conversion of the fitting image of the foreground image into a measurement line for the foreground image in the original image.
[0065] In the above scheme, the straight line fitting is performed through the first fitting point to determine the measurement line for the foreground image, comprising:
[0066] The straight line fitting is performed on the foreground image through the first fitting point to determine the fitting image of the foreground image;
[0067] The fitting image of the foreground image is transformed in position information through the position transformation relationship to determine the measurement line.
[0068] It can be understood that the server determines the fitting image of the foreground image by performing linear fitting on the foreground image through the first fitting point; and determines the measurement line for the foreground image by performing position information transformation on the fitting image of the foreground image through the position transformation relationship. Since the first fitting point is the screened measurement point, the accuracy of the fitting image of the foreground image can be improved by performing linear fitting through the first fitting point. Meanwhile, since the foreground image is determined by cropping the original image, the foreground image is smaller than the original image, and a more accurate fitting image of the foreground image can be obtained by performing linear fitting on the foreground image. By performing coordinate transformation on the more accurate fitting image of the foreground image through the position transformation relationship between the original image and the foreground image, the measurement line for the foreground image in the original image is obtained. In this transformation process, the high accuracy of the fitting image of the foreground image is maintained, so that the measurement line for the foreground image in the original image also has high accuracy, thereby improving the fitting accuracy of the measurement line for the foreground image in the original image.
[0069] In the above scheme, the method further comprises:
[0070] The foreground image in the obtained original image is measured by calling the preset caliper to obtain a plurality of measurement points.
[0071] The plurality of measurement points are screened according to a preset screening range to remove abnormal points, and a third fitting point in the foreground image is determined.
[0072] Linear fitting is performed through the third fitting point to determine the measurement line for the foreground image.
[0073] It can be understood that the server screens the plurality of measurement points according to the preset screening range to remove abnormal points and determine the third fitting point in the foreground image, thereby performing secondary abnormal point screening, so that the third fitting point has higher accuracy. The measurement line for the foreground image is determined by performing linear fitting on the foreground image through the third fitting point, so that the measurement line for the foreground image has higher accuracy, and the overall robustness of the fitting algorithm can also be improved.
[0074] The disclosure embodiment provides a fitting device for a measurement line, which comprises a determination unit, a screening unit and a fitting unit, wherein,
[0075] The determination unit is configured to perform edge detection on the foreground image in the obtained original image to determine at least two edge points; and determine an edge standard line of the foreground image based on the at least two edge points.
[0076] The screening unit is configured to remove abnormal points from the foreground image based on the edge standard line and a preset caliper to determine a first fitting point.
[0077] The fitting unit is configured to perform linear fitting by the first fitting point to determine the measurement line for the foreground image.
[0078] The present disclosure provides a fitting device for a measurement line, comprising a processor and a memory, wherein,
[0079] The memory is configured to store a computer program.
[0080] The processor is configured to call and run the computer program from the memory to perform the fitting method for a measurement line.
[0081] The present disclosure provides a computer readable storage medium storing executable instructions for causing a processor to perform the fitting method for a measurement line.
[0082] The present disclosure provides a fitting method and device for a measurement line, equipment and a computer readable storage medium, the method comprising: performing edge detection on a foreground image in an acquired original image to determine at least two edge points; determining an edge standard line of the foreground image based on the at least two edge points; removing abnormal points from the foreground image based on the edge standard line and a preset caliper to determine a first fitting point; and performing linear fitting by the first fitting point to determine a measurement line for the foreground image. With the above scheme, since the points are disturbed by abnormal points during linear fitting, removing abnormal points from the measurement points of the foreground image by establishing an edge standard line can reduce the influence of abnormal points on linear fitting, thereby improving the fitting accuracy of the measurement line for the foreground image. BRIEF DESCRIPTION OF DRAWINGS
[0083] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and serve to explain the technical solutions of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor based on these drawings.
[0084] The flowchart shown in the accompanying drawings is only an exemplary illustration, and is not necessarily required to include all contents and operations / steps, nor is it necessarily required to be executed in the order described. For example, some operations / steps can be further decomposed, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to the actual situation.
[0085] FIG. 1 is an optional flowchart of a fitting method for a measurement line according to an embodiment of the present disclosure;
[0086] FIG. 2a is an optional edge standard line diagram of a fitting method for a measurement line according to an embodiment of the present disclosure;
[0087] Figure 2b is a schematic diagram of an optional fitting skew of a fitting method for a measurement line provided in an embodiment of this disclosure;
[0088] Figure 3 is a schematic diagram of an optional outlier point of a measurement line fitting method provided in an embodiment of this disclosure;
[0089] Figure 4 is a schematic diagram of a fitted image of an optional foreground image of a fitting method for a measurement line provided in an embodiment of this disclosure;
[0090] Figure 5 is a schematic diagram of an optional process for a method of fitting a measurement line according to an embodiment of this disclosure;
[0091] Figure 6 is a schematic diagram of an optional one-dimensional caliper fitting method for a measurement line provided in an embodiment of this disclosure;
[0092] Figure 7 is a schematic diagram of an optional process for a method of fitting a measurement line according to an embodiment of this disclosure;
[0093] Figure 8 is a schematic diagram of an optional process for a method of fitting a measurement line according to an embodiment of this disclosure;
[0094] Figure 9 is a schematic diagram of an optional process for a method of fitting a measurement line according to an embodiment of this disclosure;
[0095] Figure 10a is an optional vertical projection schematic diagram of a fitting method for a measurement line provided in an embodiment of this disclosure;
[0096] Figure 10b is a schematic diagram of an optional segmented projection of a fitting method for a measurement line provided in an embodiment of this disclosure;
[0097] Figure 10c is a schematic diagram of an optional discrete function of a fitting method for a measurement line provided in an embodiment of this disclosure;
[0098] Figure 10d is a schematic diagram of an optional discrete function smoothing method for fitting a measurement line according to an embodiment of this disclosure;
[0099] Figure 10e is a schematic diagram of an optional discrete function extremum point of a measurement line fitting method provided in an embodiment of this disclosure;
[0100] Figure 11 is a schematic diagram of an optional process for a method of fitting a measurement line according to an embodiment of this disclosure;
[0101] Figure 12 is a schematic diagram of the structure of a fitting device for a measurement line provided in an embodiment of this disclosure;
[0102] Figure 13 is a schematic diagram of the structure of a fitting device for a measurement line provided in an embodiment of this disclosure. DETAILED DESCRIPTION
[0103] In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will further describe the specific technical solutions of the present disclosure with reference to the drawings in the embodiments of the present disclosure. The following embodiments are used to illustrate the present disclosure, but not to limit the scope of the present disclosure.
[0104] Unless otherwise defined, all technical and scientific terms used in the present disclosure have the same meaning as commonly understood by one of ordinary skill in the art to which the present disclosure belongs. The terms used in the present disclosure are only for the purpose of describing the embodiments of the present disclosure, and are not intended to limit the present disclosure.
[0105] In the following description, the terms "some embodiments", "the embodiment", "embodiments of the present disclosure", and the like, describe a subset of all possible embodiments, but it can be understood that "some embodiments" can be the same subset or different subsets as each other, and can be combined with each other without conflict.
[0106] If the application file appears "first / second" similar description, the following description is added, in the following description, the terms "first\second\third" are only to distinguish similar objects, and do not represent the specific order of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence as allowed, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0107] FIG. 1 is an optional flow diagram of a fitting method of a measurement line according to an embodiment of the present disclosure. As shown in FIG. 1, the fitting method of the measurement line includes the following steps:
[0108] S101, edge detection is performed on the foreground image in the acquired original image to determine at least two edge points.
[0109] The fitting method of the measurement line provided by the embodiments of the present disclosure can be applied to the fitting of the measurement line of various objects, so as to be positioned and measured according to the determined measurement line, such as battery images, vehicle part images, and aircraft part images, etc., which are not limited by the embodiments of the present disclosure.
[0110] In the following embodiments, the object to which the fitting method of the measurement line is applied will be taken as an example of a battery image, which is an image containing battery components obtained through different production processes in the production process of a power battery.
[0111] In the embodiments of the present disclosure, the original image is directly obtained by photographing in the battery production process on the battery production line. The original image contains a battery component, and the original image is mainly used to determine whether the quality of the battery component in the image meets the standard based on the original image.
[0112] In some embodiments of the present disclosure, the fitting method of the measurement line is mainly applied to the fitting of the measurement line of the original image containing a battery component in the field of semiconductors or new energy.
[0113] In some embodiments of the present disclosure, the subject performing the fitting method of the measurement line is a fitting device of the measurement line. The fitting device of the measurement line can be a server. The embodiments of the present disclosure do not make specific limitations in this regard.
[0114] In some embodiments of the present disclosure, the server can perform image-related processing on the foreground image in the obtained original image to determine the foreground image and at least two edge points of the foreground image. The image-related processing can be binaryzation processing, erosion and expansion processing, and gray projection processing, etc. The embodiments of the present disclosure do not make specific limitations in this regard.
[0115] In the following embodiments, the gray projection processing on the foreground image in the obtained original image will be taken as an example for illustration.
[0116] In some embodiments of the present disclosure, the server can perform gray projection processing based on the original image to determine the foreground image and at least two edge points of the foreground image.
[0117] In some embodiments of the present disclosure, the server performs cropping on the obtained original image to determine a first image containing a foreground object, and performs gray projection processing based on the first image to determine the foreground image and at least two edge points of the foreground image.
[0118] In some embodiments of the present disclosure, the server performs cropping on the obtained original image to determine a first image. Since the area of the first image is smaller than that of the original image, it can be convenient for subsequent fitting of the measurement line of the image based on the first image.
[0119] It can be understood that the server performs cropping on the obtained original image to determine a first image containing a foreground object, and performs gray projection processing based on the first image to determine the foreground image and at least two edge points of the foreground image. Since the first image is smaller than the original image, the calculation of invalid areas can be reduced, thereby improving the fitting accuracy of the measurement line.
[0120] In some embodiments of the present disclosure, the edge point represents a boundary point of brightness change, which is a point in the foreground image obtained after the gray projection processing of the first image.
[0121] In some embodiments of the present disclosure, the server can perform a gray scale projection processing on the first image to obtain a foreground image. At least two edge points in the foreground image are determined by performing a gray scale calculation on the foreground image.
[0122] It should be noted that the at least two edge points can be used to determine the edge standard line.
[0123] In some embodiments of the present disclosure, the server can perform a preprocessing on the first image to determine a foreground image. At least two extreme points of the foreground image are determined by performing a gray scale calculation on the foreground image, and at least two edge points in the foreground image are determined according to the at least two extreme points of the foreground image.
[0124] It should be noted that the preprocessing on the first image includes image enhancement superposition processing, gray scale opening operation, gray scale closing operation, gray scale opening operation followed by gray scale closing operation, and gray scale closing operation followed by gray scale opening operation.
[0125] In some embodiments of the present disclosure, after the gray scale projection processing based on the first image to determine the foreground image, it is determined whether there is an extreme point in the foreground image. If there is an extreme point, at least two edge points in the foreground image are determined. If there is no extreme point, a preset caliper is directly called to measure the foreground image to obtain a measurement point of the foreground image, and an abnormal point is removed through a preset screening range, so that a straight line fitting is performed on the screened measurement point to determine a measurement line for the foreground image.
[0126] It can be understood that after the gray scale projection processing based on the first image to determine the foreground image, it is determined whether there is an extreme point in the foreground image. If there is no extreme point, a preset caliper is directly called to measure the foreground image to obtain a measurement point of the foreground image, and an abnormal point is removed through a preset screening range. Since the abnormal point will interfere with the straight line fitting, after removing the abnormal point, the straight line fitting is performed on the screened measurement point, which can improve the accuracy of the measurement line for the foreground image.
[0127] S102, determining an edge standard line of the foreground image based on the at least two edge points.
[0128] In some embodiments of the present disclosure, the edge standard line is a straight line fitted after the boundary of the battery assembly in the first image, which is mainly used for screening the edge points in the foreground image and removing abnormal points.
[0129] In some embodiments of the present disclosure, the server can determine the edge standard line of the foreground image by a two-point straight line determination method based on two edge points of the at least two edge points.
[0130] For example, as shown in FIG. 2a, the edge standard line of the foreground image is a straight line 1 in FIG. 2a. The result of fitting by the existing method is shown in FIG. 2b. As can be seen from FIG. 2b, there is a skew of the straight line.
[0131] In some embodiments of the present disclosure, the server can call the preset caliper to measure the foreground image to obtain a plurality of measurement points of the foreground image. The plurality of measurement points of the foreground image are subjected to abnormal point removal by the edge standard line to determine the first fitting point.
[0132] In some embodiments of the present disclosure, the server can call the preset caliper to measure the foreground image to obtain a plurality of measurement points of the foreground image. The plurality of measurement points of the foreground image are subjected to abnormal point removal by the edge standard line to determine the first fitting point.
[0133] In some embodiments of the present disclosure, after obtaining the plurality of measurement points of the foreground image, the server calculates a plurality of first distances between the edge standard line and the plurality of measurement points of the foreground image; and removes abnormal points from the plurality of measurement points by comparing the preset distance with the plurality of first distances to determine the first fitting point.
[0134] It should be noted that the abnormal point is a point far away from the edge standard line, i.e., the distance between the abnormal point and the edge standard line is greater than the preset distance.
[0135] For example, as shown in FIG. 3, the abnormal point is a measurement point in the white box 2 in FIG. 3.
[0136] In some embodiments of the present disclosure, the server can perform straight line fitting on the foreground image by the first fitting point to obtain a fitting image of the foreground image. The fitting image of the foreground image is subjected to position information transformation to determine the measurement line for the foreground image.
[0137] In some embodiments of the present disclosure, the server can perform straight line fitting on the foreground image by the first fitting point to obtain a fitting image of the foreground image. The fitting image of the foreground image is subjected to position information transformation to determine the measurement line for the foreground image.
[0138] It should be noted that the foreground image is derived from the first image, and the first image is obtained by intercepting the original image. Therefore, the position transformation relationship between the first image and the original image can be established. The position transformation relationship is also applicable to the foreground image and the original image.
[0139] It can be understood that, since the first fitting point is a screened measurement point, the straight line fitting through the first fitting point can improve the accuracy of the fitting image of the foreground image. Meanwhile, since the foreground image is determined after the original image is cropped, the foreground image is smaller than the original image region, and the straight line fitting on the foreground image can obtain a more accurate fitting image of the foreground image. Through the position transformation relationship between the original image and the foreground image, the coordinate transformation is performed on the more accurate fitting image of the foreground image to obtain the measurement line for the foreground image in the original image. In this transformation process, the high accuracy of the fitting image of the foreground image is preserved, so that the measurement line for the foreground image in the original image also has high accuracy, thereby improving the fitting accuracy of the measurement line for the foreground image in the original image.
[0140] For example, as shown in FIG. 4, the measurement line for the foreground image is region 3 in the white box in FIG. 4.
[0141] It can be understood that the server performs edge detection on the foreground image in the obtained original image to determine at least two edge points. Based on the at least two edge points, an edge standard line of the foreground image is determined; based on the edge standard line and a preset caliper, the foreground image is subjected to abnormal point removal to determine a first fitting point. The straight line fitting is performed through the first fitting point to determine the measurement line for the foreground image. In this process, since the points are fitted into a straight line, they are disturbed by abnormal points, therefore, through the establishment of the edge standard line, the abnormal point removal is performed on the measurement points of the foreground image, which can reduce the influence of abnormal points on the straight line fitting, thereby improving the fitting accuracy of the measurement line for the foreground image.
[0142] In some embodiments of the present disclosure, as shown in FIG. 5, S103 can be implemented through S201 and S202, as follows:
[0143] S201, a plurality of measurement points are obtained by calling a preset caliper to measure the foreground image.
[0144] In some embodiments of the present disclosure, the preset caliper is divided into a one-dimensional caliper and a two-dimensional caliper; wherein the one-dimensional caliper is usually used to measure the length or position of an object in one direction, such as the length in the horizontal or vertical direction. The two-dimensional caliper can measure in both horizontal and vertical directions, so it can obtain the length, width and position information of the object in the plane.
[0145] In some embodiments of the present disclosure, the server can call a one-dimensional caliper to measure the foreground image to obtain a plurality of measurement points.
[0146] For example, the one-dimensional caliper is called to measure the foreground image to obtain a plurality of measurement points, as shown in FIG. 6, the white horizontal line forming a small rectangle is a one-dimensional caliper.
[0147] S202, remove abnormal points from the plurality of measurement points based on the edge standard line, and determine first fitting points.
[0148] In some embodiments of the present disclosure, the server can remove abnormal points from the plurality of measurement points of the foreground image based on the edge standard line to obtain the first fitting points.
[0149] In some embodiments of the present disclosure, the server can determine a plurality of first distances between the plurality of measurement points based on the edge standard line; remove abnormal points from the plurality of measurement points by comparing the plurality of first distances with a preset distance, and determine the first fitting points.
[0150] It can be understood that the server can filter out abnormal points, reduce the influence of abnormal points on straight line fitting, and improve the fitting accuracy of the measurement line by calling the preset caliper to measure the foreground image to obtain the plurality of measurement points, and removing abnormal points from the plurality of measurement points based on the edge standard line to determine the first fitting points.
[0151] In some embodiments of the present disclosure, the server can calculate a plurality of first distances between the edge standard line and the plurality of measurement points. Compare the plurality of first distances with a preset distance, determine at least one first distance corresponding to a measurement point greater than the preset distance as an abnormal point. Remove the abnormal points from the plurality of measurement points, and determine the remaining measurement points as the first fitting points.
[0152] It can be understood that the server can filter out abnormal points, reduce the influence of abnormal points on straight line fitting, and improve the fitting accuracy of the measurement line by determining a plurality of first distances between the edge standard line and the plurality of measurement points, and removing abnormal points from the plurality of measurement points by comparing the plurality of first distances with a preset distance to determine the first fitting points.
[0153] In some embodiments of the present disclosure, as shown in FIG. 7, after S202, S301 and S302 are further performed, as follows:
[0154] S301, screen the first fitting points according to a preset screening range, remove abnormal points, and determine second fitting points in the foreground image.
[0155] In some embodiments of the present disclosure, the server can sort the first fitting points to obtain sorted first fitting points, and remove abnormal points in the sorted first fitting points by the preset screening range to obtain the second fitting points in the foreground image.
[0156] In some embodiments of the present disclosure, the server can screen the first fitting points by the preset screening range along a first direction to remove abnormal points outside the preset screening range, and determine the second fitting points in the foreground image; the first direction represents a dimension direction in a two-dimensional coordinate.
[0157] In some embodiments of the present disclosure, the server sorts the first fitting points along a first direction according to position information of the first fitting points to obtain sorted first fitting points; and removes abnormal points outside a preset screening range from the sorted first fitting points to determine second fitting points in the foreground image.
[0158] It should be noted that the position information of the first fitting points can be coordinates of the first fitting points, which is not limited in the embodiments of the present disclosure.
[0159] In some embodiments of the present disclosure, the first direction can be a horizontal direction. The server can sort the first fitting points according to ascending order of the horizontal coordinates of the first fitting points to obtain sorted first fitting points. The second fitting points in the foreground image are determined by removing abnormal points outside a preset screening range from the sorted first fitting points.
[0160] For example, the preset screening range can be 10%-90%. The preset order criterion is ascending order. The first fitting points after the gray projection screening are arranged in ascending order (coordinates along the x-axis are arranged), to obtain sorted first fitting points. The measurement points between 10%-90% of the sorted first fitting points are selected as the second fitting points.
[0161] It can be understood that the server screens the first fitting points along the first direction according to the preset screening range, removes abnormal points outside the preset screening range, determines the second fitting points in the foreground image, and performs secondary abnormal point screening on the measurement points, so that the second fitting points have higher accuracy.
[0162] S302 determines a measurement line for the foreground image by performing linear fitting on the second fitting points.
[0163] In some embodiments of the present disclosure, the server can determine a fitting image of the foreground image by performing sorting on the second fitting points and fitting a measurement line on the sorted second fitting points in the foreground image. The fitting image of the foreground image is position information transformed according to the position transformation relationship to determine the measurement line for the foreground image.
[0164] It can be understood that the server screens the first fitting points according to the preset screening range, removes abnormal points, determines the second fitting points in the foreground image, and performs secondary abnormal point screening, so that the second fitting points have higher accuracy. The measurement line for the foreground image is determined by performing linear fitting on the second fitting points in the foreground image, so that the measurement line for the foreground image has higher precision, and the overall robustness of the fitting algorithm can also be improved.
[0165] In some embodiments of the present disclosure, S101 can be implemented by S401, as follows:
[0166] S401, based on the original image, performing a gray projection process to determine a foreground image and at least two edge points of the foreground image.
[0167] In some embodiments of the present disclosure, the server crops the obtained original image to determine a first image containing a foreground object; based on the first image, performing a gray projection process to determine a foreground image and at least two edge points of the foreground image.
[0168] It can be understood that the server, based on the original image, performs a gray projection process to determine a foreground image and at least two edge points of the foreground image, which can facilitate determining the edge standard line through the at least two edge points.
[0169] In some embodiments of the present disclosure, S401 can be implemented by S4011, S4012 and S4013, as follows:
[0170] S4011, cropping the obtained original image to determine a first image containing a foreground object.
[0171] In some embodiments of the present disclosure, the server can obtain an original image, determine a target region of the original image in the original image, and crop the original image according to the target region to obtain a first image containing a foreground object.
[0172] It should be noted that the target region is a region containing a foreground object, and the foreground object can be a battery assembly.
[0173] S4012, based on the first image, performing a gray projection process to determine a foreground image.
[0174] S4013, performing a gray calculation on the foreground image to determine at least two edge points of the foreground image.
[0175] In some embodiments of the present disclosure, the gray calculation is performed on the foreground image to determine at least two extreme points of the foreground image, so as to determine at least two edge points in the foreground image according to the at least two extreme points of the foreground image.
[0176] It can be understood that the server crops the obtained original image to determine a first image containing a foreground object, and based on the first image, performs a gray projection process to determine a foreground image and at least two edge points of the foreground image. Since the first image is smaller than the original image, the calculation on the invalid region can be reduced, thereby improving the fitting accuracy of the measurement line.
[0177] In some embodiments of the present disclosure, after S4012, S501, S502 and S503 are further performed as shown in FIG. 8, as follows:
[0178] S501, by calling a preset caliper, measuring the foreground image in the acquired original image to obtain a plurality of measurement points.
[0179] In some embodiments of the present disclosure, the server can determine the direction of the two-dimensional caliper, and measure the foreground image in the acquired original image by calling the two-dimensional caliper to obtain a plurality of measurement points, or measure the foreground image in the acquired original image by calling the one-dimensional caliper to obtain a plurality of measurement points.
[0180] S502, according to a preset screening range, screening the plurality of measurement points to remove abnormal points, and determining a third fitting point in the foreground image.
[0181] In some embodiments of the present disclosure, the server sorts the plurality of measurement points according to the position information of the plurality of measurement points along the first direction to obtain a plurality of sorted measurement points, and removes abnormal points outside the preset screening range from the plurality of sorted measurement points to determine the third fitting point in the foreground image.
[0182] It should be noted that the principle of screening the plurality of measurement points according to the preset screening range to remove abnormal points and determine the third fitting point in the foreground image is similar to that of screening the first fitting point according to the preset screening range to remove abnormal points and determine the second fitting point in the foreground image, which will not be described here.
[0183] S503, by the third fitting point, performing linear fitting on the foreground image to determine a measurement line for the foreground image.
[0184] In some embodiments of the present disclosure, the server can sort the third fitting points, perform linear fitting on the sorted third fitting points on the foreground image to determine a fitting image of the foreground image, and perform position information transformation on the fitting image of the foreground image through the position transformation relationship to determine the measurement line for the foreground image.
[0185] It can be understood that the server screens the plurality of measurement points according to the preset screening range, removes abnormal points, and determines the third fitting point in the foreground image, which performs secondary abnormal point screening, so that the third fitting point has higher accuracy. Therefore, by the third fitting point, performing linear fitting on the foreground image to determine the measurement line for the foreground image makes the measurement line of the foreground image have higher precision, and also improves the overall robustness of the fitting algorithm.
[0186] In some embodiments of the present disclosure, based on the first image, the gray-scale projection processing is performed, the foreground image is determined, and at least two edge points of the foreground image can be implemented through S601, S602 and S603 as follows:
[0187] S601, the first image is subjected to image enhancement superposition processing according to the cycle number, and a first enhanced image is obtained.
[0188] In some embodiments of the present disclosure, the server can perform image enhancement superposition processing on the first image until the number of image enhancement superposition reaches the cycle number, stop processing, and obtain the first enhanced image.
[0189] In some embodiments of the present disclosure, the server determines the first gray-scale value and the second gray-scale value of the first image in different directions respectively; multiplies the first gray-scale value and the second gray-scale value to determine the gray-scale value of the initial enhanced image; and based on the gray-scale value of the initial enhanced image, continues to perform image enhancement superposition processing until the cycle number is reached to determine the first enhanced image.
[0190] In some embodiments of the present disclosure, the server can determine the first gray-scale value and the second gray-scale value of the first image in different directions respectively, perform image enhancement through the first gray-scale value and the second gray-scale value to obtain the gray-scale value of the initial enhanced image; and based on the gray-scale value of the initial enhanced image, continues to perform image enhancement superposition processing until the cycle number is reached to determine the first enhanced image.
[0191] It should be noted that the gray-scale value of the initial enhanced image is also divided into the first initial gray-scale value and the second initial gray-scale value of the initial enhanced image.
[0192] For example, the multiplication operation is performed on an image, the gray-scale value (g1, g2) of the first image is converted according to formula (1) to obtain a first enhanced image as follows: g’ = g1*g2*Mult+Add (1)
[0193] Wherein, g1 and g2 are the gray-scale values of the first image in different directions respectively; Mult is a multi-step value; Add represents superposition processing; g’ represents the gray-scale value of the first enhanced image.
[0194] It can be understood that the server determines the first gray value and the second gray value of the first image in different directions respectively; multiplies the first gray value and the second gray value to determine the gray value of the initial enhanced image. Based on the gray value of the initial enhanced image, the image enhancement superposition processing is continued until the number of cycles is reached to determine the first enhanced image. In this process, the image is processed in a FOR loop manner, the Mult value can be kept unchanged, the number of cycles is set, and the superposition processing is performed on the value. In addition, when the image enhancement coefficient Mult value increases from 0.1 to 0.2, the result shows that the coefficient increases, and the span is large, which is easy to exceed the expected effect. This way can be proportional growth or coefficient growth.
[0195] S602, at least one gray operation is performed on the first enhanced image to obtain a foreground image; wherein the at least one gray operation includes: gray open operation, gray close operation, gray open-close operation and gray close-open operation.
[0196] In some embodiments of the present disclosure, the gray open operation first performs an erosion operation on the image, and then performs an expansion on the erosion result. This operation is mainly used to remove small bright details in the image relative to the structure element, while keeping the overall gray value and large bright areas unchanged. The gray close operation is the opposite, which first performs an expansion operation and then performs an erosion. It is mainly used to remove small dark details in the image relative to the structure element, while keeping the overall gray value and large dark areas unchanged.
[0197] In some embodiments of the present disclosure, the server can perform a gray open operation on the first enhanced image to obtain a foreground image; or the server can perform a gray close operation on the first enhanced image to obtain a foreground image; or the server can first perform a gray close operation on the first enhanced image and then perform a gray open operation to obtain a foreground image; or the server can first perform a gray open operation on the first enhanced image and then perform a gray close operation to obtain a foreground image. In addition, the four gray operations can be performed on the first enhanced image, and the results can be fused or screened to obtain a foreground image.
[0198] For example, the first image is subjected to image enhancement superposition processing according to the number of cycles to obtain a first enhanced image, and at least one gray operation is performed on the first enhanced image to obtain a foreground image, which can be realized by FIG. 9 as follows:
[0199] S1, region of interest cropping.
[0200] In some embodiments of the present disclosure, after the server obtains the original image, the original image is preprocessed, and first, the region of interest, i.e., the region containing the battery component (i.e., the foreground object), is determined. The region of interest is cropped to obtain a first image.
[0201] S2, the first image after cropping is subjected to FOR loop proportional multiplication to enhance contrast.
[0202] In some embodiments of the present application, the server can determine the first gray value and the second gray value of the first image in different directions respectively, perform image enhancement through the first gray value and the second gray value to obtain the gray value of the initial enhanced image, and continue to perform image enhancement superposition processing until the number of cycles is reached to determine the first enhanced image. The number of cycles is the number of FOR loops.
[0203] S3, gray open operation.
[0204] In some embodiments of the present application, the server performs gray open operation on the first enhanced image after obtaining the first enhanced image to obtain the foreground image.
[0205] S4, gray close operation.
[0206] In some embodiments of the present application, the server performs gray close operation on the first enhanced image after obtaining the first enhanced image to obtain the foreground image.
[0207] In some embodiments of the present application, S3 or S4 can be performed after S2, and the present disclosure does not make specific limitations thereon. After S3 or S4 is performed, S5 is directly performed. In addition to this, S4 can be performed after S3 is performed, and then S5 is performed. In addition, S3 can be performed after S4 is performed, and then S5 is performed.
[0208] S5, obtaining the foreground image.
[0209] In some embodiments of the present application, the server can obtain the foreground image after performing gray open operation on the first enhanced image, or obtain the foreground image after performing gray close operation on the first enhanced image, or obtain the foreground image after performing gray close operation on the first enhanced image and then performing gray open operation, or obtain the foreground image after performing gray open operation on the first enhanced image and then performing gray close operation.
[0210] S603, performing gray calculation on the foreground image along a second direction to determine at least two edge points; the second direction is different from the first direction.
[0211] In some embodiments of the present application, the server can divide the foreground image into multiple region images along the second direction, perform gray calculation on the multiple region images to obtain multiple extreme points, and then determine multiple edge points according to the multiple extreme points; the second direction is different from the first direction.
[0212] In some embodiments of the present disclosure, the server divides the foreground image in the second direction to obtain at least two region images; performs gray scale calculation on the at least two region images respectively to obtain respective extreme points of the at least two region images; and determines at least two edge points based on the respective extreme points of the at least two region images.
[0213] It can be understood that the server divides the foreground image in the second direction to obtain at least two region images; performs gray scale calculation on the at least two region images respectively to obtain respective extreme points of the at least two region images; and determines at least two edge points based on the respective extreme points of the at least two region images, so as to facilitate subsequent determination of the edge standard line and screening of abnormal points, and thus improve the fitting accuracy of the measurement line.
[0214] In some embodiments of the present disclosure, the server calculates, for each region image, a unit gray scale mean value in the second direction to determine a total gray scale mean value of each region image; wherein the unit gray scale mean value represents a gray scale mean value of each row or each column in the corresponding dimension of the first direction; and determines the extreme point corresponding to each region image by establishing a discrete function and performing smoothing and derivation processing based on the total gray scale mean value of each region image.
[0215] It should be noted that the first direction is the vertical direction, and the unit gray scale mean value is the gray scale mean value of each row; or the first direction is the horizontal direction, and the unit gray scale mean value is the gray scale mean value of each column.
[0216] It can be understood that the server determines the extreme point corresponding to each region image for each region image, so as to facilitate determination of the at least two edge points, thus facilitating subsequent determination of the edge standard line and screening of abnormal points, and thus improving the fitting accuracy of the measurement line for the foreground image.
[0217] For example, the foreground image is divided in the second direction to obtain two region images, the foreground image is divided along the vertical direction (as shown in FIG. 10a) into two region images (as shown in FIG. 10b), the sum of all gray scales in a certain direction (horizontal direction each row or vertical direction each column) is calculated, and the mean value is calculated, the gray scale mean values of all rows or columns in the two region images are summarized, the original data is converted into a one-dimensional discrete function (as shown in FIG. 10c), and smoothing is performed to achieve the purpose of noise reduction (as shown in FIG. 10d), and then the zero points of the first derivative function of the function are calculated to obtain the maximum value and the minimum value (as shown in FIG. 10e). The maximum value represents the change from dark to light = positive, and the minimum value represents the change from light to dark = negative. According to the extreme points, two edge points are obtained, and the edge standard line is formed by the edge points (as shown in FIG. 2a).
[0218] It should be noted that the one-dimensional discrete function can be smoothed by applying the mean filter multiple times.
[0219] It can be understood that the server performs image enhancement superposition processing on the first image according to the number of cycles to obtain a first enhanced image, and performs at least one gray scale operation on the first enhanced image to obtain a foreground image. Through the cyclic image enhancement processing and the gray scale processing on the first image, the definition of the image can be improved. For the foreground image, the gray scale calculation is performed along the second direction to determine at least two edge points, so as to facilitate subsequent determination of the edge standard line and screening of abnormal points.
[0220] In some embodiments of the present disclosure, the fitting method of the measurement line further includes the following steps:
[0221] S701, determining first position information of a first point corresponding to an original image and second position information of a second point corresponding to a first image.
[0222] In some embodiments of the present disclosure, the server can determine the position information corresponding to the center point in the original image as the first position information of the first point corresponding to the original image, and determine the position information corresponding to the center point in the first image as the second position information of the second point corresponding to the first image.
[0223] S702, based on the first position information and the second position information, calculating a rotation angle and a translation distance to determine a position transformation relationship.
[0224] In some embodiments of the present disclosure, the server can calculate a rotation angle based on the first position information and the second position information to determine a rotation matrix, calculate a translation distance based on the first position information and the second position information to determine a translation vector, and multiply the rotation matrix and the translation vector to determine the position transformation relationship.
[0225] It should be noted that the first position information and the second position information can be two-dimensional coordinates.
[0226] It can be understood that the server can calculate a rotation angle based on the first position information and the second position information to determine a rotation matrix, calculate a translation distance based on the first position information and the second position information to determine a translation vector, and multiply the rotation matrix and the translation vector to determine the position transformation relationship, so as to establish the position transformation relationship between the first image and the original image, and facilitate subsequent conversion of the fitting image of the foreground image into the measurement line of the foreground image in the original image.
[0227] In some embodiments of the present disclosure, the server can determine the coordinates of the first point and the coordinates of the second point, establish the point correspondence and the two corresponding angles, calculate the rigid affine transformation, i.e., the transformation composed of rotation and translation, and return it as a homogeneous transformation matrix. The correspondence of the points can be the center point ((Weight-1) / 2, (Height-1) / 2) of the original image and the center point (X, Y) of the first image. The homogeneous transformation matrix is the position transformation relationship.
[0228] For example, the coordinates of the first point of the original image are (T x , T y ), and the coordinates of the second point of the first image are (O x , O y ). The position transformation relationship can be determined by formula (2) as follows:
[0229] Where M is the position transformation relationship, R is the rotation matrix, T is the translation vector, and 1 represents the angle. R can be calculated by formula (3), and T can be calculated by formula (4) as follows: T=(T x -O x, T y -O y ) (4)
[0230] Where θ is the rotation angle.
[0231] It can be understood that the server determines the first position information of the first point of the original image and the second position information of the second point of the first image, calculates the rotation angle and the translation distance through the first position information and the second position information, and determines the position transformation relationship, so as to facilitate the transformation of the fitting image of the foreground image into the measurement line of the foreground image in the original image through the position transformation relationship.
[0232] In some embodiments of the present disclosure, S104 can be implemented by S1041 and S1042 as follows:
[0233] S1041, through the first fitting point, performing straight line fitting on the foreground image to determine the fitting image of the foreground image.
[0234] In some embodiments of the present disclosure, the server performs fitting of the measurement line on the foreground image through the first fitting point to obtain the fitting image of the foreground image.
[0235] S1042, through the position transformation relationship, performing position information transformation on the fitting image of the foreground image to determine the measurement line.
[0236] In some embodiments of the present disclosure, the server can determine the measurement line for the foreground image by transforming the fitting image of the foreground image in position information according to the position transformation relationship.
[0237] It can be understood that the server determines the fitting image of the foreground image by fitting the measurement line on the foreground image through the first fitting point, and determines the measurement line for the foreground image by transforming the fitting image of the foreground image in position information according to the position transformation relationship. Since the first fitting point is the screened measurement point, the straight line fitting is performed through the first fitting point, which can improve the accuracy of the fitting image of the foreground image. At the same time, since the foreground image is determined by cropping the original image, the foreground image is smaller than the original image region, and when the straight line fitting is performed on the foreground image, a more accurate fitting image of the foreground image can be obtained. The measurement line for the foreground image in the original image is obtained by transforming the more accurate fitting image of the foreground image in coordinates according to the position transformation relationship between the original image and the foreground image. In this transformation process, the high accuracy of the fitting image of the foreground image is maintained, so that the measurement line for the foreground image in the original image also has high accuracy, thereby improving the fitting accuracy of the measurement line for the foreground image in the original image.
[0238] In some embodiments of the present disclosure, the server can design an encapsulation function interface. The input parameters mainly include the original image and a plurality of control parameters, and the output parameters include the measurement line for the foreground image in the original image.
[0239] It should be noted that the plurality of control parameters include: projection extreme value (i.e., at least two region images each corresponding to an extreme point), caliper threshold (i.e., the measurement range of the caliper, such as the position of the white grid in FIG. 6), caliper direction (i.e., the second direction, such as the vertical direction of the foreground image), target region for cropping (i.e., the region of interest, such as the region containing the battery assembly), etc. The output parameters can include two extreme points in addition to the measurement line for the foreground image in the original image.
[0240] In some embodiments of the present disclosure, FIG. 11 is an optional flowchart six of a measurement line fitting method provided by an embodiment of the present disclosure, and the implementation steps of the measurement line fitting method are as follows:
[0241] S11, image acquisition.
[0242] In some embodiments of the present disclosure, the image sensor acquires an image to obtain an original image.
[0243] S12, coarse positioning.
[0244] In some embodiments of the present disclosure, the server can perform coarse positioning on the original image.
[0245] S13, locate the target detection part, crop, and pretreat.
[0246] In some embodiments of the present disclosure, the server can locate the target detection part, i.e., the region containing the battery component, in the original image. The original image is cropped by the region where the battery component is located to obtain a first image. The first image is pretreated to obtain a foreground image.
[0247] It should be noted that the pretreatment includes image enhancement processing and grayscale processing. The grayscale processing includes grayscale opening operation, grayscale closing operation, grayscale opening operation followed by grayscale closing operation, and grayscale closing operation followed by grayscale opening operation.
[0248] In some embodiments of the present disclosure, after S13 is performed, S14 can be performed, and S21 can also be performed. There is no sequence between the two, and they are performed according to actual conditions.
[0249] S14, determine whether there is an extreme value.
[0250] In some embodiments of the present disclosure, the server can perform grayscale calculation on the foreground image to determine whether there is an extreme value.
[0251] In some embodiments of the present disclosure, when S14 is performed, if yes, S15 is performed; if no, S16, S23, S24, and S25 are performed.
[0252] S15, determine a target edge point and fit the target edge point into a standard line.
[0253] In some embodiments of the present disclosure, the server can determine a measurement point corresponding to the extreme value as a target edge point, and fit the target edge point into an edge standard line.
[0254] It should be noted that the target edge point is at least two edge points; and the edge standard line is the standard line.
[0255] S16, call a one-dimensional caliper to obtain a series of grayscale points.
[0256] In some embodiments of the present disclosure, the server can call a one-dimensional caliper on the foreground image to obtain a series of grayscale points.
[0257] It should be noted that the grayscale point is the measurement point.
[0258] S17, calculate the distance from the grayscale point to the standard line.
[0259] In some embodiments of the present disclosure, the server can calculate the distance between the series of grayscale points and the edge standard line to obtain the distance of a plurality of point lines.
[0260] S18, screen the grayscale points according to the distance of the point lines to obtain a first grayscale point.
[0261] In some embodiments of the present disclosure, the server can perform gray point screening on the series of gray points according to the distances of the plurality of point lines and the preset distance, to obtain first gray points.
[0262] S19, sorting and percentage cutting on the first gray points to obtain second gray points.
[0263] In some embodiments of the present disclosure, the server can sort the first gray points to obtain arranged first gray points, and then cut the arranged first gray points according to the percentage to obtain second gray points.
[0264] S20, arranging the second gray points.
[0265] In some embodiments of the present disclosure, the server can arrange the second gray points.
[0266] In some embodiments of the present disclosure, S20 is performed before S25.
[0267] S21, direction selection setting (U2B\B2U\L2R\R2L).
[0268] In some embodiments of the present disclosure, the server can set the direction according to one of from left to right, from right to left, from top to bottom, and from bottom to top.
[0269] S22, calling a two-dimensional caliper to obtain a series of gray points.
[0270] In some embodiments of the present disclosure, the server can call a two-dimensional caliper to obtain a series of gray points.
[0271] In some embodiments of the present disclosure, S22 is performed before S23, S24 and S25.
[0272] S23, sorting and percentage cutting on the series of gray points to obtain third gray points.
[0273] S24, arranging the third gray points.
[0274] In some embodiments of the present disclosure, S24 is performed before S25.
[0275] S25, obtaining final gray points, fitting an ideal straight line to obtain a measurement line for the foreground image.
[0276] In some embodiments of the present disclosure, the server can arrange the second gray points according to S20 to obtain final gray points. The final gray points are used for fitting a measurement line to obtain an ideal straight line, thereby obtaining a measurement line for the foreground image.
[0277] It should be noted that the final gray point can be the first fitting point, the second fitting point or the third fitting point.
[0278] It can be understood that in the fitting process of the measurement line for the image, for the interference of complex background and dirt, the disclosure can perform twice screening through the edge standard line and the percentage interception, can remove the abnormal points, and can improve the fitting accuracy of the measurement line for the foreground image.
[0279] The embodiment of the disclosure also provides a fitting device of a measurement line. FIG. 12 is a structural schematic diagram of a fitting device of a measurement line provided by the embodiment of the disclosure. As shown in FIG. 12, the fitting device of the measurement line 12 comprises a determination unit 1201, a screening unit 1202 and a fitting unit 1203, wherein
[0280] The determination unit 1201 is configured to perform edge detection on the foreground image in the acquired original image, and determine at least two edge points; and determine an edge standard line of the foreground image based on the at least two edge points.
[0281] The screening unit 1202 is configured to remove abnormal points from the foreground image based on the edge standard line and a preset caliper, and determine a first fitting point.
[0282] The fitting unit 1203 is configured to perform straight line fitting through the first fitting point, and determine a measurement line for the foreground image.
[0283] In some embodiments of the disclosure, the fitting device of the measurement line 12 further comprises a measurement unit 1204.
[0284] The measurement unit 1204 is configured to measure the foreground image by calling the preset caliper, and obtain a plurality of measurement points.
[0285] The screening unit 1202 is further configured to remove abnormal points from the plurality of measurement points based on the edge standard line, and determine the first fitting point.
[0286] In some embodiments of the disclosure, the screening unit 1202 is further configured to, after determining the first fitting point based on the edge standard line and the plurality of measurement points, screen the first fitting point according to a preset screening range, remove abnormal points, and determine a second fitting point in the foreground image.
[0287] The fitting unit 1203 is further configured to perform straight line fitting through the second fitting point, and determine a measurement line for the foreground image.
[0288] In some embodiments of the disclosure, the determination unit 1201 is further configured to determine a plurality of first distances between the plurality of measurement points based on the edge standard line.
[0289] The screening unit 1202 is further configured to remove abnormal points from the plurality of measurement points by the preset distance and the plurality of first distances, and determine first fitting points.
[0290] In some embodiments of the present disclosure, the screening unit 1202 is further configured to screen the first fitting points along a first direction by a preset screening range, remove abnormal points outside the preset screening range, and determine second fitting points in the foreground image; the first direction represents a dimension direction in a two-dimensional coordinate.
[0291] In some embodiments of the present disclosure, the determination unit 1201 is further configured to perform gray projection processing based on the original image, determine the foreground image, and at least two edge points of the foreground image.
[0292] In some embodiments of the present disclosure, the fitting device 12 of the measurement line further comprises a clipping unit 1205; wherein,
[0293] The clipping unit 1205 is configured to clip the obtained original image to determine a first image containing a foreground object.
[0294] The determination unit 1201 is further configured to perform gray projection processing based on the first image, determine the foreground image, and at least two edge points of the foreground image.
[0295] In some embodiments of the present disclosure, the fitting device 12 of the measurement line further comprises an enhancement unit 1206; wherein,
[0296] The enhancement unit 1206 is further configured to perform image enhancement superposition processing on the first image according to a cycle number to obtain a first enhanced image; and perform at least one gray scale operation on the first enhanced image to obtain the foreground image; wherein, the at least one gray scale operation includes gray scale opening operation, gray scale closing operation, gray scale opening and closing operation, and gray scale closing and opening operation.
[0297] The determination unit 1202 is further configured to perform gray scale calculation on the foreground image along a second direction to determine the at least two edge points; the second direction is different from the first direction.
[0298] In some embodiments of the present disclosure, the fitting device 12 of the measurement line further comprises a calculation unit 1207; wherein,
[0299] The calculation unit 1207 is further configured to divide the foreground image into at least two region images according to the second direction; and perform gray scale calculation on the at least two region images respectively to obtain extreme points corresponding to the at least two region images respectively.
[0300] The determination unit 1202 is further configured to determine the at least two edge points based on the extreme points corresponding to the at least two region images respectively.
[0301] In some embodiments of the present disclosure, the calculation unit 1207 is further configured to calculate a unit gray mean value in the second direction for each region image, determine a total gray mean value of each region image, wherein the unit gray mean value represents a gray mean value in the corresponding dimension of the first direction; and based on the total gray mean value of each region image, respectively determine an extreme point corresponding to each region image by establishing a discrete function and performing smoothing processing and derivation processing.
[0302] In some embodiments of the present disclosure, the calculation unit 1207 is further configured to determine a first gray value and a second gray value of the first image in different directions respectively; multiply the first gray value and the second gray value to determine a gray value of the initial enhanced image; and based on the gray value of the initial enhanced image, continue to perform image enhancement superposition processing until a cycle number is reached to determine the first enhanced image.
[0303] In some embodiments of the present disclosure, the calculation unit 1207 is further configured to determine first position information of the first point corresponding to the original image and second position information of the second point corresponding to the first image; based on the first position information and the second position information, calculate a rotation angle and a translation distance to determine a position transformation relationship.
[0304] In some embodiments of the present disclosure, the calculation unit 1207 is further configured to calculate a rotation angle based on the first position information and the second position information to determine a rotation matrix; calculate a translation distance based on the first position information and the second position information to determine a translation vector; and multiply the rotation matrix and the translation vector to determine the position transformation relationship.
[0305] In some embodiments of the present disclosure, the fitting unit 1203 is further configured to perform linear fitting on the foreground image through the first fitting point to determine a fitting image of the foreground image; and perform position information transformation on the fitting image of the foreground image through the position transformation relationship to determine the measurement line.
[0306] In some embodiments of the present disclosure, the measurement unit 1204 is further configured to perform gray projection processing based on the first image to determine the foreground image, and then call a preset caliper to measure the foreground image in the obtained original image to obtain a plurality of measurement points.
[0307] The screening unit 1202 is further configured to screen the plurality of measurement points according to a preset screening range, remove abnormal points, and determine a third fitting point in the foreground image; and perform linear fitting on the foreground image through the third fitting point to determine the measurement line for the foreground image.
[0308] Based on the fitting method of the measurement line of the above embodiment, the embodiment of the disclosure further provides a fitting device of a measurement line, as shown in Figure 13, which is a structural schematic diagram of a fitting device of a measurement line provided by the embodiment of the disclosure. The fitting device 13 of the measurement line comprises a processor 1301 and a memory 1302. The memory 1302 is used to store a computer program; the processor 1301 is used to call and run the computer program from the memory to execute the fitting method of the measurement line of the above embodiment.
[0309] In the embodiment of the disclosure, the above-mentioned processor 1301 can be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic device used to realize the function of the above-mentioned processor can also be other, and the embodiment of the disclosure does not make specific limitation.
[0310] The embodiment of the disclosure provides a computer readable storage medium, which stores a computer program, and is used to realize the fitting method of the measurement line of any one of the above embodiments when executed by a processor.
[0311] For example, the program instructions corresponding to the fitting method of the measurement line in the embodiment can be stored on a storage medium such as an optical disc, a hard disk, a U disk, etc. When the program instructions corresponding to the fitting method of the measurement line in the storage medium are read by an electronic device or executed, the fitting method of the measurement line of any one of the above embodiments can be realized.
[0312] If the integrated unit is realized in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solution of the embodiment or the whole or part of the technical solution that essentially contributes to the related art can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the embodiment method.
[0313] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium, and the program performs the steps of the above-mentioned method embodiments when executed; and the foregoing storage medium includes a mobile storage device, a read only memory (ROM), a magnetic disc or an optical disc and various storage medium capable of storing program codes.
[0314] The modules described as separate components above can or can not be physically separate, and the components shown as modules can or can not be physical modules; they can be located in one place or distributed on multiple network units; and part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments.
[0315] In addition, each functional module in each embodiment of the present disclosure can be integrated in one processing unit, or each module can be a separate unit, or two or more modules can be integrated in one unit; the integrated module can be realized in the form of hardware or in the form of hardware plus software function unit. It should be understood that "one embodiment" or "an embodiment" mentioned in the present disclosure means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner.
[0316] It should be understood that in various embodiments of the present disclosure, the size of the serial number of each step / process does not mean the execution order, and the execution order of each step / process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial number of the above-mentioned embodiments of the present disclosure is only for description, not representing the pros and cons of the embodiments.
[0317] It should be noted that in the application, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0318] In several embodiments provided by the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other manners. The embodiments described above are merely exemplary, for example, the division of units is only a logical function division, and there can be other division manners in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed coupling, or direct coupling or communication connection between any two components can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0319] The disclosed methods in several method embodiments provided by the present disclosure can be combined arbitrarily without conflict, to obtain new method embodiments.
[0320] The disclosed features in several product embodiments provided by the present disclosure can be combined arbitrarily without conflict, to obtain new product embodiments.
[0321] The disclosed features in several method or device embodiments provided by the present disclosure can be combined arbitrarily without conflict, to obtain new method or device embodiments.
[0322] The above is merely an implementation manner of the embodiments of the present disclosure, but the protection scope of the embodiments of the present disclosure is not limited to this. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present disclosure, which should be covered by the protection scope of the embodiments of the present disclosure. Therefore, the protection scope of the embodiments of the present disclosure should be subject to the protection scope of the claims.
Claims
A fitting method of a measurement line, the method comprising: performing edge detection on a foreground image in an acquired original image to determine at least two edge points; determining an edge standard line of the foreground image based on the at least two edge points; performing outlier point removal on the foreground image based on the edge standard line and a preset caliper to determine a first fitting point; performing straight line fitting through the first fitting point to determine a measurement line for the foreground image. The method of claim 1, wherein, The performing outlier point removal on the foreground image based on the edge standard line and a preset caliper to determine a first fitting point comprises: measuring the foreground image by calling the preset caliper to obtain a plurality of measurement points; performing outlier point removal on the plurality of measurement points based on the edge standard line to determine the first fitting point. The method of claim 2, wherein, After the performing outlier point removal on the plurality of measurement points based on the edge standard line to determine the first fitting point, the method further comprises: screening the first fitting point according to a preset screening range to remove outliers and determine a second fitting point in the foreground image; performing straight line fitting through the second fitting point to determine the measurement line for the foreground image. The method according to claim 2 or 3, wherein The performing outlier point removal on the plurality of measurement points based on the edge standard line to determine the first fitting point comprises: determining a plurality of first distances between the plurality of measurement points based on the edge standard line; removing outliers from the plurality of measurement points by a preset distance and the plurality of first distances to determine the first fitting point. The method of claim 3, wherein, The screening the first fitting point according to a preset screening range to remove outliers and determine a second fitting point in the foreground image comprises: screening the first fitting point according to the preset screening range along a first direction to remove outliers outside the preset screening range and determine a second fitting point in the foreground image; the first direction comprises a dimension direction in a two-dimensional coordinate. The method according to any one of claims 1 to 5, wherein The performing edge detection on a foreground image in an acquired original image to determine at least two edge points of the foreground image comprises: performing gray projection processing based on the original image to determine a foreground image and the at least two edge points of the foreground image. The method of claim 6, wherein, The performing gray projection processing based on the original image to determine a foreground image and the at least two edge points of the foreground image comprises: cropping the acquired original image to determine a first image containing a foreground object; performing gray projection processing based on the first image to determine the foreground image and the at least two edge points of the foreground image. The method of claim 7, wherein, The performing gray projection processing based on the first image to determine the foreground image and the at least two edge points of the foreground image comprises: performing image enhancement superposition processing on the first image according to a cycle number to obtain a first enhanced image; performing at least one gray operation on the first enhanced image to obtain the foreground image; wherein the at least one gray operation comprises: gray open operation, gray close operation, gray open-close operation and gray close-open operation; The foreground image is calculated in a second direction to determine the at least two edge points; the second direction is different from the first direction. The method of claim 8, wherein, The foreground image is calculated in a second direction to determine the at least two edge points, comprising: The foreground image is divided into at least two region images according to the second direction; The at least two region images are respectively calculated to obtain the extreme points corresponding to the at least two region images respectively; The at least two edge points are determined based on the extreme points corresponding to the at least two region images respectively. The method of claim 9, wherein, The at least two region images are respectively calculated to obtain the extreme points corresponding to the at least two region images, comprising: For each region image, the unit gray mean value in the second direction is calculated to determine the total gray mean value of the each region image; wherein the unit gray mean value represents the gray mean value in the first direction corresponding dimension; Based on the total gray mean value of the each region image, the extreme points corresponding to the each region image are determined by establishing a discrete function and performing smoothing processing and derivative processing respectively. The first image is enhanced and superimposed according to the number of cycles to obtain a first enhanced image, comprising: The method according to any one of claims 8-10, wherein The first gray value and the second gray value of the first image in different directions are determined; The first gray value and the second gray value are multiplied to determine the gray value of the initial enhanced image; Based on the gray value of the initial enhanced image, image enhancement superposition processing is continued until the number of cycles is reached to determine the first enhanced image. The method further comprises: The method according to any one of claims 7-10, wherein The first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image are determined; Based on the first position information and the second position information, the rotation angle and the translation distance are calculated to determine the position transformation relationship. Based on the first position information and the second position information, the rotation angle is calculated to determine the rotation matrix; The method of claim 12, wherein, Based on the first position information and the second position information, the translation distance is calculated to determine the translation vector; The rotation matrix and the translation vector are multiplied to determine the position transformation relationship. The first fitting point is used for linear fitting to determine the measurement line for the foreground image, comprising: The first fitting point is used for linear fitting on the foreground image to determine the fitting image of the foreground image; The method according to claim 12 or 13, wherein The fitting image of the foreground image is transformed in position information based on the position transformation relationship to determine the measurement line. The method further comprises: The foreground image in the obtained original image is measured by calling the preset caliper to obtain a plurality of measurement points; The method of claim 1, wherein, The plurality of measurement points are screened according to a preset screening range to remove abnormal points to determine the third fitting point in the foreground image; The third fitting point is used for linear fitting to determine the measurement line for the foreground image. The determination unit, the screening unit and the fitting unit are provided. A fitting device of measurement lines, the fitting device of measurement lines comprising: The determination unit is configured to perform edge detection on the foreground image in the obtained original image to determine at least two edge points; and determine an edge standard line of the foreground image based on the at least two edge points. The screening unit is configured to remove abnormal points from the foreground image based on the edge standard line and a preset caliper to determine first fitting points. The fitting unit is configured to perform linear fitting through the first fitting points to determine a measurement line for the foreground image. The apparatus of claim 16, wherein The fitting device of the measurement line further includes a measurement unit. The measurement unit is configured to call a preset caliper to measure the foreground image to obtain a plurality of measurement points. The screening unit is further configured to remove abnormal points from the plurality of measurement points based on the edge standard line to determine the first fitting points. According to the device of claim 17, After the screening unit removes abnormal points from the plurality of measurement points based on the edge standard line to determine the first fitting points, the screening unit screens the first fitting points according to a preset screening range, removes abnormal points, and determines second fitting points in the foreground image. The fitting unit is further configured to perform linear fitting through the second fitting points to determine the measurement line for the foreground image. A fitting device for measuring a line, comprising: A processor and a memory, wherein The memory is used to store a computer program. The processor is used to call and run the computer program from the memory to execute the fitting method of the measurement line according to any one of claims 1 to 15. A computer readable storage medium stores executable instructions for causing a processor to execute the fitting method of the measurement line according to any one of claims 1 to 15.
Citation Information
Patent Citations
Image-based straight line detection method and device, and electronic equipment
CN111080661A
Heat exchanger fin pitch measuring method and device based on machine vision and medium
CN114199148A
Straight line detection method and device, equipment and storage medium
CN116309660A
Workpiece size visual measurement method for complex machining environment
CN117011282A
Line width measurement method and apparatus, computing processing device, computer program, and computer readable medium
WO2023070593A1