Object detection method, object detection system and electronic device
By using vector data in product design drawings for matching and identification of detection objects, the problem of missed and missed detection in the prior art certification mark detection is solved, and higher detection accuracy and effectiveness are achieved.
Patent Information
- Application Number
- CN202411361100.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-09-27
AI Technical Summary
The prior art is prone to missed inspection and missed inspection in the detection of certification marks in product design drawings, especially after the certification marks are processed after post-processing such as size scaling, color change, etc.
The integrity and correctness of the detection object are determined by matching identification based on the vector data of the detection object in the image to be detected and the standardized vector data. Vector data can characterize the spatial location of objects and improve the accuracy of detection.
It improves the accuracy of detection, reduces the data distortion problem when comparing raster data in rotation and scaling scenarios, and ensures the effectiveness of the detection results.
Smart Images

Figure CN119068223B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of target detection technology, and in particular, to an object detection method, an object detection system, and an electronic device. Background Art
[0002] Image detection algorithms can be applied in a variety of scenarios to achieve the purpose of image recognition and detection. For example, image detection algorithms can be applied to the detection scenario of certification marks in product design drawings. Generally, certification marks marked in product design drawings are mandatory requirements before products leave the factory, and certification marks are used to indicate that products comply with relevant specifications. If the certification mark is missing from the product design drawing, or the certification mark in the product design drawing is incomplete, the products produced based on the product design drawing will face the risk of being scrapped after leaving the factory. Therefore, object detection of certification marks in product design drawings is an important part of product production and delivery.
[0003] However, the certification mark in the product design drawing may be post-processed (for example, resizing, changing color, etc.). In this application scenario, the recognition and detection of the certification mark through image detection algorithms is prone to missed detection and false detection. Summary of the invention
[0004] The embodiments of the present application provide an object detection method, an object detection system and an electronic device, which perform matching and identification based on the vector data of the detection object in the image to be detected and the standardized vector data corresponding to the detection object to determine the integrity and correctness of the detection object. Since the vector data can represent information such as the spatial position of the object, matching detection based on an appropriate amount of data can improve the detection accuracy.
[0005] In order to achieve the above-mentioned purpose, the embodiments of the present application adopt the following technical solutions.
[0006] In a first aspect, a method for object detection is provided, the method comprising:
[0007] The electronic device acquires an image to be detected, wherein the image to be detected includes at least one detection object.
[0008] The electronic device obtains a reference image corresponding to each detection object in the image to be detected. The reference image is a standard image corresponding to the detection object. The standard image refers to a complete image of the detection object, or the standard image refers to a complete and correct image of the detection object.
[0009] The electronic device performs matching detection of the detection object and the reference image based on the first vector data of the detection object and the second vector data of the reference image to obtain a detection result of the detection object.
[0010] The test result is used to indicate whether the test object has passed or failed the test.
[0011] In the present application, the electronic device can match the first vector data of the detection object with the second vector data of the detection object from the dimension of the vector data based on the first vector data of the detection object in the image to be detected and the second vector data of the reference image corresponding to the detection object, so as to realize the recognition and detection of the detection object. When the first vector data matches the second vector data, it is considered that the detection of the detection object in the image to be detected is qualified. When the first vector data does not match the second vector data, it is considered that the detection of the detection object in the image to be detected is unqualified. The comparison between vector data is essentially a parameter comparison of the function, which reduces the problem of reduced accuracy of the original data caused by the distortion of the original data when the raster data is compared in the rotation and scaling scenarios. Consistency matching based on vector data (detection of compliance with specifications) can ensure the validity of the detection results and improve the detection accuracy of the detection object in the image to be detected.
[0012] In a possible implementation manner of the first aspect, the electronic device performs matching detection between the detection object and the reference image based on the first vector data of the detection object and the second vector data of the reference image, and obtains a detection result of the detection object, including:
[0013] For each detection object in the image to be detected, the electronic device constructs a coordinate system with reference to the first vector data of the detection object.
[0014] The electronic device maps the second vector data of the reference image to the coordinate system, performs matching detection between the detection object and the reference image, and obtains the detection result of the detection object.
[0015] In the present application, the electronic device can also use the second vector data of the reference image as a reference to map the first vector data of the detection object to the coordinate system, perform matching detection between the detection object and the reference image, and obtain the detection result of the detection object. The mapping method is similar.
[0016] In the present application, the electronic device can use the first vector data as a reference to map the second vector data to the coordinate system of the first vector data to perform matching detection between the detection object and the reference image. The vector data object can be decomposed into coordinate points. Whether it is scaled or rotated, it is essentially a parameter transformation of the polyline or Bezier curve function. In theory, there will be no distortion problem. Consistency matching based on vector data can ensure the validity of the detection results and improve the detection accuracy of the detection object in the image to be detected.
[0017] In another possible implementation manner of the first aspect, the first vector data includes a coordinate sequence of marking points in the detection object, and the second vector data includes a coordinate sequence of marking points in a reference image.
[0018] Mapping the second vector data of the reference image to the coordinate system, performing matching detection between the detection object and the reference image, and obtaining the detection result of the detection object, including:
[0019] The electronic device obtains the first marking point in the coordinate sequence of the second vector data of the reference image.
[0020] The electronic device maps the target marking point of the coordinate sequence of the second vector data to the coordinate position of the corresponding target marking point in the coordinate sequence of the first vector data of the detection object, so that the target marking point of the coordinate sequence of the second vector data coincides with the coordinate position of the target marking point in the coordinate sequence of the first vector data; the target marking point is the first marking point in the coordinate sequence, or the target marking point is any marking point in the coordinate sequence.
[0021] The electronic device traverses the second marking points in the coordinate sequence of the second vector data of the reference image, matches and detects each second marking point with the first marking point in the coordinate sequence of the first vector data of the detection object, and obtains the detection result of the detection object.
[0022] The second marking points are the remaining marking points in the coordinate sequence of the second vector data except the target marking point; and the first marking points are the remaining marking points in the coordinate sequence of the first vector data except the target marking point.
[0023] In this application, vector data objects can be decomposed into coordinate points, and electronic devices can perform traversal matching of marker points based on the marker points in the first vector data and the marker points in the second vector data. Whether scaling or rotation is essentially a parameter transformation of a polyline or Bezier curve function, there will be no distortion problem in theory. Consistency matching based on vector data can ensure the validity of the detection results and improve the detection accuracy of the object in the image to be detected.
[0024] In another possible implementation manner of the first aspect, the electronic device traverses the second marking points in the coordinate sequence of the second vector data of the reference image, matches and detects each second marking point with the first marking point in the coordinate sequence of the first vector data of the detection object, and obtains a detection result of the detection object, including:
[0025] The electronic device matches and detects each second marking point with each first marking point. If all the second marking points have matching first marking points, it performs attribute information detection on the detection object to obtain the detection result of the detection object; the existence of a matching first marking point at the second marking point includes the coordinate position of the second marking point being consistent with the coordinate position of the matching first marking point.
[0026] If there is no matching first marking point for at least one second marking point, the electronic device performs coordinate transformation on the second vector data, traverses the marking points in the coordinate sequence of the second vector data after the coordinate transformation, matches and detects the marking points in the coordinate sequence of the second vector data after the coordinate transformation with the first marking point in the coordinate sequence of the first vector data of the detection object, and obtains the detection result of the detection object.
[0027] In the present application, the vector data object can be decomposed into coordinate points. When there is no matching first mark point at the second mark point, the coordinate transformation of the second vector data can be performed. For example, the second vector data can be rotated or scaled, and consistency detection can be performed again to ensure the validity of the consistency detection of the first vector data and the second vector data. Because it is based on the matching comparison of vector data, whether scaling or rotation is essentially a parameter transformation of a broken line or Bezier curve function, theoretically there will be no distortion problem. Consistency matching based on vector data can ensure the validity of the detection results and improve the detection accuracy of the detection object in the image to be detected.
[0028] In another possible implementation manner of the first aspect, the electronic device performs coordinate transformation on the second vector data, traverses the marked points in the coordinate sequence of the second vector data after the coordinate transformation, matches and detects the marked points in the coordinate sequence of the second vector data after the coordinate transformation with the first marked points in the coordinate sequence of the first vector data of the detection object, and obtains a detection result of the detection object, including:
[0029] The electronic device calculates the angle deviation between the first vector data and the second vector data according to the coordinate positions of at least two marking points in the coordinate sequence of the first vector data and the coordinate positions of at least two marking points in the coordinate sequence of the second vector data.
[0030] The electronic device rotates the second vector data based on the angle deviation to obtain the second vector data after the first coordinate is transformed.
[0031] The electronic device matches and detects each third marking point in the coordinate sequence of the second vector data after the first coordinate is converted with each first marking point. If all the third marking points have matching first marking points, it performs attribute information detection on the detection object to obtain the detection result of the detection object.
[0032] If there is no matching first marking point for at least one third marking point, the electronic device calculates the size deviation between the second vector data after the first coordinate transformation and the first vector data based on the coordinate positions of at least two third marking points and the coordinate positions of the corresponding first marking points; the electronic device scales the second vector data after the first coordinate transformation based on the size deviation to obtain the second vector data after the second coordinate transformation.
[0033] The electronic device matches and detects each fourth marking point in the coordinate sequence of the second vector data after the second coordinate is converted with each first marking point. If all the fourth marking points have matching first marking points, it performs attribute information detection on the detection object to obtain the detection result of the detection object.
[0034] If at least one fourth marking point does not have a matching first marking point, the electronic device obtains the next reference image and performs a matching detection between the detection object and the next reference image; if the next reference image does not exist, the detection result of the detection object is unqualified.
[0035] The position deviation includes angle deviation and size deviation. The electronic device adjusts the angle or size of the first vector data and the second vector data based on the position deviation, thereby matching the marking points according to the adjusted first vector data and the second vector data, which can be achieved in a variety of feasible ways.
[0036] Among them, the electronic device may first perform a first coordinate transformation based on the angle deviation. If there is at least one third marking point that does not match the first marking point among the third coordinate points included in the second vector data after the first coordinate transformation, the electronic device may reduce or enlarge the second vector data based on the size deviation (second coordinate transformation), thereby matching the marking points of the second vector data after the second coordinate transformation. Alternatively, the electronic device may first perform a second coordinate transformation based on the size deviation. If there is at least one fourth marking point that does not match the first marking point among the fourth coordinate points included in the second vector data after the second coordinate transformation, the electronic device may perform an angle rotation (first coordinate transformation) on the second vector data based on the angle deviation, thereby matching the marking points of the second vector data after the first coordinate transformation. The order in which the electronic device performs the first coordinate transformation based on the angle deviation and the second coordinate transformation based on the size deviation is not limited.
[0037] In the present application, for some detection objects that have been deformed in size or rotation angle, during consistency detection, the electronic device can rotate the second vector data of the reference image of the detection object based on the angle deviation, thereby converting the second vector data to the same rotation angle as the first vector data for consistency detection, which can improve the detection effectiveness and accuracy of the detection object. In the case of no match after rotation, the second vector data of the reference image can also be scaled based on the size deviation, thereby converting the second vector data to the same size as the first vector data for consistency detection, further improving the detection effectiveness and accuracy of the detection object.
[0038] In another possible implementation manner of the first aspect, the detection requirement information corresponding to the reference image specifies a size range and a rotation angle range of the reference image.
[0039] The electronic device rotates the second vector data based on the angle deviation to obtain the second vector data after the first coordinate is transformed, including:
[0040] Within the size range and the rotation angle range, the electronic device rotates the second vector data based on the angle deviation to obtain the second vector data after the first coordinate is transformed.
[0041] The electronic device scales the second vector data after the first coordinate transformation based on the size deviation to obtain the second vector data after the second coordinate transformation, including:
[0042] Within the size range, the electronic device scales the second vector data after the first coordinate transformation based on the size deviation to obtain the second vector data after the second coordinate transformation.
[0043] In the present application, for some detection objects that have been deformed in size or rotation angle, during consistency detection, the electronic device can rotate and scale the second vector data of the reference image of the detection object within the size range and rotation angle range based on the angle deviation and size deviation, thereby changing the second vector data to the same rotation angle as the first vector data for consistency detection, which can improve the detection effectiveness and accuracy of the detection object.
[0044] In another possible implementation manner of the first aspect, the attribute information includes at least color information, the first vector data includes first color information, the second vector data includes second color information, and performing attribute information detection on the detection object to obtain a detection result of the detection object includes:
[0045] If the first color information is consistent with the second color information, the detection result of the detection object is qualified; if the first color information is inconsistent with the second color information, the detection result of the detection object is unqualified.
[0046] In the present application, for some detection objects that require consistent color information, the electronic device can also perform consistency detection of color information. The color information may include the values of different color channels. By obtaining the color information of the detection object and performing color consistency detection on the color information corresponding to the reference image, the detection effectiveness and accuracy of the detection object can be improved.
[0047] In another possible implementation manner of the first aspect, before the electronic device constructs a coordinate system for each detection object in the image to be detected using the first vector data of the detection object as a reference, the method further includes:
[0048] For each detection object in the image to be detected, the electronic device obtains a first number of marking points included in the first vector data of the detection object.
[0049] The electronic device obtains a second number of candidate reference images that is the same as the first number based on a second number of marking points included in the second vector data of the reference image.
[0050] The electronic device maps the second vector data of the reference image into the coordinate system, performs matching detection between the detection object and the reference image, and obtains the detection result of the detection object, including:
[0051] The electronic device maps the second vector data of the candidate reference image to the coordinate system, performs matching detection between the detection object and the candidate reference image, and obtains the detection result of the detection object.
[0052] In the present application, the electronic device can first perform a preliminary match based on the number of marking points contained in the first vector data and the second vector data. If the number of marking points of the first vector data is different from the number of marking points of the second vector data, it means that the first vector data and the second vector data are most likely not matched, and there is no need to perform consistency detection based on the first vector data and the second vector data. This can reduce the amount of data for consistency detection by the electronic device and improve the efficiency of consistency detection by the electronic device.
[0053] In another possible implementation manner of the first aspect, the method further includes:
[0054] The electronic device obtains first vector data of the detection object according to the vector image of the detection object through the vector data extraction tool; the electronic device obtains second vector data of the reference image according to the vector image of the reference image through the vector data extraction tool.
[0055] In the present application, the electronic device can obtain the vector data of the image to be detected or the reference image through a vector data extraction tool, so that consistency detection can be performed based on the vector data. The comparison between vector data is essentially a parameter comparison of the function, which reduces the problem of reduced accuracy of the original data caused by the distortion of the original data when the raster data is compared in the rotation and scaling scenarios. Consistency matching based on vector data can ensure the validity of the detection results and improve the detection accuracy of the detection object in the image to be detected.
[0056] In another possible implementation manner of the first aspect, a database is deployed in the electronic device; the database pre-stores a reference image corresponding to the detection object included in the image to be detected.
[0057] The database also includes second vector data corresponding to the reference image and related information of the reference image; the related information of the reference image includes at least the encoding of the reference image and the regional information of the reference image, the regional information includes detection requirement information of the reference image in the region to which it belongs, wherein the detection requirement information includes requirements for the color, rotation angle and size of the reference image.
[0058] In the present application, reference images corresponding to each detection object and related information of the reference images can be stored in the database in advance. In the process of consistency detection, consistency detection of the detection object in multiple dimensions can be performed based on the related information to improve the detection accuracy of the detection object.
[0059] In another possible implementation manner of the first aspect, the electronic device obtains a reference image corresponding to each detection object in the image to be detected, including:
[0060] Based on the code corresponding to the detection object in the image to be detected, the electronic device searches a database for a reference image whose code matches the code corresponding to the detection object.
[0061] In the present application, the detection object has a code for unique identification. The electronic device can query the matching reference image from the database based on the code, and then perform consistency detection between the detection object and the reference image, thereby improving the detection efficiency and accuracy of the detection object.
[0062] In another possible implementation of the first aspect, when the image to be detected is a product design drawing, the detection object includes the authentication mark, and the reference image is a complete image corresponding to the authentication mark; when the image to be detected is a circuit diagram of a circuit board, the detection object includes components, and the reference image is a complete image corresponding to the components, and the components include at least one or more of a power supply, a resistor, an inductor, and a capacitor.
[0063] In the present application, the object detection method can be applied to any scenario where a vector image / vector data of the detection object can be obtained, and can improve the detection efficiency and accuracy of the detection object in a variety of scenarios.
[0064] In another possible implementation manner of the first aspect, the method further includes:
[0065] The electronic device displays the detection result of the detection object on the display interface.
[0066] In the present application, the electronic device displays the detection result of the detection object on the display interface, so that the user can more intuitively know the detection result of the image to be detected.
[0067] In a second aspect, an object detection system is provided, the object detection system comprising a detection module and a database. The database pre-stores reference images corresponding to a plurality of detection objects.
[0068] The detection module is used to obtain an image to be detected, where the image to be detected includes at least one detection object.
[0069] The detection module is used to obtain a reference image corresponding to each detection object in the image to be detected from the database; the reference image is a standard image corresponding to the detection object.
[0070] The detection module is used to perform matching detection between the detection object and the reference image based on the first vector data of the detection object and the second vector data of the reference image to obtain the detection result of the detection object.
[0071] The test result is used to indicate whether the test object has passed or failed the test.
[0072] In the present application, the detection module in the object detection system can match the first vector data of the detection object with the second vector data of the detection object from the dimension of the vector data based on the first vector data of the detection object in the image to be detected and the second vector data of the reference image corresponding to the detection object, so as to realize the recognition and detection of the detection object. When the first vector data matches the second vector data, it is considered that the detection of the detection object in the image to be detected is qualified. When the first vector data does not match the second vector data, it is considered that the detection of the detection object in the image to be detected is unqualified. The comparison between vector data is essentially a parameter comparison of the function, which reduces the problem of reduced accuracy of the original data caused by the distortion of the original data when the raster data is compared in the rotation and scaling scenarios. Consistency matching based on vector data (detection of compliance with specifications) can ensure the validity of the detection results and improve the detection accuracy of the detection object in the image to be detected.
[0073] In a possible implementation manner of the second aspect, the detection module is further configured to display a detection result of the detected object on a display interface of the object detection system.
[0074] In the present application, the object detection system can display the detection result of the detected object on the display interface. In addition, the object detection system can also display some intermediate results of the matching detection process on the display interface, for example, the intermediate result of mapping the first vector data and the second vector data to the same coordinate system can be displayed, and so on.
[0075] In the present application, the object detection system can display intermediate results and output results, so that the user can more intuitively know the detection results of the image to be detected.
[0076] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any one of the methods described in the first aspect.
[0077] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer program / instructions are executed by a processor, the steps of the method described in any one of the first aspects are implemented.
[0078] In a fifth aspect, a computer program product comprising instructions is provided, including a computer program / instructions, which, when executed by a processor, implements the steps of any one of the methods described in the first aspect above.
[0079] In a sixth aspect, an embodiment of the present application provides a chip, the chip including a processor, the processor being used to call a computer program in a memory to execute a method as described in any one of the methods in the first aspect.
[0080] It can be understood that the beneficial effects that can be achieved by the electronic device described in the third aspect, the computer-readable storage medium described in the fourth aspect, the computer program product described in the fifth aspect, and the chip described in the sixth aspect provided above can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] Figure 1 A schematic diagram of an authentication mark provided in an embodiment of the present application;
[0082] Figure 2 A schematic diagram of a detection object in different scenarios provided in an embodiment of the present application;
[0083] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0084] Figure 4 A flow chart of an object detection method provided in an embodiment of the present application;
[0085] Figure 5 A schematic diagram of a scene of an object detection algorithm when the image to be detected is a product design drawing provided in an embodiment of the present application;
[0086] Figure 6 A schematic diagram of a flow chart of another object detection method provided in an embodiment of the present application;
[0087] Figure 7 A schematic diagram of a scene of an object detection algorithm when the image to be detected is a circuit diagram of a circuit board provided in an embodiment of the present application;
[0088] Figure 8 A flow chart of an object detection algorithm provided in an embodiment of the present application;
[0089] Fig. 9 A schematic diagram of a broken line and a Bezier curve provided in an embodiment of the present application;
[0090] Fig.10 A schematic diagram of a specific process of consistency detection provided in an embodiment of the present application;
[0091] Fig.11 A schematic diagram of calculating position deviation provided in an embodiment of the present application;
[0092] Fig.12 A schematic diagram of the structure of another electronic device provided in an embodiment of the present application;
[0093] Fig.13 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0094] In the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0095] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0096] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0097] It is a mandatory requirement for the product design to have a certification mark before the product leaves the factory. The certification mark is used to indicate that the product complies with relevant specifications. If the certification mark is missing from the product design, or if the certification mark in the product design is incomplete, the product produced based on the product design will face the risk of being scrapped after leaving the factory. Therefore, object detection of the certification mark in the product design is an important part of product production and shipment.
[0098] In traditional technology, the certification mark in the product design drawing can be detected through manual review; or, the certification mark in the product design drawing can be identified and detected through an image detection algorithm.
[0099] Among them, manual review refers to manually comparing the certification mark of the product design drawing with the standard certification mark at each review stage of the product design drawing to determine whether the certification mark of the product design drawing is consistent with the standard certification mark. However, this traditional manual review method is limited by the experience of the reviewers. If the reviewers do not have sufficient knowledge or inaccurate grasp of the standard certification marks under different specifications, or the reviewers may miss some minor errors that are not easy to identify with the naked eye, this will lead to problems of missed detection and wrong detection of the certification mark.
[0100] Image detection algorithm refers to the use of template matching, machine learning and other algorithms based on image raster data to compare the consistency of the standard certification mark with the certification mark of the product design drawing. Among them, the raster data reflected in the image can be understood as the image pixels presenting a grid layout in the image. For example, Figure 1 A schematic diagram of a certification mark is given. Figure 1 (a) shows a standard schematic diagram of a certification mark. Figure 1 (b) shows a schematic diagram of raster data (i.e., pixel map) of an authentication mark. Figure 1 From the two types of data of the certification mark provided in (a) and (b), it can be seen that compared with the standard image of the certification mark, the raster data of the certification mark has some missing edge information and the certification mark has a rotation angle.
[0101] Since the authentication mark detection of the image detection algorithm is essentially a consistency comparison of the pixel map of the authentication mark in the image, and some product design drawings may perform image post-processing such as rotation, scaling, and color adjustment on the authentication mark, the pixel map of the authentication mark in the product design drawing cannot be completely matched with the pixel map of the standard authentication mark. The post-image processing may also cause the edge information of the raster data to be missing, resulting in a higher false detection rate.
[0102] Regarding the post-image processing of the certification mark in the actual product design drawing, in general, the consistency judgment between the standard certification mark and the certification mark in the actual product design drawing can be thresholded. However, during the thresholding process, if the threshold is set too high, it will cause false negatives in the detection results, resulting in a higher false detection rate and lower detection efficiency. Among them, false negatives refer to the theoretical detection result should be 1 (the predicted result is a match), but the actual detection result is 0 (the predicted result is a mismatch). If the threshold is set too low, it will cause false positives in the detection results, resulting in a higher missed detection rate. Among them, false positives refer to the theoretical detection result should be 0 (the predicted result is a mismatch), but the actual detection result is 1 (the predicted result is a match). Therefore, the detection of certification marks based on raster data (pixel images) has the problem of low detection accuracy.
[0103] The embodiment of the present application provides an object detection method, which can match the first vector data of the detection object with the second vector data of the detection object from the dimension of the vector data based on the first vector data of the detection object in the image to be detected, and the second vector data corresponding to the detection object (the standardized vector data corresponding to the detection object), so as to realize the recognition and detection of the detection object. When the first vector data matches the second vector data, it is considered that the detection object in the image to be detected meets the specification. When the first vector data does not match the second vector data, it is considered that the detection object in the image to be detected does not meet the specification. Since the vector data is used to represent the spatial position of the detection object, the vector data object can be decomposed into coordinate points and vector parameters. Whether scaling or rotation is essentially a parameter transformation of a polyline or Bezier curve function, theoretically, there will be no problem of missing or distorted pixel edge information. Based on vector data, consistency matching (detection of compliance with the specification) can be applied to scenes where the detection object is rotated, scaled, and other post-image processing is performed, which can ensure the validity of the detection results and improve the detection accuracy of the detection object in the image to be detected.
[0104] An object detection method provided in an embodiment of the present application can be applied to the detection of detection objects in various scenarios. In some specific scenarios, for example, the detection object can be an identification, in which a specific example, the identification can be a designated identification (such as a certification identification) in a product design drawing. In the embodiment of the present application, vector data of a designated identification in a product design drawing can be obtained, and object detection (also referred to as target detection) can be performed based on the vector data of the designated identification to determine whether the designated identification in the product design drawing is correct and complete. For another example, the detection object can be a component, circuit, etc. in a circuit design drawing of a circuit board. In the embodiment of the present application, vector data of components and / or circuits in a circuit design drawing of a circuit board can be obtained, and object detection can be performed based on the vector data of components and / or circuits to determine whether the components and circuits in the circuit design drawing of the circuit board are correct and complete. Among them, the components can include one or more components that may be involved in the circuit diagram, such as power supply, resistor, inductor, capacitor, etc. For another example, the detection object can be a building, passage, etc. in a construction design drawing. In the embodiment of the present application, vector data of the detection object in the construction drawing can be obtained, and object detection can be performed based on the vector data of the detection object to determine whether the detection object in the construction design drawing is correct and complete. For another example, the detection object may be a designated icon in the product outer packaging design drawing, for example, the designated icon includes a recyclable logo, a barcode, a trash can logo, etc. In the embodiment of the present application, vector data of the designated icon in the product outer packaging design drawing may be obtained, and object detection may be performed based on the vector data of the designated icon to determine whether the designated icon in the product outer packaging design drawing is correct and complete.
[0105] For example, Figure 2 Schematic diagrams of detection objects in different scenarios are given.
[0106] Figure 2 (a) shows a schematic diagram of a compulsory certification mark in a product design drawing. The compulsory certification mark is applicable to products included in the designated catalog. After the products in the designated catalog are certified by the designated certification body, their corresponding product design drawings need to contain complete and accurate compulsory certification marks, so as to carry out subsequent production and factory delivery processes. In the embodiment of the present application, the vector data of the compulsory certification mark in the product design drawing to be tested can be obtained, and matching detection is performed based on the vector data of the compulsory certification mark in the product design drawing to be tested and the pre-stored complete and accurate vector data of the compulsory certification mark, so as to determine whether the compulsory certification mark in the product design drawing to be tested is correct and complete.
[0107] Figure 2 (b) shows the schematic diagram of several components of the circuit board. Figure 2 In (b), the components include resistors, capacitors, and inductors. In the embodiment of the present application, vector data of each component in the circuit diagram of the circuit board to be detected can be obtained, and matching detection is performed based on the vector data of each component in the circuit diagram of the circuit board to be detected and the pre-stored complete and correct vector data of each component, so as to determine whether each component in the circuit diagram of the circuit board to be detected is correct and complete.
[0108] Figure 2 (c) shows several designated icons in the product packaging design. Figure 2 The designated icon 1 (trash can icon) in (c) is used to remind users to throw product waste into the trash can after using the product. Figure 2 The designated icon 2 (recyclable logo) in (c) is used to remind the user that the packaging of the product is made of recyclable materials. In the embodiment of the present application, the vector data of the designated icon in the outer packaging design drawing of the product to be detected can be obtained, and a matching detection is performed based on the vector data of the designated icon in the outer packaging design drawing of the product to be detected and the pre-stored complete and correct vector data of the designated icon, so as to determine whether the designated icon in the outer packaging design drawing of the product to be detected is correct and complete.
[0109] That is to say, for detection scenarios of detection objects in which vector data can be obtained, the object detection method provided in the embodiments of the present application can be used to perform detection and matching of the detection objects, thereby achieving the purpose of complete and accurate judgment of the detection objects.
[0110] An object detection method provided in an embodiment of the present application can be applied to an electronic device. For example, the electronic device can be a portable computer (such as a mobile phone), a tablet computer, a laptop computer, a personal computer (PC), a server, etc. The following embodiments do not impose any special restrictions on the specific form of the electronic device.
[0111] For example, Figure 3 As shown in the structural schematic diagram of the electronic device 100. Figure 3 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. Figure 3 , Figure 3 The electronic device 100 shown may include: a processor 301 , a memory 302 , a communication interface 303 , and a bus 304 . The processor 301 , the memory 302 , and the communication interface 303 may be connected via the bus 304 .
[0112] The processor 301 is the control center of the electronic device, and may be a general-purpose central processing unit (CPU) or other general-purpose processors, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0113] As an example, the processor 301 may include one or more CPUs, such as Figure 3 CPU 0 and CPU 1 are shown in .
[0114] The memory 302 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0115] In a possible implementation, the memory 302 may exist independently of the processor 301. The memory 302 may be connected to the processor 301 via a bus 304 and used to store data, instructions, or program codes. When the processor 301 calls and executes the instructions or program codes stored in the memory 302, the object detection method provided in the embodiment of the present application can be implemented.
[0116] In another possible implementation, the memory 302 may also be integrated with the processor 301 .
[0117] In some embodiments, a database may be deployed in the memory 302 of the electronic device. The database is used to pre-store relevant data of various detection objects in various scenarios (for example, designated logos in product design drawings, components in circuit diagrams of circuit boards, designated icons in product packaging design drawings, etc.), and the relevant data of the detection objects in the database are used as reference data (also called standard data) in the detection process to perform detection and matching of the detection objects in the image to be detected.
[0118] The relevant data may include an image of the detection object, vector data of the detection object, and other relevant information of the detection object. For example, when the detection object is a designated mark in a product design drawing, other relevant information may include the operator information of the product design drawing, the component code, the whole machine code, the stock keeping unit (SKU) code of the product corresponding to the product design drawing, the shipping place information of the product corresponding to the product design drawing, the detection requirement information of the designated mark in the product design drawing, etc. Among them, the detection requirement information may include the requirement information related to the attributes such as the size, rotation angle and color of the designated mark. The detection requirement information is related to the shipping place information, that is, the shipping place to which the product is sold is different, and the shipping place may have different requirements for the size, rotation angle and color of the designated mark in the product design drawing. Each product component code has a corresponding whole machine code, each product whole machine code has a corresponding SKU code, and each SKU code has the shipping place information of the corresponding product. Among them, the component code refers to the unique identification code of a single component, and a single component can be a single chip or a single device; the whole machine code refers to the unique identification code of the device where the component is located. For example, if the component is a mobile phone chip, the component code is the chip code, and the whole machine code is the code of the mobile phone. SKU can also be called product code or item number. SKU corresponds to the product's shipping location information. The shipping location information refers to the relevant information about the region where the product is sold. The region where the product is sold determines the testing requirements for the certification mark in the product design drawing. For example, region 1 requires the product design drawing to have certification mark 1, region 2 requires the product design drawing to have certification mark 2, and so on.
[0119] For example, when the detection object is a component of a circuit diagram of a circuit board, other relevant information may include the component code corresponding to the component, the circuit board detection requirement information corresponding to the component code, etc. The circuit board detection requirement information may include layout rules, component size, spacing between components, etc.
[0120] In another feasible embodiment, the database may be deployed in other devices. For example, the database may be deployed in the cloud. The electronic device interacts with the database in the cloud to obtain the relevant data of the detection object pre-stored in the database.
[0121] In this embodiment, a preset database stores relevant data corresponding to various images to be detected and each detection object, providing effective data support during the object detection process of the images to be detected and the detection objects, so that the object detection of the detection objects is more accurate.
[0122] The communication interface 303 is used for the electronic device to connect to other devices through a communication network, and the communication network may be Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 303 may include a receiving unit for receiving data and a sending unit for sending data.
[0123] In one embodiment, if the database is deployed in the cloud / other device, the electronic device can establish a communication connection with the cloud / other device through the communication interface 303 to obtain the relevant data of the detection object pre-stored in the database. Alternatively, the electronic device can also directly establish a communication connection with the database through the communication interface 303 to obtain the relevant data of the detection object pre-stored in the database.
[0124] The bus 304 may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0125] It should be pointed out that Figure 3 The structure shown in the figure does not constitute a limitation on the electronic device, except Figure 3 In addition to the components shown, the electronic device may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0126] In one embodiment, the object detection method provided by the present application is described by taking the detection object as a designated mark in a product design drawing as an example. Figure 4, Figure 4 A flow chart of an object detection method is given. The object detection of a product design drawing is applied before the product design drawing is archived. That is, before the product design drawing is archived, object detection is performed on the product design drawing, and whether the product design drawing can be archived is determined based on the object detection result. For example, if the detection result indicates that the product design drawing is qualified, it can be archived; if the detection result indicates that the product design drawing is unqualified, it cannot be archived.
[0127] Among them, archiving the product design drawings refers to archiving the product design drawings to an archiving platform for product design drawings for storage, and recording the stored operator information.
[0128] Perform object detection on the product design drawing and determine whether to archive the product design drawing based on the object detection result, including:
[0129] S201: The electronic device obtains an image to be detected and attribute information of the image to be detected.
[0130] In this embodiment, the image to be detected is a product design drawing to be detected. When the image to be detected is a product design drawing, the attribute information of the product design drawing may include information such as the operator information of the product design drawing and the component code of the corresponding product of the product design drawing.
[0131] The attribute information of the image to be detected is the default information of the image to be detected, and each image to be detected has the attribute information itself.
[0132] S202: The electronic device obtains region information corresponding to the image to be detected from a database based on the attribute information of the image to be detected.
[0133] Among them, when the image to be detected is a product design drawing, the attribute information may include the component code of the product corresponding to the product design drawing. The regional information refers to the shipping place information of the product corresponding to the image to be detected, and also refers to the relevant information of the region where the product is sold. The regional information determines the relevant detection standards of the detection object in the image to be detected. For example, when the image to be detected is a product design drawing, the detection object is a certification mark, and the regional information is region 1, the relevant detection standards of region 1 include requiring the product design drawing to have certification mark 1; when the regional information is region 2, the relevant detection standards of region 2 include requiring the product design drawing to have certification mark 2, and so on.
[0134] In this embodiment, when the image to be detected is a product design drawing, the database is a database corresponding to the product design drawing (referred to as the first database). The database corresponding to the product design drawing stores reference images and related data corresponding to multiple authentication marks that may be involved in the product design drawing. Among them, the related data includes the component code, the whole machine code corresponding to the component code, the SKU corresponding to the whole machine code, the regional information corresponding to the SKU, etc. The related data may also include the detection requirement information of the product design drawing, etc.
[0135] Based on the component code, the electronic device can query the target component code matching the component code from the database through the first database interface. Therefore, based on the target component code, the target whole machine code corresponding to the target component code can be obtained; based on the target whole machine code, the target SKU corresponding to it can be obtained, and based on the target SKU, the target shipping place information corresponding to it can be obtained. At least one of the target component code, the target whole machine code, the target SKU, and the target shipping place information can be used as the regional information of the product corresponding to the image to be detected.
[0136] S203: The electronic device determines reference data corresponding to the image to be detected according to the image to be detected and the corresponding attribute information and region information.
[0137] The reference data may include data such as a reference image corresponding to the detection object in the image to be detected, detection requirement information, etc.
[0138] The electronic device can perform object detection on the detection object in the image to be detected based on the reference data and a preset object detection algorithm, and determine the integrity and correctness of the detection object in the image to be detected.
[0139] The reference image refers to a standard image corresponding to the detection object, wherein the standard image refers to a complete image of the detection object, or the standard image refers to a complete and correct image of the detection object. For example, if the detection object is the designated identifier 1, then the reference image is a standardized, complete, and correct image corresponding to the designated identifier 1. The detection requirement information may include information related to the attributes used to limit the detection standard of the detection object, for example, it may include information related to the attributes such as the size, rotation angle, and color of the detection object.
[0140] S204: The electronic device uses the image to be detected, the reference image, and the detection requirement information as inputs of a preset target detection algorithm to obtain a detection result of the image to be detected.
[0141] In this embodiment, the preset target detection algorithm refers to object detection based on first vector data of the detection object of the image to be detected and second vector data of the reference image.
[0142] Before performing object detection based on a preset target detection algorithm, the electronic device may first extract vector data from the detected object and a reference image corresponding to the detected object to obtain first vector data of the detected object and second vector data of the reference image. The vector data may be extracted using a preset vector data extraction tool, and the embodiment of the present application does not limit how to extract the vector data.
[0143] In the present embodiment, the electronic device can determine whether the image to be detected / reference image is a vector graphic according to the image format of the image to be detected / reference image. If the image to be detected / reference image is not a vector graphic, the electronic device can first obtain the vector graphic of the image to be detected / reference image, and extract the first vector data / second vector data based on the vector graphic. If the image to be detected / reference image is a vector graphic, the first vector data / second vector data can be directly extracted based on the image to be detected / reference image. Among them, the formats of the vector graphic include *.bw, *.ai, *.cdr, *.col, *.cgm, *.dwg, *.wmf, *.eps. The electronic device can determine whether it is a vector graphic based on the image format of the image to be detected / reference image, and when it is determined that the image to be detected / reference image is not a vector graphic, the vector graphic of the image to be detected / reference image can be obtained through an image format conversion tool or an image format conversion algorithm.
[0144] The extracted first vector data / second vector data may include a breakpoint sequence or a Bezier curve sequence. The breakpoint sequence or the Bezier curve sequence includes multiple marker points. The electronic device can extract the marker points according to the two-dimensional coordinates and record the two-dimensional coordinate matrix range of each marker point. Optionally, when extracting vector data, other attribute information of the detection object / reference image can also be obtained, and a corresponding relationship between the vector data and the attribute information is formed. Among them, the attribute information can be, for example, color information. For example, the color information includes the values of different color channels.
[0145] After obtaining the first vector data of the detection object and the second vector data of the reference image, the first vector data and the second vector data can be mapped in the same coordinate system to perform consistency detection on the first vector data and the second vector data. Among them, the first vector data or the second vector data can be rotated, scaled, etc., so that the first vector data and the second vector data are in the same coordinate system, with the same size and the same angle for consistency detection. In an optional embodiment, since the vector data is data formed by multiple marking points for representing the spatial position, before mapping the first vector data and the second vector data to the same coordinate system, a preliminary detection can be performed based on the number of marking points contained in the first vector data and the data of the marking points contained in the second vector data. The first vector data and the second vector data whose numbers of marking points do not match are not mapped to the same coordinate system and consistency detection is not performed, which can improve the detection efficiency. In an optional embodiment, after the first vector data and the second vector data are mapped to the same coordinate system for consistency detection, the color consistency detection can also be performed on the color information corresponding to the first vector data and the color information corresponding to the second vector data.
[0146] The detection result is used to indicate whether the detection of the detection object in the image to be detected is successful or failed.
[0147] Among them, when the image to be detected is a product design drawing, successful detection can indicate that the detection object (for example, a certification mark) in the product design drawing meets the design requirements / design specifications; failed detection can indicate that the detection object (for example, a certification mark) in the product design drawing does not meet the design requirements / design specifications.
[0148] If the detection object in the image to be detected is consistent with the reference image (for example, the first vector data is consistent with the second vector data), and the detection object matches the detection requirement information (for example, the color is consistent), then the detection result of the detection object in the image to be detected is a successful detection. If the detection object in the image to be detected is inconsistent with the reference image, or the detection object does not match the detection requirement information, then the detection result of the detection object in the image to be detected is a detection failure.
[0149] When the image to be detected is a product design drawing, if the detection result is a detection failure, the product design drawing cannot be archived to the archiving platform of the product design drawing. In one embodiment, the product design drawing can be tagged, and the tag is set as a certification mark detection failure / test failure.
[0150] Figure 5A scene diagram of an object detection algorithm when the image to be detected is a product design drawing is given. In combination with the above S201-S204, the electronic device can obtain the product design drawing and the attribute information of the product design drawing. Based on the attribute information of the product design drawing, the electronic device obtains the reference data corresponding to the product design drawing from the database. Among them, the reference data includes the reference image corresponding to the certification mark in the product design drawing and the detection requirement information. Among them, Figure 5 Take the example of a product design drawing that includes only one authentication mark. The electronic device obtains the first vector data of the authentication mark and the second vector data of the reference image corresponding to the authentication mark, performs consistency detection between the authentication mark and the reference image, and obtains the detection result of the authentication mark (that is, the product design drawing). The detection result includes a qualified detection or a failed detection.
[0151] This embodiment provides an object detection method, which can match the first vector data of the detection object and the second vector data corresponding to the detection object (standardized vector data corresponding to the detection object) from the dimension of the vector data to realize the recognition and detection of the detection object. When the first vector data matches the second vector data, it is considered that the detection object in the image to be detected meets the specification. When the first vector data does not match the second vector data, it is considered that the detection object in the image to be detected does not meet the specification. The comparison between vector data is essentially a parameter comparison of the function, which reduces the problem of the original data accuracy being reduced due to the distortion of the original data when the raster data is compared in the rotation and scaling scenes. The vector data object can be decomposed into coordinate points and vector parameters. Whether scaling or rotation is essentially a parameter transformation of the polyline or Bezier curve function, theoretically, no distortion problem will occur. Based on the consistency matching of vector data (detection of compliance with the specification), the validity of the detection result can be guaranteed, and the detection accuracy of the detection object in the image to be detected can be improved.
[0152] In another embodiment, the object detection method provided by the present application is described by taking the components of the circuit diagram of the circuit board as an example. Figure 6 , Figure 6 A flow chart of another object detection method is given. Among them, the object detection of the circuit diagram of the circuit board is applied before the circuit diagram of the circuit board is archived. That is, before the circuit diagram of the circuit board is archived, the components in the circuit diagram of the circuit board are subjected to object detection, and whether the circuit diagram of the circuit board can be archived is determined based on the object detection result. For example, if the detection result indicates that the circuit diagram of the circuit board is qualified, it can be archived; if the detection result indicates that the circuit diagram of the circuit board is unqualified, it cannot be archived.
[0153] Among them, archiving the circuit diagram of the circuit board refers to archiving the circuit diagram of the circuit board to an archiving platform for the circuit diagram of the circuit board for storage, and recording the stored operator information.
[0154] Performing object detection on components in a circuit diagram of a circuit board, and determining whether to archive the circuit diagram of the circuit board based on the object detection result, including:
[0155] S301: The electronic device obtains an image to be detected and attribute information of the image to be detected.
[0156] The image to be detected refers to the image to be detected. In this embodiment, the image to be detected is a circuit diagram of a circuit board. When the image to be detected is a circuit diagram of a circuit board, the attribute information of the circuit diagram of the circuit board may include operator information of the circuit diagram of the circuit board and component codes corresponding to the circuit diagram of the circuit board.
[0157] The attribute information of the image to be detected is the default information of the image to be detected, and each image to be detected has the attribute information itself.
[0158] S302: The electronic device obtains a reference image and detection requirement information corresponding to the image to be detected from a database based on the attribute information of the image to be detected.
[0159] Wherein, when the image to be detected is a circuit diagram of a circuit board, the detection requirement information may include the detection standard requirements of the circuit board. In this embodiment, when the image to be detected is a circuit diagram of a circuit board, the database is a database corresponding to the circuit board (referred to as the second database). The database corresponding to the circuit board stores reference images and related data corresponding to multiple components that may be involved in the circuit diagram of the circuit board. Wherein, the related data includes component codes, detection standard requirements of the circuit board, etc.
[0160] The reference image refers to a standardized, complete, and correct image corresponding to the inspection object. For example, if the inspection object is component 1 of the circuit diagram of the circuit board, then the reference image is a standardized, complete, and correct image corresponding to component 1 of the circuit diagram of the circuit board. Exemplarily, the inspection standard requirements for the circuit board may include standard requirements for dimensions such as layout rules, component size, and spacing between components.
[0161] The database stores reference data corresponding to different inspection objects. Based on the component code, the electronic device can query the database through the second database interface for a reference image matching the component code and the inspection standard requirements of the circuit board.
[0162] S303: The electronic device uses the image to be detected, the reference image and the detection requirement information as inputs of a preset target detection algorithm to obtain a detection result of the image to be detected.
[0163] Similar to S204 above, before performing object detection based on a preset target detection algorithm, the electronic device may first extract vector data of the detection object and the reference image corresponding to the detection object to obtain first vector data of the detection object and second vector data of the reference image. After obtaining the first vector data of the detection object and the second vector data of the reference image, the first vector data and the second vector data may be mapped in the same coordinate system to perform a consistency check on the first vector data and the second vector data. After the first vector data and the second vector data are mapped to the same coordinate system for consistency check, a color consistency check may also be performed on the color information corresponding to the first vector data and the color information corresponding to the second vector data.
[0164] Among them, when the image to be detected is a circuit diagram of a circuit board, successful detection can indicate that the components in the circuit diagram of the circuit board meet the design requirements / design specifications; failed detection can indicate that the components in the circuit diagram of the circuit board do not meet the design requirements / design specifications.
[0165] If the detection object in the image to be detected is consistent with the reference image, and the detection object matches the detection requirement information, then the detection result of the detection object in the image to be detected is a successful detection. If the detection object in the image to be detected is inconsistent with the reference image, or the detection object does not match the detection requirement information, then the detection result of the detection object in the image to be detected is a detection failure.
[0166] When the image to be detected is a circuit diagram of a circuit board, if the detection result is a detection failure, the circuit diagram of the circuit board cannot be archived to the circuit diagram archiving platform of the circuit board. In one embodiment, the circuit diagram of the circuit board can be labeled, and the label is set as component detection failure / detection failure.
[0167] Figure 7 A scene diagram of an object detection algorithm is given when the image to be detected is a circuit diagram of a circuit board. In combination with the above S301-S303, the electronic device can obtain the circuit diagram of the circuit board and the attribute information of the circuit diagram of the circuit board. Based on the attribute information of the circuit diagram of the circuit board, the electronic device obtains reference data corresponding to the circuit diagram of the circuit board from a database. The reference data includes reference images corresponding to components in the circuit diagram of the circuit board and detection requirement information. Figure 7 Take the circuit diagram of a circuit board that includes only one component as an example. The electronic device obtains the first vector data of the component and the second vector data of the reference image corresponding to the component, performs consistency detection between the component and the reference image, and obtains the detection result of the component (that is, the circuit diagram of the circuit board). The detection result includes a qualified detection or a failed detection.
[0168] In some feasible embodiments, an object detection system is provided, and the object detection system includes a detection module and a database. The detection module can execute the object detection method executed by the electronic device in the above-mentioned embodiment. Among them, the database and the detection module can be deployed on the same device, that is, the object detection system is deployed in the electronic device, and the object detection system / electronic device includes a detection module and a data volume. The database and the detection module can also be independently deployed on different devices, for example, the database can be deployed in the cloud. For example, the object detection system includes a detection module deployed in the electronic device, and a database deployed in the cloud.
[0169] The object detection system may include a display interface for interacting with a user. The display interface may display intermediate results during the object detection process and final detection results of the image to be detected.
[0170] For example, the intermediate result may include the result of mapping the first vector data and the second vector data to the same coordinate system. The detection module / electronic device may display a schematic diagram of mapping the first vector data and the second vector data to the same coordinate system on a display interface. For example, the intermediate result may also include the result of vector data extraction for the image to be detected / reference image. The detection module / electronic device may display a schematic diagram of the corresponding vector data obtained by vector extraction for the image to be detected / reference image on a display interface.
[0171] The display interface displays the final detection result of the image to be detected, which may be a reminder message of the final detection result output in the form of a message window, or a schematic diagram of the final detection result may be displayed in the form of a legend.
[0172] This embodiment provides an object detection method, which can match the first vector data of the detection object and the second vector data corresponding to the detection object (standardized vector data corresponding to the detection object) from the dimension of the vector data to realize the recognition and detection of the detection object. When the first vector data matches the second vector data, it is considered that the detection object in the image to be detected meets the specification. When the first vector data does not match the second vector data, it is considered that the detection object in the image to be detected does not meet the specification. The comparison between vector data is essentially a parameter comparison of the function, which reduces the problem of the original data accuracy being reduced due to the distortion of the original data when the raster data is compared in the rotation and scaling scenes. The vector data object can be decomposed into coordinate points and vector parameters. Whether scaling or rotation is essentially a parameter transformation of the polyline or Bezier curve function, theoretically, no distortion problem will occur. Based on the consistency matching of vector data (detection of compliance with the specification), the validity of the detection result can be guaranteed, and the detection accuracy of the detection object in the image to be detected can be improved.
[0173] Specifically, in the above S204 / S303, the electronic device uses the image to be detected, the reference image and the detection requirement information as the input of the preset target detection algorithm to perform object detection on the image to be detected and obtain the detection result of the image to be detected. Figure 8 The flowchart of the target detection algorithm is given. It includes:
[0174] S401: The electronic device extracts first vector data of a detection object in an image to be detected.
[0175] The image to be detected may include one or more different detection objects. The electronic device extracts first vector data corresponding to each detection object in the image to be detected.
[0176] In this embodiment, the electronic device can extract the vector data of each detection object by using a traditional vector data extraction tool or a traditional vector data extraction algorithm.
[0177] Specifically, for example, the detection object is the authentication mark 1 in the product design drawing. The electronic device can obtain the vector diagram of the product design drawing, identify the vector data of the authentication mark 1 in the vector diagram of the product design drawing, obtain the marking points of the vector data of the authentication mark 1, extract according to the coordinates of the marking points, and form a coordinate matrix range of the marking points corresponding to the authentication mark 1.
[0178] Generally, the image to be detected is a two-dimensional image, and the coordinates of the corresponding marking points are two-dimensional coordinates. The marking points contained in the vector data of the extracted authentication mark 1 can form inflection points or Bezier curves. Correspondingly, when the marking points form inflection points, the coordinates of the marking points can form an inflection point sequence; when the marking points form a Bezier curve, the coordinates of the marking points can form a Bezier curve sequence.
[0179] Fig. 9 A schematic diagram of a polyline and a Bezier curve is given.
[0180] For example, Fig. 9 (a) shows a schematic diagram of a polyline, which contains multiple marked points. Fig. 9 (b) shows a schematic diagram of a Bezier curve. The Bezier curve is a mathematical curve used in two-dimensional graphics applications. General vector graphics software uses it to accurately draw curves. The Bezier curve consists of line segments, control points, and nodes. Nodes are draggable fulcrums, and line segments are like retractable rubber bands.
[0181] For example, Fig. 9(b) shows a schematic diagram of a second-order Bezier curve. The second-order Bezier curve contains 3 control points (A, B and C). Select any point D on the line segment AB. Calculate the ratio of the distance AD from the point to the starting point of the line segment to the total length AB of the line segment. According to the obtained ratio, find the corresponding point E on the line segment BC, so that AD:AB=BE:BC. Connect this DE, and find the point F with the same ratio on the line segment DE again, so that DF:DE=AD:AB=BE:BC. Point F is the fulcrum of the second-order Bezier curve. Let the selected point D move from the starting point A to the end point B on the line segment AB, find all the fulcrums F on the second-order Bezier curves, and all the fulcrums F form a second-order Bezier curve. For example, Fig. 9 (c) shows a schematic diagram of a third-order Bezier curve. The third-order Bezier curve contains 4 control points (A1, B1, C1 and D1). When K1K:K1K2=E1K1:E1F1=F1K2:F1G1=A1E1:A1B1=B1F1:B1C1=C1G1:C1D1, let point E1 move from the starting point A1 to the end point B1 on the line segment A1B1, and let point K1 move from the starting point E1 to the end point F1 on the line segment E1F1. Find all the fulcrums K on the third-order Bezier curves. All the fulcrums K form a third-order Bezier curve.
[0182] Among them, the control points (A, B and C) or (A1, B1, C1 and D1) in the Bezier curve are the marking points of the vector data corresponding to the detection object in the embodiment of the present application.
[0183] In an embodiment of the present application, the electronic device performs vector data recognition on the vector image of each detection object in the detection image based on a vector data extraction tool or recognition algorithm, and obtains the first vector data corresponding to each detection object. For example, if the image to be detected contains three detection objects, the electronic device extracts the vector data of each detection object in the image to be detected, and obtains the first vector data 1 corresponding to the detection object 1, the first vector data 2 corresponding to the detection object 2, and the first vector data 3 corresponding to the detection object 3. The first vector data of each detection object includes the first marking point corresponding to the detection object and the coordinates of each first marking point, and all the first marking points and the coordinates of the first marking points can form a marking point coordinate matrix range corresponding to the detection object.
[0184] S402: The electronic device extracts second vector data of a reference image included in the image to be detected from a database based on attribute information of the image to be detected.
[0185] Based on the whole machine code corresponding to the image to be detected and the regional information and other information, the electronic device can query the reference image that may be contained in the image to be detected from the database.
[0186] Similar to S401 , the electronic device may extract vector data from the reference image using a traditional vector data extraction tool or a traditional vector data extraction algorithm.
[0187] Similarly, the marker points contained in the vector data of the extracted reference image can form inflection points or Bezier curves. Correspondingly, when the marker points form inflection points, the coordinates of the marker points can form an inflection point sequence; when the marker points form Bezier curves, the coordinates of the marker points can form a Bezier curve sequence.
[0188] In an embodiment of the present application, the electronic device performs vector data recognition on the vector image of the reference image based on a vector data extraction tool or recognition algorithm, and obtains the second vector data corresponding to each reference image. For example, if the image to be detected contains three reference images, the electronic device can obtain three reference images from the database for vector data extraction. After extracting the vector data of each reference image, the second vector data 1 of reference image 1, the second vector data 2 of reference image 2, and the second vector data 3 of reference image 3 are obtained. The second vector data corresponding to each reference image includes the second marking point corresponding to the reference image and the coordinates of each second marking point. All second marking points and the coordinates of the second marking points can form a marking point coordinate matrix range corresponding to the reference image.
[0189] Alternatively, in another feasible embodiment, the electronic device can extract vector data for all reference images in the database in advance, and pre-store the second vector data of each reference image. When performing target detection of the detection object of the image to be detected, the electronic device can directly obtain the second vector data of all reference images corresponding to the image to be detected for target detection, thereby avoiding the increase in time consumption that may be caused by real-time vector data extraction of reference images, and improving the efficiency of target detection.
[0190] For each detection object in the image to be detected, the electronic device performs:
[0191] S403: The electronic device performs consistency detection on the first vector data of the detection object based on the second vector data of the reference image that is queried.
[0192] For each detection object in the image to be detected, the electronic device performs consistency detection on the detection object and all reference images corresponding to the image to be detected to determine the detection result of each detection object.
[0193] In one implementation, the electronic device can use the first vector data of the detection object as a reference to construct a two-dimensional coordinate system of the first vector data, map the second vector data of the queried reference image into the two-dimensional coordinate system, and perform consistency detection.
[0194] For details, please refer to the specific process of consistency detection. Fig.10 A flowchart is given, which includes:
[0195] S4031: The electronic device obtains a first number of marking points in first vector data of the detection object and a second number of marking points in second vector data of each reference image.
[0196] Each marked point in the vector data corresponds to a coordinate, and the number of marked points in the vector data is also the number of coordinates contained in the vector data.
[0197] The electronic device can directly obtain the first number of marking points of the first vector data of the detection object based on the first vector data of the detection object; and obtain the second number of marking points of the second vector data based on the second vector data of each reference image.
[0198] S4032. The electronic device determines whether there are a second number of reference images that are consistent with the first number.
[0199] If it exists, then S4033 is executed, that is, the next step of consistency detection is performed. If it does not exist, then the detection result of the detection object is determined to be detection failure.
[0200] In this embodiment, when the reference images queried by the electronic device include multiple ones, the reference images that may match the detection object can be preliminarily screened by the number of marking points. Specifically, if the second number of all reference images is inconsistent with the first number of the detection object, that is, there is no reference image whose second number is consistent with the first number, it means that any reference image matching the detection object cannot be queried in the database, and the detection object may be missing or wrong, and the detection result of the detection object is detection failure, and the detection object is unqualified / does not meet the specification requirements.
[0201] If there are reference images whose second quantity is consistent with the first quantity, the electronic device uses the reference images as candidate reference images and performs the next step of consistency detection with the detection object.
[0202] Exemplarily, the number of marking points included in the first vector data of the detection object 1 is 13. In the reference images queried by the electronic device, the number of marking points included in the second vector data of the reference image 1 is 13; the number of marking points included in the second vector data of the reference image 2 is 11; and the number of marking points included in the second vector data of the reference image 3 is 15.
[0203] There are reference images 1 of which the second number is consistent with the first number (13) of the detection object 1. In this case, the electronic device selects the reference image 1 as a candidate reference image for subsequent consistency detection with the detection object 1. A portion of the reference images is initially screened out to reduce the amount of data for the consistency detection of the detection object 1 by the electronic device.
[0204] In some embodiments, there may be multiple candidate reference images, and the electronic device can perform consistency detection between each candidate reference image and the detection object in turn according to a certain order.
[0205] In some embodiments, the electronic device may perform the above-mentioned S4031 and S4032 as an optional step, that is, in one implementation, the electronic device may directly perform S4033 to perform matching detection between the detection object and the reference image after acquiring the first vector data of the detection object and the second vector data of the reference image. Alternatively, in another implementation, the electronic device may perform S4031 and S4032 after acquiring the first vector data of the detection object and the second vector data of the reference image, and reduce the amount of matching detection between the detection object and the reference image performed by the electronic device by determining the candidate reference image.
[0206] S4033: The electronic device constructs a coordinate system using the first vector data of the detection object as a reference, and maps the second vector data of the candidate reference image into the coordinate system.
[0207] In this embodiment, the electronic device uses the first vector data of the detected object as a reference to construct a coordinate system. In one implementation, the electronic device can use any marking point included in the first vector data as the origin of the coordinate system to construct a two-dimensional coordinate system. For example, Fig.10 An example of constructing a coordinate system with the first coordinate in the coordinate sequence of the first vector data of the detection object 1 as the origin of the coordinate system is given in S4033.
[0208] After constructing the two-dimensional coordinate system, the electronic device can establish a first mapping relationship between any marker point included in the second vector data of the candidate reference image and the marker point of the first vector data of the detection object, thereby obtaining a mapping relationship between each marker point in the second vector data and the corresponding marker point in the first vector data. Exemplarily, the electronic device can establish a first mapping relationship between the first coordinate in the coordinate sequence of the second vector data of the candidate reference image and the first coordinate in the coordinate sequence of the first vector data of the detection object (that is, the origin of the coordinate system). Based on the coordinate values of each coordinate point, a mapping relationship between each marker point in the second vector data and the corresponding marker point in the first vector data is formed. For reference, Fig.10A schematic diagram of mapping the first vector data of the detection image and the second vector data of the candidate reference image given in S4033 to the same coordinate system. Alternatively, the electronic device may also establish a first mapping relationship between the i-th coordinate in the coordinate sequence of the second vector data of the candidate reference image and the i-th coordinate (i.e., the origin of the coordinate system) corresponding to the coordinate sequence of the first vector data of the detection object. Wherein, i is a natural number greater than 0.
[0209] It is understandable that when the second vector data of the candidate reference image is mapped to the coordinate system, a marker point in the first vector data and a marker point in the second vector data indicated by the first mapping relationship have matched. Fig.10 In S4033, the first coordinate of the first vector data matches the first coordinate of the second vector data.
[0210] The electronic device needs to determine whether the remaining marked points (same coordinates) of the first vector data match the remaining marked points (same coordinates) of the second vector data, so as to perform consistency detection between the candidate reference image and the detection object.
[0211] S4034. The electronic device traverses the second marking points in the second vector data of the candidate reference image, and matches each second marking point with the first marking point in the first vector data of the detection object.
[0212] In this embodiment, the detection requirement information corresponding to the image to be detected specifies the required range of rotation angle and size corresponding to the detection object / reference image. The electronic device matches and identifies each marking point in the first vector data and the second vector data within the required range of rotation angle and size.
[0213] If the angle and size are within the required range, and if all the second marking points match the first marking points, execute S4036, that is, perform the next step of consistency detection; if the angle and size are within the required range, and all the second marking points do not match the first marking points, execute S4035.
[0214] The second marking points of the second vector data are all marking points in the second vector data except the marking points indicated by the first mapping relationship. If the first mapping relationship indicates the mapping relationship between the first marking point of the first vector data and the first marking point of the second vector data, then the second marking points of the second vector data are all marking points in the second vector data except the first marking point. The first marking points of the first vector data are also all marking points except the marking points indicated by the first mapping relationship.
[0215] All second marker points match the first marker points, which means that first marker points with the same coordinates as the second marker points can be found in the first vector data, that is, each first marker point in the first vector data matches each second marker point in the second vector data, and the shape formed by the coordinates of each marker point in the first vector data is the same as the shape formed by the coordinates of each marker point in the second vector data. In this case, the consistency of other attribute information of the first vector data and the second vector data can be checked. For example, the consistency of other attribute information such as color can be checked.
[0216] If a second marking point does not match, traverse the next second marking point, and if all second marking points do not match, execute S4035. Each second marking point does not match the first marking point, that is, a first marking point consistent with the coordinates of each second marking point cannot be found in the first vector data. This is because there may be an angle or size deviation between the first vector data and the second vector data in the coordinate system. In this case, the electronic device can calculate the position deviation between the first vector data and the second vector data, and adjust the angle or size of the first vector data and the second vector data based on the position deviation, so as to match the marking points according to the adjusted first vector data and the second vector data. Among them, the position deviation may include angle deviation and size deviation.
[0217] The electronic device adjusts the angle or size of the first vector data and the second vector data based on the position deviation, thereby matching the marking points according to the adjusted first vector data and the second vector data, which can be achieved in a variety of feasible ways.
[0218] For example, in a feasible implementation method, the electronic device may first perform a first coordinate transformation based on an angle deviation. If there is at least one third marking point among the third coordinate points contained in the second vector data after the first coordinate transformation that does not match the first marking point, the electronic device may reduce or enlarge the second vector data based on the size deviation (second coordinate transformation), thereby matching each marking point of the second vector data after the second coordinate transformation.
[0219] Specifically, the electronic device may first perform an angle rotation (first coordinate transformation) on the second vector data based on the angle deviation, thereby matching each marker point of the second vector data after the first coordinate transformation. If the third coordinate point included in the second vector data after the first coordinate transformation matches the first marker point, the consistency check of other attribute information is performed on the first vector data and the second vector data (execution S4037).
[0220] If at least one third marking point does not match the first marking point among the third coordinate points included in the second vector data after the first coordinate transformation, the electronic device can reduce or enlarge the second vector data based on the size deviation (second coordinate transformation), so as to match the marking points of the second vector data after the second coordinate transformation. If the fourth coordinate point included in the second vector data after the second coordinate transformation matches the first marking point, the consistency of other attribute information of the first vector data and the second vector data is checked (execute S4037). If at least one fourth marking point does not match the first marking point among the fourth coordinate points included in the second vector data after the second coordinate transformation, if there are other candidate reference images that have not been checked for consistency, the consistency check of the first vector data of the detection object is re-performed based on the second vector data of the next candidate reference image (return to execute S4031).
[0221] For example, in another feasible implementation method, the electronic device may first perform a second coordinate transformation based on size deviation. If there is at least one fourth marking point in the fourth coordinate points contained in the second vector data after the second coordinate transformation that does not match the first marking point, the electronic device may perform an angle rotation (first coordinate transformation) on the second vector data based on the angle deviation, thereby matching each marking point of the second vector data after the first coordinate transformation.
[0222] Specifically, the order in which the electronic device performs the first coordinate transformation based on the angle deviation and the second coordinate transformation based on the size deviation is not limited. The electronic device may first reduce or enlarge the second vector data based on the size deviation (second coordinate transformation), thereby matching each marking point of the second vector data after the second coordinate transformation. If the fourth coordinate point contained in the second vector data after the second coordinate transformation matches the first marking point, the consistency of other attribute information of the first vector data and the second vector data is checked (execution S4037).
[0223] If at least one fourth marking point among the fourth coordinate points included in the second vector data after the second coordinate transformation does not match the first marking point, the electronic device can perform angle rotation (first coordinate transformation) on the second vector data based on the angle deviation, thereby matching the marking points based on the second vector data after the first coordinate transformation. If the third coordinate points included in the second vector data after the first coordinate transformation match the first marking point, the consistency check of other attribute information is performed on the first vector data and the second vector data (execution S4037).
[0224] If there is at least one third marking point in the third coordinate points contained in the second vector data after the first coordinate transformation that does not match the first marking point, and if there are other candidate reference images that have not been checked for consistency, then based on the second vector data of the next candidate reference image, the consistency check of the first vector data of the detection object is re-performed (return to execute S4031).
[0225] That is, the order in which the electronic device performs the first coordinate transformation based on the angle deviation and the second coordinate transformation based on the size deviation is not limited.
[0226] In this embodiment, an example is taken in which the first coordinate transformation based on the angle deviation is performed first, and then the second coordinate transformation based on the size deviation is performed.
[0227] S4035. The electronic device calculates the angle deviation based on the first vector data and the second vector data, performs a first coordinate transformation on the second vector data, and re-traverses and matches the first coordinate point based on a third coordinate point included in the second vector data after the first coordinate transformation.
[0228] The electronic device may calculate the angle deviation between the second vector data and the first vector data based on the coordinates of at least two marking points in the second vector data and the coordinates of the corresponding marking points in the first vector data.
[0229] For example, Fig.11 A schematic diagram for calculating position deviation is given.
[0230] in, Fig.11 (a) shows a schematic diagram of calculating the angle deviation. Fig.11 (a), the reference image is line segment AB, where the coordinates of the starting point A of line segment AB are (x0, y0), and the coordinates of the end point B are (x1, y1); the detection object is line segment CD, where the coordinates of the starting point C of line segment CD are (x0, y0), and the coordinates of the end point D are (x3, y3). The second vector data of line segment AB includes marked points A and B, and the first vector data of line segment CD includes marked points C and D. Among them, A of the second vector data coincides with C of the first vector data (first mapping relationship).
[0231] When the marking point D does not match the marking point B, the angle deviation between the first vector data and the second vector data is calculated, and based on the angle deviation, the second vector data is angularly rotated to achieve the first coordinate transformation of the second vector data.
[0232] The process of calculating the angle deviation α can be expressed as the following formula 1:
[0233] Formula (I).
[0234] After the electronic device calculates the rotation angle α, if the rotation angle α is within the rotation angle range required by the detection requirement information, the electronic device performs the first coordinate transformation based on the rotation angle α. If the rotation angle α is not within the rotation angle range required by the detection requirement information, the electronic device calculates the size deviation and performs consistency detection based on the scaled second vector data (execute S4036).
[0235] The electronic device can rotate the second vector data by an angle α in the coordinate system so as to eliminate the angle deviation between the second vector data and the first vector data. After eliminating the angle deviation, each third marking point in the second vector data after the first coordinate transformation is matched with each first marking point in the first vector data, thereby obtaining the marking point matching result between the first vector data and the second vector data.
[0236] in, Fig.10 A schematic diagram of the rotation process is given in S4035. The electronic device calculates the angle deviation based on the first vector data of the detection object 1 and the second vector data of the candidate reference image, and rotates the position of the second vector data in the coordinate system based on the angle deviation to obtain the second vector data after the first coordinate is transformed.
[0237] If the third coordinate point included in the second vector data after the first coordinate transformation matches the first marking point, a consistency check of other attribute information is performed on the first vector data and the second vector data (execution S4037 ).
[0238] If the third coordinate point included in the second vector data after the first coordinate transformation does not match the first marking point, the electronic device calculates the size deviation and performs consistency detection based on the scaled second vector data (execute S4036).
[0239] S4036: The electronic device calculates a size deviation based on the first vector data and the second vector data, performs a second coordinate transformation on the second vector data, and re-traverses and matches the first coordinate point based on a fourth coordinate point included in the second vector data after the second coordinate transformation.
[0240] The electronic device may calculate the size deviation between the second vector data and the first vector data based on the coordinates of at least two marking points in the second vector data and the coordinates of the corresponding marking points in the first vector data.
[0241] For example, Fig.11 A schematic diagram for calculating position deviation is given.
[0242] in, Fig.11 (b) shows a schematic diagram of calculating the size deviation. Fig.11 (b), the reference image line segment A1B1 should coincide with the detection object line segment C1D1 after being rotated by an angle α. For ease of explanation, line segment A1B1 and line segment C1D1 are shown separately here. In fact, point A1 should coincide with point C1.
[0243] The reference image is line segment A1B1 (line segment length is a), where the coordinates of the starting point A1 of line segment A1B1 are (x0, y0), and the coordinates of the end point B1 are (x4, y4); the detection object is line segment C1D1 (line segment length is b), where the coordinates of the starting point C1 of line segment C1D1 are (x0, y0), and the coordinates of the end point D1 are (x5, y5). The second vector data of line segment A1B1 includes marker points A1 and B1, and the first vector data of line segment C1D1 includes marker points C1 and D1. Among them, A1 of the second vector data coincides and matches C1 of the first vector data (first mapping relationship).
[0244] When the marking point D1 does not match the marking point B1, the size deviation between the first vector data and the second vector data is calculated, and based on the size deviation, the second vector data is reduced or enlarged to achieve the second coordinate transformation of the second vector data.
[0245] The process of calculating the size deviation β can be expressed as the following formula 2:
[0246] Formula (II).
[0247] The length a of the line segment A1B1 can be calculated based on the coordinates of A1 and B1 and the distance formula between the two points; the length b of the line segment C1D1 can be calculated based on the coordinates of C1 and D1 and the distance formula between the two points.
[0248] For example, the length a of line segment A1B1 can be calculated using the following formula:
[0249] Formula (III).
[0250] For example, the length b of line segment C1D1 can be calculated by the following formula 4:
[0251] Formula (IV).
[0252] After the electronic device calculates the size deviation β, if the size deviation β is within the size range required by the detection requirement information, the electronic device performs the second coordinate transformation based on the size deviation β. If the size deviation β is not within the rotation angle range required by the detection requirement information, the electronic device can determine that the consistency detection result of the detection object is a detection failure.
[0253] The electronic device can reduce or enlarge the second vector data by β in the coordinate system so as to eliminate the size deviation between the second vector data and the first vector data. After eliminating the size deviation, each fourth marking point in the second vector data after the second coordinate transformation is matched with each first marking point in the first vector data, thereby obtaining the marking point matching result between the first vector data and the second vector data.
[0254] in, Fig.10 A schematic diagram of the reduction process is given in S4036. The electronic device calculates the size deviation based on the first vector data of the detection object 1 and the second vector data of the candidate reference image, and based on the size deviation, reduces the second vector data to obtain the second vector data after the second coordinate is transformed.
[0255] If the fourth coordinate point included in the second vector data after the second coordinate transformation matches the first marking point, a consistency check of other attribute information is performed on the first vector data and the second vector data (execution S4037 ).
[0256] If the fourth coordinate point contained in the second vector data after the second coordinate transformation does not match the first marking point, and if there are other candidate reference images that have not been checked for consistency, a consistency check is performed on the first vector data of the detection object based on the second vector data of the next candidate reference image.
[0257] If all candidate reference images have been subjected to consistency detection, it is confirmed that there is no image consistent with the detection object among the candidate reference images, and the consistency detection result of the detection object is determined to be a detection failure.
[0258] S4037: The electronic device determines whether other attribute information of the first vector data is consistent with that of the second vector data.
[0259] Among them, other attribute information may include color. The electronic device may obtain color information corresponding to the first vector data, and color information corresponding to the second vector data. Among them, the color information is the color information corresponding to each marking point. Specifically, the color information includes the value of the color channel corresponding to the marking point. For example, the color information of marking point 1 includes the value of the red channel, the value of the blue channel, and the value of the green channel of marking point 1. Alternatively, the color information may also include the grayscale information corresponding to the marking point. For example, the color information of marking point 1 includes the grayscale value of marking point 1.
[0260] If the color information of each marking point in the second vector data is consistent with the color information of the corresponding marking point in the first vector data, the consistency detection result of the detection object is determined to be a successful detection; if the color information of at least one marking point in the second vector data is inconsistent with the color information of the corresponding marking point in the first vector data, the consistency detection result of the detection object is determined to be a failed detection.
[0261] This embodiment provides an object detection method, which can match the first vector data of the detection object and the second vector data corresponding to the detection object (standardized vector data corresponding to the detection object) from the dimension of the vector data to realize the recognition and detection of the detection object. When the first vector data matches the second vector data, it is considered that the detection object in the image to be detected meets the specification. When the first vector data does not match the second vector data, it is considered that the detection object in the image to be detected does not meet the specification. The comparison between vector data is essentially a parameter comparison of the function, which reduces the problem of the original data accuracy being reduced due to the distortion of the original data when the raster data is compared in the rotation and scaling scenes. The vector data object can be decomposed into coordinate points and vector parameters. Whether scaling or rotation is essentially a parameter transformation of the polyline or Bezier curve function, theoretically, no distortion problem will occur. Based on the consistency matching of vector data (detection of compliance with the specification), the validity of the detection result can be guaranteed, and the detection accuracy of the detection object in the image to be detected can be improved.
[0262] Fig.12 Another possible structural diagram of the electronic device involved in the above embodiment is shown. Fig.12 The electronic device 1200 shown includes a processing module 1201 , a communication module 1202 and a storage module 1203 .
[0263] The processing module 1201 may be a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The processor may include an application processor and a baseband processor. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0264] For example, the processing module 1201 may be as follows Figure 3 The processor 301 shown; the communication module 1202 can be as follows Figure 3 The communication interface 303 shown in FIG. 1 and the storage module 1203 may be as follows: Figure 3 The electronic device provided in the embodiment of the present application can be Figure 3 An electronic device 100 is shown.
[0265] The present application also provides a chip system (eg, a system on a chip (SoC)), such as Fig.13 As shown, the chip system includes at least one processor 1301 and at least one interface circuit 1302. The processor 1301 and the interface circuit 1302 can be interconnected through lines. For example, the interface circuit 1302 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 1302 can be used to send signals to other devices (such as a processor 1301 or a camera of an electronic device). Exemplarily, the interface circuit 1302 can read instructions stored in the memory and send the instructions to the processor 1301. When the instructions are executed by the processor 1301, the electronic device can execute the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiments of the present application.
[0266] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed by the electronic device 100 in the above-mentioned method embodiment.
[0267] The embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the functions or steps executed by the electronic device 100 in the above method embodiment. For example, the computer may be the above electronic device 100.
[0268] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0269] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0270] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0271] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0272] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0273] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. An object detection method, characterized in that: The method comprises: The electronic device acquires an image to be detected; the image to be detected includes at least one detection object; The electronic device acquires a reference image corresponding to each of the detection objects in the image to be detected; the reference image is a standard image corresponding to the detection object; For each detection object in the image to be detected, the electronic device obtains a first number of marking points included in first vector data of the detection object; The electronic device acquires, based on a second number of marking points included in the second vector data of the reference image, candidate reference images whose second number is the same as the first number; The electronic device constructs a coordinate system with reference to the first vector data of the detection object, maps the second vector data of the candidate reference image to the coordinate system, performs matching detection between the detection object and the candidate reference image, and obtains a detection result of the detection object; Among them, the first vector data is extracted from the vector map of the detection object, and the first vector data includes a coordinate sequence of marked points in the detection object; the second vector data is extracted from the vector map of the reference image, and the second vector data includes a coordinate sequence of marked points in the reference image; the detection result is used to characterize whether the detection of the detection object is qualified or unqualified.
2. The method according to claim 1, characterized in that The mapping the second vector data of the candidate reference image to the coordinate system, performing matching detection between the detection object and the candidate reference image, and obtaining a detection result of the detection object includes: The electronic device acquires a first marked point in a coordinate sequence of second vector data of the candidate reference image; The electronic device maps the target marking point of the coordinate sequence of the second vector data to the coordinate position of the corresponding target marking point in the coordinate sequence of the first vector data of the detection object, so that the target marking point of the coordinate sequence of the second vector data coincides with the coordinate position of the target marking point in the coordinate sequence of the first vector data; the target marking point is the first marking point in the coordinate sequence, or the target marking point is any marking point in the coordinate sequence; The electronic device traverses the second marking points in the coordinate sequence of the second vector data of the candidate reference image, matches and detects each of the second marking points with the first marking points in the coordinate sequence of the first vector data of the detection object, and obtains a detection result of the detection object; The second marking points are the remaining marking points in the coordinate sequence of the second vector data except the target marking point; and the first marking points are the remaining marking points in the coordinate sequence of the first vector data except the target marking point.
3. The method according to claim 2, characterized in that The electronic device traverses the second marking points in the coordinate sequence of the second vector data of the candidate reference image, matches and detects each of the second marking points with the first marking points in the coordinate sequence of the first vector data of the detection object, and obtains the detection result of the detection object, including: The electronic device matches and detects each of the second marking points with each of the first marking points, and if all the second marking points have matching first marking points, performs attribute information detection on the detection object to obtain a detection result of the detection object; the second marking point having a matching first marking point includes that the coordinate position of the second marking point is consistent with the coordinate position of the matching first marking point; If at least one of the second marking points does not have a matching first marking point, the electronic device performs coordinate transformation on the second vector data, traverses the marking points in the coordinate sequence of the second vector data after the coordinate transformation, matches and detects each marking point in the coordinate sequence of the second vector data after the coordinate transformation with the first marking point in the coordinate sequence of the first vector data of the detection object, and obtains the detection result of the detection object.
4. The method according to claim 3, characterized in that The electronic device performs coordinate transformation on the second vector data, traverses the marked points in the coordinate sequence of the second vector data after the coordinate transformation, matches and detects the marked points in the coordinate sequence of each of the second vector data after the coordinate transformation with the first marked point in the coordinate sequence of the first vector data of the detection object, and obtains the detection result of the detection object, including: The electronic device calculates an angle deviation between the first vector data and the second vector data according to the coordinate positions of at least two marking points in the coordinate sequence of the first vector data and the coordinate positions of at least two marking points in the coordinate sequence of the second vector data; The electronic device rotates the second vector data based on the angle deviation to obtain the second vector data after the first coordinate is transformed; The electronic device matches and detects each third marking point in the coordinate sequence of the second vector data after the first coordinates are converted with each first marking point, and if all the third marking points have matching first marking points, performs attribute information detection on the detection object to obtain a detection result of the detection object; If at least one of the third marking points does not have a matching first marking point, the electronic device calculates a size deviation between the second vector data after the first coordinates are transformed and the first vector data according to the coordinate positions of at least two of the third marking points and the corresponding coordinate positions of the first marking points; The electronic device scales the second vector data after the first coordinate transformation based on the size deviation to obtain the second vector data after the second coordinate transformation; The electronic device matches and detects each fourth marking point in the coordinate sequence of the second vector data after the second coordinate is converted with each first marking point, and if all the fourth marking points have matching first marking points, performs attribute information detection on the detection object to obtain a detection result of the detection object; If at least one of the fourth marking points does not have a matching first marking point, the electronic device obtains the next candidate reference image and performs a matching detection between the detection object and the next candidate reference image; if the next candidate reference image does not exist, the detection result of the detection object is a failed detection.
5. The method according to claim 4, characterized in that Detection requirement information corresponding to the candidate reference image, wherein the detection requirement information specifies a size range and a rotation angle range of the candidate reference image; The electronic device rotates the second vector data based on the angle deviation to obtain the second vector data after the first coordinate is transformed, including: Within the rotation angle range, the electronic device rotates the second vector data based on the angle deviation to obtain the second vector data after the first coordinates are transformed; The electronic device scales the second vector data after the first coordinate transformation based on the size deviation to obtain the second vector data after the second coordinate transformation, including: Within the size range, the electronic device scales the second vector data after the first coordinate transformation based on the size deviation to obtain the second vector data after the second coordinate transformation.
6. The method according to any one of claims 3 to 5, characterized in that: The attribute information at least includes color information, the first vector data includes first color information, the second vector data includes second color information, and the performing attribute information detection on the detection object to obtain the detection result of the detection object includes: If the first color information is consistent with the second color information, the detection result of the detection object is qualified; If the first color information is inconsistent with the second color information, the detection result of the detection object is unqualified.
7. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The electronic device acquires first vector data of the detection object according to the vector diagram of the detection object by using a vector data extraction tool; The electronic device obtains the second vector data of the reference image according to the vector image of the reference image by using a vector data extraction tool.
8. The method according to any one of claims 1 to 5, characterized in that A database is deployed in the electronic device; the database pre-stores a reference image corresponding to the detection object contained in the image to be detected; The database also includes second vector data corresponding to the reference image and related information of the reference image; the related information of the reference image includes at least the encoding of the reference image and the regional information of the reference image, and the regional information includes detection requirement information of the reference image in the region to which it belongs, wherein the detection requirement information includes requirements for the color, rotation angle and size of the reference image.
9. The method according to claim 8, characterized in that The electronic device acquires a reference image corresponding to each of the detection objects in the image to be detected, including: The electronic device searches the database for the reference image whose code matches the code corresponding to the detection object based on the code corresponding to the detection object in the image to be detected.
10. The method according to any one of claims 1 to 5, characterized in that When the image to be detected is a product design drawing, the detection object includes a certification mark, and the reference image is a complete image corresponding to the certification mark; when the image to be detected is a circuit diagram of a circuit board, the detection object includes components, and the reference image is a complete image corresponding to the components, and the components include at least one or more of a power supply, a resistor, an inductor, and a capacitor.
11. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The electronic device displays the detection result of the detection object on a display interface.
12. An object detection system, characterized in that: The object detection system includes a detection module and a database; the database pre-stores reference images corresponding to a variety of detection objects; The detection module is used to obtain an image to be detected, wherein the image to be detected includes at least one detection object; The detection module is used to obtain a reference image corresponding to each detection object in the image to be detected from the database; the reference image is a standard image corresponding to the detection object; The detection module is used to obtain, for each detection object in the image to be detected, a first number of marking points included in the first vector data of the detection object, and based on the second number of marking points included in the second vector data of the reference image, obtain a second number of candidate reference images that is the same as the first number; The detection module is used to construct a coordinate system with reference to the first vector data of the detection object, map the second vector data of the candidate reference image to the coordinate system, perform matching detection between the detection object and the candidate reference image, and obtain a detection result of the detection object; Among them, the first vector data is extracted from the vector map of the detection object, and the first vector data includes a coordinate sequence of marked points in the detection object; the second vector data is extracted from the vector map of the reference image, and the second vector data includes a coordinate sequence of marked points in the reference image; the detection result is used to characterize whether the detection of the detection object is qualified or unqualified.
13. The system according to claim 12, characterized in that The detection module is further used to display the detection result of the detected object on the display interface of the object detection system.
14. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 11.
15. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
16. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Mainboard component appearance defect detection method, system, equipment and medium
CN114240939A