Method, apparatus and storage medium for positioning a target object in a to-be-detected image
By utilizing the center of gravity information and the location information of markers in the template image, the target object in the image to be detected is automatically located, solving the problem of uncertain position of the target object in the image to be detected and achieving higher positioning accuracy and intelligence.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CONTEMPORARY AMPEREX TECHNOLOGY CO LTD
- Filing Date
- 2023-04-28
- Publication Date
- 2026-05-15
AI Technical Summary
Due to the instability of the product to be inspected, the positional and structural information of the product to be inspected varies in different images, making it difficult to accurately locate the target object in the image to be inspected.
The positional transformation information of the target object is determined by the first and second centroid information. Combined with the positional information of the target object's markers in the template image, the target object in the image to be detected is automatically located, reducing manual point sampling errors and improving positioning accuracy.
It improves the accuracy and intelligence of target object positioning in the image to be detected, reduces the error caused by manual point selection, and enhances the accuracy of position change information.
Smart Images

Figure CN119698635B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image detection technology, and in particular to a method, apparatus and storage medium for locating a target object in an image to be detected. Background Technology
[0002] With the development of industrial and image processing technologies, more and more factories are acquiring images of products to obtain information about the products to be inspected. However, due to the instability of the products to be inspected, the positional and structural information of the products to be inspected varies in different images, making it difficult to accurately locate the products to be inspected in the images. Summary of the Invention
[0003] This application provides a method, apparatus, and storage medium for locating target objects in an image to be detected, which can accurately locate target objects in the image to be detected.
[0004] In a first aspect, a method for locating a target object in an image to be detected is provided. The method includes: determining position transformation information of the target object based on first centroid information and second centroid information, wherein the first centroid information includes the first contour centroid coordinates of the target object in a template image, and the second centroid information includes the second contour centroid coordinates of the target object in the image to be detected; the position transformation information is the position transformation information of the target object in the image to be detected relative to the target object in the template image; and locating the target object in the image to be detected based on the position transformation information and the position information of a marker on the target object in the template image.
[0005] In the embodiments of this application, the position change information of the target object is determined by the first centroid information and the second centroid information. It is not necessary to manually select points in the template image and the image to be detected to determine the position change information of the target object. This not only increases the intelligence of determining the position change information of the target object, but also reduces the error caused by manual point selection, thereby improving the accuracy of the position change information and thus improving the accuracy of locating the target object in the image to be detected.
[0006] In some possible implementations, the marker is a specific line segment on the outline of the target object. Locating the target object in the image to be detected based on position transformation information and the position information of the marker on the target object in the template image includes: determining a preset target outline in the image to be detected based on the position transformation information and the position information of the specific line segment of the target object in the template image; and determining the target outline in the image to be detected based on the detection area containing the preset target outline in the image to be detected, so as to locate the target object in the image to be detected.
[0007] In the above embodiments, since there are differences between the position and structural information of the target object in the image to be detected and the position and structural information of the target object in the template image, a preset target contour that is close to the real contour of the target object in the image to be detected can be obtained in advance based on the position transformation information and the position information of the specific line segments of the target object in the template image; and a more accurate target contour can be determined based on the detection area containing the preset target contour, which can further improve the accuracy of locating the target object in the image to be detected.
[0008] In some possible implementations, the target contour is determined based on the relationship between the gradient value in the region to be detected and a preset threshold. This allows for convenient determination of the target contour.
[0009] In some possible implementations, the region to be detected includes multiple sub-regions to be detected; determining the target contour based on the relationship between gradient values in the region to be detected and a preset threshold includes: determining multiple sub-regions to be detected arranged adjacent to each other along the preset target contour based on the preset target contour; and determining the target contour based on the relationship between gradient values in the multiple sub-regions to be detected and a preset threshold.
[0010] In the above embodiments, the gradient value of the detection area can be determined more accurately by using multiple adjacent sub-regions to be detected, thereby enabling more precise determination of the target contour.
[0011] In some possible implementations, the method for detecting target points in the image further includes: acquiring first contour information of the target object in a template image; and determining the centroid coordinates of the first contour based on the first contour information. Thus, since the first contour information includes the contour coordinates of the target object in the template image, the centroid coordinates of the first contour can be accurately determined.
[0012] In some possible implementations, the target object includes a first target object and / or a second target object; the first contour information includes first contour sub-information and / or second contour sub-information; the first contour centroid coordinates include first contour sub-centroid coordinates and / or second contour sub-centroid coordinates; determining the first contour centroid coordinates based on the first contour information includes: determining a first width sub-information and a first length sub-information of the contour of the first target object in the template image based on the first contour sub-information; determining the vertex coordinates of a first enclosing sub-frame based on the first width sub-information and the first length sub-information; determining the first contour sub-centroid coordinates based on the vertex coordinates of the first enclosing sub-frame; and / or determining a second width sub-information and a second length sub-information of the contour of the second target object in the template image based on the second contour sub-information; determining the vertex coordinates of a second enclosing sub-frame based on the second width sub-information and the second length sub-information; and determining the second contour sub-centroid coordinates based on the vertex coordinates of the second enclosing sub-frame.
[0013] In the above embodiments, since the first outer sub-frame is determined based on the first width sub-information and the first length sub-information of the contour of the first target object in the template image, the first outer sub-frame can include all the coordinates of the contour of the first target object in the template image. Therefore, determining the first contour sub-centroid coordinates based on the vertex coordinates of the first outer sub-frame can more accurately determine the first contour sub-centroid coordinates. Similarly, the second contour sub-centroid coordinates can also be determined more accurately.
[0014] In some possible implementations, the method for detecting target points in the image further includes: acquiring second contour information of the target object in the image; and determining the centroid coordinates of the second contour based on the second contour information. Thus, since the second contour information includes the contour coordinates of the target object in the image, the centroid coordinates of the second contour can be accurately determined.
[0015] In some possible implementations, the target object includes a first target object and / or a second target object, and the second contour information includes a third contour sub-information and / or a fourth contour sub-information. Obtaining the second contour information of the target object in the image to be detected includes: determining at least one image matching block based on the first target object in the template image, the image matching block including at least a portion of the first target object; obtaining the third contour sub-information based on the matching degree between the image matching block and the image to be detected; and / or determining at least one image matching block based on the second target object in the template image, the image matching block including at least a portion of the second target object; and obtaining the fourth contour sub-information based on the matching degree between the image matching block and the image to be detected. Thus, since the image matching block contains information about the target object in the template image, the second contour information can be directly determined based on the image matching block of the template image without introducing other images, making the determination of the second contour information more convenient.
[0016] In some possible implementations, the second contour centroid coordinates include third contour sub-centroid coordinates and / or, fourth contour sub-centroid coordinates. Determining the second contour centroid coordinates based on the second contour information includes: determining the third width sub-information and the third length sub-information of the contour of the first target object in the image to be detected based on the third contour sub-information; determining the vertex coordinates of the third bounding box based on the third width sub-information and the second length sub-information; and determining the third contour centroid sub-coordinates based on the vertex coordinates of the third bounding box.
[0017] In the above embodiments, since the third outer sub-frame is determined based on the third width sub-information and the third length sub-information of the contour of the first target object in the image to be detected, the third outer sub-frame can include all the coordinates of the contour of the first target object in the image to be detected. Therefore, determining the centroid coordinates of the third contour sub-frame based on the vertex coordinates of the third outer sub-frame can more accurately determine the centroid coordinates of the third contour sub-frame; similarly, the centroid coordinates of the fourth contour sub-frame can also be determined more accurately.
[0018] In some possible implementations, the method for detecting target points in an image further includes: acquiring first contour information of the target object in a template image; and determining the position information of a specific line segment of the target object in the template image based on the first contour information and the inflection point information of the target object in the template image.
[0019] In the above embodiments, since the area near the inflection point of the target object is prone to deformation or information loss, the position information of the specific line segment determined based on the first contour information and the inflection point information of the target object in the template image can provide more accurate contour information for the image to be detected, which is beneficial for locating the target object in the image to be detected.
[0020] In some possible implementations, the position transformation information includes translation information and / or rotation information. Determining the position transformation information of the target object based on the first and second center of gravity information includes determining the translation information and / or rotation information based on the coordinates of the first and second contour centers of gravity. Thus, by determining the translation information and / or rotation information of the target object using the first and second center of gravity information, the translation and / or rotation of the target object can be determined more accurately, thereby locating the target object more precisely.
[0021] In some possible implementations, the translation information includes first translation information and second translation information, and the rotation information includes first rotation information and second rotation information. Determining the translation information and / or rotation information based on the first and second contour centroid coordinates includes: determining the first translation information and / or the first rotation information based on the first and third contour sub-centroid coordinates; and / or, determining the second translation information and / or the second rotation information based on the second and fourth contour sub-centroid coordinates. This allows for the simultaneous determination of the translation information of multiple targets in the detected image, improving the efficiency of image processing.
[0022] In some possible implementations, the first target is a cover plate, and the second target is an adapter piece. The adapter piece is attached to the cover plate, and the two overlap. In this way, the positional transformation information of the cover plate and / or the adapter piece can be determined using the first and second center of gravity information. This eliminates the need for manual point selection in the template image and the image to be detected, increasing the intelligence of determining the positional transformation information and reducing errors caused by manual point selection. This improves the accuracy of the positional transformation information and, consequently, the accuracy of locating the cover plate and / or the adapter piece in the image to be detected.
[0023] In some possible implementations, the outline of the target object in the image to be detected has an occluded area.
[0024] In the above embodiments, when there is an occluded area in the outline of the target object in the image to be detected, more complete outline information of the target object can be obtained in the image to be detected by using the position information and position transformation information of specific line segments of the target object in the template image, which is more conducive to locating the target object in the image to be detected.
[0025] In some possible implementations, the method for detecting target points in the image further includes: determining the matching degree between the contour of the target object in the image to be detected and the contour of the target object in the template image; and determining the second centroid information if the matching degree meets preset conditions. This way, when the difference between the contour of the target object in the image to be detected and the contour of the target object in the template image is too large, the determination of the second centroid coordinates and subsequent processing are no longer required, improving the efficiency of locating the target object in the image to be detected.
[0026] Secondly, an apparatus for locating a target object in an image to be detected is provided. The apparatus includes: a determining module, which is used to determine the position transformation information of the target object based on first centroid information and second centroid information, wherein the first centroid information includes the first contour centroid coordinates of the target object in a template image, and the second centroid information includes the second contour centroid coordinates of the target object in the image to be detected; the position transformation information is the position transformation information of the target object in the image to be detected relative to the target object in the template image; and a locating module, which is used to locate the target object in the image to be detected based on the position transformation information and the position information of a marker on the target object in the template image.
[0027] In some possible implementations, the marker is a specific line segment on the outline of the target object. The determination module is also used to determine the preset target outline in the image to be detected based on the position transformation information and the position information of the marker on the target object in the template image. The determination module is also used to determine the target outline in the image to be detected based on the detection area containing the preset target outline in the image to be detected, so as to locate the target object in the image to be detected.
[0028] In some possible implementations, the determining module is also used to determine the target contour based on the relationship between gradient values in the region to be detected and a preset threshold.
[0029] In some possible implementations, the region to be detected includes multiple sub-regions to be detected, and the determining module is further configured to determine multiple sub-regions to be detected that are arranged adjacent to each other along the preset target contour according to the preset target contour; the determining module is further configured to determine the target contour according to the relationship between the gradient values and preset thresholds within the multiple sub-regions to be detected.
[0030] In some possible implementations, the apparatus for locating a target object in an image to be detected further includes: an acquisition module for acquiring first contour information of the target object in a template image; and a determination module for determining the centroid coordinates of the first contour based on the first contour information.
[0031] In some possible implementations, the target object includes a first target object and / or a second target object; the first contour information includes first contour sub-information and / or second contour sub-information; the first contour centroid coordinates include first contour sub-centroid coordinates and / or second contour sub-centroid coordinates; the determining module is further configured to determine, based on the first contour sub-information, a first width sub-information and a first length sub-information of the contour of the first target object in the template image; the determining module is further configured to determine, based on the first width sub-information and the first length sub-information, the vertex coordinates of the first enclosing sub-frame; the determining module is further configured to determine, based on the vertex coordinates of the first enclosing sub-frame, the centroid coordinates of the first contour; and / or, the determining module is further configured to determine, based on the second contour sub-information, a second width sub-information and a second length sub-information of the contour of the second target object in the template image; the determining module is further configured to determine, based on the second width sub-information and the second length sub-information, the vertex coordinates of the second enclosing sub-frame; and the determining module is further configured to determine, based on the vertex coordinates of the second enclosing sub-frame, the centroid coordinates of the second contour.
[0032] In some possible implementations, the apparatus for locating a target object in an image to be detected further includes: an acquisition module further configured to acquire second contour information of the target object in the image to be detected; and a determination module further configured to determine the centroid coordinates of the second contour based on the second contour information.
[0033] In some possible implementations, the target object includes a first target object and / or a second target object, the second contour information includes a third contour sub-information and / or a fourth contour sub-information, the determining module is further configured to determine at least one image matching block based on the first target object in the template image, the image matching block including at least a portion of the first target object; the acquiring module is further configured to acquire the third contour sub-information based on the matching degree between the image matching block and the image to be detected;
[0034] And / or, the determining module is further configured to determine at least one image matching block based on the second target object in the template image, the image matching block including at least a portion of the region of the second target object; the acquiring module is further configured to acquire fourth contour sub-information based on the matching degree between the image matching block and the image to be detected.
[0035] In some possible implementations, the second contour centroid coordinates include third contour sub-centroid coordinates, and / or, fourth contour sub-centroid coordinates. The determining module is further configured to determine, based on the second contour information, the third width sub-information and the third length sub-information of the contour of the first target object in the image to be detected. The determining module is further configured to determine the vertex coordinates of the third bounding box based on the third width sub-information and the third length sub-information. The determining module is further configured to determine the third contour centroid sub-coordinates based on the vertex coordinates of the third bounding box. And / or, the determining module is further configured to determine, based on the fourth contour sub-information, the fourth width sub-information and the fourth length sub-information of the contour of the second target object in the image to be detected. The determining module is further configured to determine the vertex coordinates of the fourth bounding box based on the fourth width sub-information and the fourth length sub-information. The determining module is further configured to determine the fourth contour centroid sub-coordinates based on the vertex coordinates of the fourth bounding box.
[0036] In some possible implementations, the apparatus for locating a target object in an image to be detected further includes: an acquisition module for acquiring first contour information of the target object in a template image; and a determination module for determining the position information of a specific line segment of the target object in the template image based on the first contour information and the inflection point information of the target object in the template image.
[0037] In some possible implementations, the position transformation information includes translation information and / or rotation information, and the determining module is further configured to determine the translation information and / or rotation information based on the centroid coordinates of the first profile and the centroid coordinates of the second profile.
[0038] In some possible implementations, the translation information includes first translation information and second translation information, and the rotation information includes first rotation information and second rotation information; the determining module is used to determine the first translation information and / or the first rotation information based on the first profile sub-centroid coordinates and the third profile sub-centroid coordinates; and / or, the determining module is used to determine the second translation information and / or the second rotation information based on the second profile sub-centroid coordinates and the fourth profile sub-centroid coordinates.
[0039] In some possible implementations, the first target is a cover plate, and the second target is an adapter piece attached to the cover plate, with the adapter piece and the cover plate having an overlapping area.
[0040] In some possible implementations, the outline of the target object in the image to be detected has an occluded area.
[0041] In some possible implementations, the determining module is further configured to determine the matching degree between the contour of the target object in the image to be detected and the contour of the target object in the template image; the determining module is further configured to determine the second centroid information if the matching degree meets the preset conditions.
[0042] Thirdly, an apparatus for locating a target object in an image to be detected is provided, comprising a processor and a memory, the memory for storing a program, and the processor for calling and running the program from the memory to perform the method for locating a target object in an image to be detected as described in the first aspect or any possible implementation thereof.
[0043] Fourthly, a computer-readable storage medium is provided, including a computer program that, when run on a computer, causes the computer to perform the method for locating a target in an image to be detected as described in the first aspect or any possible implementation thereof.
[0044] Fifthly, a computer program product containing instructions is provided, which, when executed by a computer, cause the computer to perform the method for locating a target object in an image to be detected as described in the first aspect or any possible implementation thereof. Attached Figure Description
[0045] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some implementation methods of this application. For those skilled in the art, other drawings can be obtained based on the drawings without creative effort.
[0046] Figure 1 This is a schematic diagram of the system architecture provided in this application;
[0047] Figure 2 This is a flowchart illustrating a method for locating a target object in an image to be detected, as disclosed in an embodiment of this application.
[0048] Figure 3 This is a schematic diagram of a template image disclosed in an embodiment of this application;
[0049] Figure 4 This is a schematic diagram of an image to be detected as disclosed in an embodiment of this application;
[0050] Figure 5 This is a schematic diagram of an image to be detected that includes a preset target contour, as disclosed in an embodiment of this application;
[0051] Figure 6 This is the embodiment disclosed in this application. Figure 5 A magnified view of a portion of region A3 in the middle;
[0052] Figure 7 This is a schematic diagram of the centroid of a first contour disclosed in an embodiment of this application;
[0053] Figure 8 This is a schematic structural block diagram of a device for locating a target object in an image to be detected, as disclosed in an embodiment of this application;
[0054] Figure 9 This is a schematic diagram of the hardware structure of a device for locating a target object in an image to be detected, according to an embodiment of this application. Detailed Implementation
[0055] The embodiments of this application will be described in further detail below with reference to the accompanying drawings and examples. The detailed description of the following embodiments and the accompanying drawings are used to illustrate the principles of this application by way of example, but should not be used to limit the scope of this application, that is, this application is not limited to the described embodiments.
[0056] The embodiments of this application are applicable to image processing systems, including but not limited to products based on infrared imaging. This image processing system can be applied to various intelligent manufacturing equipment with image processing devices, such as personal computers, computer workstations, smartphones, tablets, smart cameras, media consumption devices, wearable devices, set-top boxes, game consoles, augmented reality (AR) / virtual reality (VR) devices, vehicle terminals, etc. The embodiments disclosed in this application do not limit this application.
[0057] It should be understood that the specific examples in this document are only intended to help those skilled in the art better understand the embodiments of this application, and are not intended to limit the scope of the embodiments of this application.
[0058] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0059] It should also be understood that the various implementation methods described in this specification can be implemented individually or in combination, and the embodiments of this application are not limited in this respect.
[0060] Unless otherwise stated, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this application includes any and all combinations of one or more of the associated listed items.
[0061] Currently, with the development of industrial and image processing technologies, more and more factories are acquiring image information of products to obtain information about the products to be inspected. However, due to the instability of the products to be inspected, the positional and structural information of the products to be inspected varies in different images, making it difficult to accurately locate the products to be inspected in the images.
[0062] In some applications, a single testing step requires comprehensive testing of the product to be tested; in this case, the target object is the product to be tested. In other applications, a single testing step only requires testing the main components of the product to be tested; in this case, the target object is the main components of the product to be tested.
[0063] For example, the structures of different batches of products to be inspected may differ, leading to variations in the information about the item or its main components in different images. Alternatively, the positions of some components in the product may be variable, sometimes obscuring key components and resulting in the loss of some information about these components in the image. Thus, due to these differences in the positional and structural information of the target object in different images, it is difficult to accurately locate the target object within the images.
[0064] Based on the above considerations, in order to accurately locate the target object in the image to be detected, this application proposes a method for locating the target object in the image to be detected. The method determines the position transformation information of the target object in the image to be detected relative to the target object in the template image by using the centroid of the contours of multiple target objects, and locates the target object in the image to be detected based on the position transformation information of the target object and the specific line segments of the target object.
[0065] In this way, the positional transformation information of the target object can be determined by the first and second centroid information, eliminating the need to manually select points in the template image and the image to be detected to determine the positional transformation information of the target object. This not only increases the intelligence of determining the positional transformation information of the target object, but also reduces the error caused by manual point selection, thereby improving the accuracy of the positional transformation information and thus improving the accuracy of locating the target object in the image to be detected.
[0066] To better understand the solutions of the embodiments of this application, the following will first combine... Figure 1 A brief introduction to the possible application scenarios of the embodiments of this application is provided.
[0067] like Figure 1 As shown, this application embodiment provides a system architecture 100. In Figure 1 In this embodiment, the data acquisition device 160 is used to acquire annotation information and template images. For the method of detecting target objects in the image to be detected according to this application, the known annotation information is the first centroid information of the target object in the template image.
[0068] After collecting the annotation information and template images, the data acquisition device 160 stores these template images and annotation information into the database 130.
[0069] The aforementioned target model / rule 101 can be used to implement the method for locating target objects in an image to be detected according to the embodiments of this application. Furthermore, the target model / rule 101 can be applied to different systems or devices, such as those used in… Figure 1 The execution device 110 shown can be a terminal, such as a mobile phone, tablet computer, or laptop computer, or it can be a server or cloud service. Figure 1 In this embodiment, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with external devices. Users can input data to the I / O interface 112 through the client device 140. The input data may include the image to be detected input by the client device 140.
[0070] In some implementations, the client device 140 may be the same device as the execution device 110. For example, both the client device 140 and the execution device 110 may be terminal devices.
[0071] In other embodiments, the client device 140 may be a different device from the execution device 110. For example, the client device 140 may be a terminal device, while the execution device 110 may be a cloud device, a server, or other such device. The client device 140 may interact with the execution device 310 through a communication network of any communication mechanism / standard. The communication network may be a wide area network, a local area network, a point-to-point connection, or any combination thereof.
[0072] The calculation module 111 of the execution device 110 is used to process the input data (such as the image to be detected) received by the I / O interface 112. During the calculation and other related processing performed by the calculation module 111 of the execution device 110, the execution device 110 can call data, code, etc. in the data storage system 150 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 150.
[0073] Finally, the I / O interface 112 returns the processing results, such as the location results of the target object in the image to be detected, to the client device 140, thereby providing them to the user.
[0074] exist Figure 1In the scenario shown, the user can manually provide input data, which can be done through the interface provided by I / O interface 112. Alternatively, the client device 140 can automatically send input data to I / O interface 112. If user authorization is required for the client device 140 to automatically send input data, the user can set the corresponding permissions in the client device 140. The user can view the output results of the execution device 110 on the client device 140, which can be presented in various forms such as display, sound, or animation. The client device 140 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 112 as shown in the figure, using them as new template images and first center of gravity information, and storing them in the database 130. Alternatively, the data can be collected directly from the I / O interface 112 without going through the client device 140, using the input data and output results of the input I / O interface 112 as shown in the figure, and storing them in the database 130 as new template images and first center of gravity information.
[0075] It is worth noting that, Figure 1 This is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the diagram do not constitute any limitation. For example, in Figure 1 In this context, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed within the execution device 110.
[0076] Below, as Figure 2 As shown, the main process of the method for locating target objects in an image to be detected according to an embodiment of this application is described.
[0077] 210. Determine the position transformation information of the target object based on the first centroid information and the second centroid information, wherein the first centroid information includes the first contour centroid coordinates of the target object in the template image, and the second centroid information includes the second contour centroid coordinates of the target object in the image to be detected; the position transformation information is the position transformation information of the target object in the image to be detected relative to the target object in the template image.
[0078] It should be understood that the target object can be a major component with poor consistency in the product to be inspected. Furthermore, due to the poor consistency of the major component, the contour of the component will differ in images of different inspected products. The first centroid information can include the first contour centroid coordinates of the target object in multiple template images; the second centroid information can include the second contour centroid coordinates of the target object in multiple images to be inspected. Moreover, the first and second contour centroid coordinates can be two-dimensional coordinates including horizontal and vertical coordinates, or three-dimensional coordinates including horizontal, vertical, and angles. The angle can be the angle between multiple first contour centroids or the angle between multiple second contour centroids.
[0079] For example, Figure 3 A template image of an embodiment of this application is shown. Figure 4 An image to be detected according to an embodiment of this application is shown. For example... Figures 3 to 4 As shown, the first contour centroid coordinates can be obtained from the complete contour of the target object 20, or from the centroid coordinates of the first part of the contour 28 of the target object 20. The second contour centroid coordinates can be from the centroid coordinates of the second part of the contour 30 of the target object 20. It should be noted that the first part of the contour 28 and the second part of the contour 30 are located at essentially the same position on the target object 20. However, the first part of the contour 28 is closer to the true contour of the target object 20 than the second part of the contour 30.
[0080] 220. Locate the target object 20 in the image to be detected 3 based on the position transformation information and the position information of the marker on the target object 20 in the template image 2.
[0081] The markers on the target object 20 in the template image 2 can be relatively fixed shapes and positions on the target object 20 in the template image 2, such as rectangles, circles, etc., or they can be relatively fixed lines on the target object 20.
[0082] Based on the position transformation information and the position information of the marker on the target object 20 in the template image 2, the position information of the target object 20 in the image to be detected 3 can be determined, and the target object 20 can be located in the image to be detected 3 based on the position information.
[0083] In the embodiments of this application, the position change information of the target object 20 is determined by the first centroid information and the second centroid information. There is no need to manually select points in the template image 2 and the image to be detected 3 to determine the position change information of the target object 20. This not only increases the intelligence of determining the position information of the target object 20, but also reduces the error caused by manual point selection, thereby improving the accuracy of the position change information, and thus improving the accuracy of locating the target object 20 in the image to be detected 3.
[0084] Optionally, in some embodiments of this application, such as Figure 5 and Figure 6 As shown, the marker is a specific line segment 25 on the contour of the target object 20. The target object 20 in the image to be detected is located according to the position transformation information and the position information of the marker on the target object 20 in the template image 2. This includes: determining the preset target contour 26 in the image to be detected according to the position transformation information and the position information of the specific line segment 25 of the target object 20 in the template image 2; and determining the target contour 27 in the image to be detected according to the detection area 29 containing the preset target contour 26 in the image to be detected, so as to locate the target object 20 in the image to be detected.
[0085] It should be understood that if a specific line segment 25 of the target object 20 in template image 2 is the complete outline of the target object 20 in template image 2, then the preset target outline 26 is the complete outline of the target object 20 in the image to be detected 3; if a specific line segment 25 of the target object 20 in template image 2 is the outline 28 of the first part of the target object 20 in template image 2, then the preset target outline 26 is the outline of the corresponding part of the target object 20 in the image to be detected 3. Furthermore, due to the instability of the image to be detected 3, the preset target outline 26 differs to some extent from the true outline of the target object 20. Based on the pixel distribution of the detection area 29, an outline that is consistent with or close to the true outline of the target object 20 can be determined.
[0086] In the above embodiments, since there are differences between the position and structural information of the target object 20 in the image to be detected 3 and the position and structural information of the target object 20 in the template image 2, based on the position transformation information and the position information of the specific line segment 25 of the target object 20 in the template image 2, a preset target contour 26 near the true contour of the target object 20 in the image to be detected 3 can be obtained in advance; and a more accurate target contour 27 can be determined based on the detection area containing the preset target contour 26, which can further improve the accuracy of locating the target object 20 in the image to be detected 3.
[0087] Optionally, in some embodiments of this application, the target contour 27 is determined based on the relationship between the gradient value in the region to be detected 29 and a preset threshold. This allows for convenient determination of the target contour.
[0088] The following explanation uses the example of a specific line segment 25 representing the outline of a portion of the target object 20 in template image 2. Figure 6 As shown, the gradient value of the detection region 29 can represent the rate of change between two adjacent pixels within the detection region 29. Furthermore, the larger the gradient value at a corresponding location within the detection region, the greater the probability that the location is on an edge. Therefore, if the rate of change between two adjacent pixels within the detection region 29 is greater than or equal to a preset threshold, it can be determined that these two pixels are located near the target contour 27.
[0089] In practical applications, the Laplacian algorithm can be used to determine the gradient value of the region to be detected 29 and the target contour 27.
[0090] Understandably, the size of the area to be detected 29 will affect the positioning accuracy and positioning speed of the target contour 27.
[0091] Optionally, in some embodiments of this application, the detection area 29 includes a plurality of detection sub-regions 291. The target contour 27 is determined according to the relationship between the gradient value in the detection area 29 and a preset threshold, including: determining a plurality of detection sub-regions 291 arranged adjacent to the preset target contour according to a preset target contour 26; and determining the target contour 27 according to the relationship between the gradient value in the plurality of detection sub-regions 291 and the preset threshold.
[0092] For example, the shape of the sub-region 291 to be detected can be rectangular. Multiple rectangular sub-regions 291 to be detected are arranged adjacently along a preset target contour 26. The size and number of sub-regions 291 to be detected can be determined according to the actual situation. The method for determining the target contour 27 based on the gradient values within the multiple sub-regions 29 can be the same as described above, or it can be different. For example, calipers can be used to determine the gradient values within the sub-regions 291 to be detected and the target contour 27. By determining the target points in the calipers, the target contour 27 is determined by fitting multiple target points.
[0093] In the above embodiments, the gradient value of the detection region 29 can be determined more accurately by using multiple adjacent sub-regions 291 to be detected, thereby enabling more precise determination of the target contour 27.
[0094] The embodiments of this application can determine the centroid coordinates of the first contour in various ways. In some implementations of this application, the method for locating the target object 20 in the image to be detected 3 further includes: obtaining the first contour information of the target object 20 in the template image 2; and determining the centroid coordinates of the first contour based on the first contour information. In this way, since the first contour information includes the contour coordinates of the target object 20 in the template image 2, the centroid coordinates of the first contour can be accurately determined.
[0095] The first contour information can be the complete contour information of the target object 20, or the contour information of the first part of the target object 20. Furthermore, the first contour information can be obtained through various contour extraction methods, such as template matching algorithms, neural networks, and boundary tracking algorithms.
[0096] Given the first contour information, the centroid coordinates of the first contour can be determined in the following way:
[0097] Example 1: Determine the complete outline of the target object 20 or the smallest circumcircle of the first part of the outline 28 based on the first outline information, and then determine the centroid coordinates of the first outline.
[0098] Example 2: Determine the centroid coordinates of the first contour by determining the complete contour of the target object 20 or the maximum inscribed rectangle of the first part of the contour 28 based on the first contour information.
[0099] It should be understood that, in addition to the methods described above, the centroid of the first contour can also be determined in other ways.
[0100] Figure 7 A schematic diagram of the centroid of a first profile according to an embodiment of this application is shown.
[0101] like Figure 7 As shown, in some embodiments of this application, the target object 20 includes a first target object 201 and / or a second target object 202; the first contour information includes first contour sub-information and / or second contour sub-information; the first contour centroid coordinates include first contour sub-centroid coordinates (z1, z2, z3) and / or second contour sub-centroid coordinates; determining the first contour centroid coordinates based on the first contour information includes: determining the first width sub-information of the contour of the first target object 201 in the template image 2 and the first width sub-information of the contour of the first target object 201 in the template image 2 based on the first contour information. The length sub-information; the vertex coordinates of the first outer sub-frame are determined based on the first width sub-information and the first length sub-information; the centroid coordinates (z1, z2, z3) of the first contour sub-frame are determined based on the vertex coordinates of the first outer sub-frame; and / or, the second width sub-information and the second length sub-information of the contour of the second target object 202 in the template image 2 are determined based on the second contour sub-information; the vertex coordinates of the second outer sub-frame are determined based on the second width sub-information and the second length sub-information; the centroid coordinates of the second contour sub-frame are determined based on the vertex coordinates of the second outer sub-frame.
[0102] Wherein, the first bounding sub-frame can be the smallest bounding rectangle of the outline of the first target object 201 in the template image 2, the first width sub-information can be the width W of the smallest bounding rectangle, and the first length sub-information can be the length H of the smallest bounding rectangle.
[0103] The vertex coordinates of the first bounding subframe are determined based on the width W and length H of the minimum bounding rectangle.
[0104] For example, the vertex coordinates (a, b), (c, d), (e, f), and (g, h) of the first outer subframe can be determined using the following formula:
[0105] a=-W / 2*Cos(Phi)-H / 2*Sin(Phi)
[0106] b=-W / 2*Sin(Phi)+H / 2*Cos(Phi)
[0107] c = W / 2 * Cos(Phi) - H / 2 * Sin(Phi)
[0108] d = W / 2 * Sin(Phi) + H / 2 * Cos(Phi)
[0109] e = W / 2 * Cos(Phi) + H / 2 * Sin(Phi)
[0110] f = W / 2 * Sin(Phi) - H / 2 * Cos(Phi)
[0111] g=-W / 2*Cos(Phi)+H / 2*Sin(Phi)
[0112] h=-W / 2*Sin(Phi)-H / 2*Cos(Phi)
[0113] Where Phi is the tilt angle of the first outer subframe.
[0114] Based on the vertex coordinates (a, b), (c, d), (e, f), and (g, h), two intersecting line segments are determined. The intersection point of these two line segments is used to determine the coordinates (z1, z2, z3) of the first contour sub-centroid, where z1 represents the abscissa of the first contour sub-centroid, z2 represents the ordinate of the first contour sub-centroid, and z3 represents the angle of the first contour sub-centroid. Furthermore, the angle z3 can be equal to Phi.
[0115] In the above embodiments, since the first outer subframe is determined based on the width and length information of the outline of the first target object 201 in the template image 2, the first outer subframe can include all the coordinates of the outline of the first target object 201 in the template image 2. Therefore, determining the centroid coordinates (z1, z2, z3) of the first outline subframe based on the vertex coordinates of the first outer subframe can more accurately determine the centroid coordinates (z1, z2, z3) of the first outline subframe.
[0116] The method for obtaining the centroid coordinates of the second contour sub-center can be the same as that for obtaining the centroid coordinates of the first contour sub-center, and will not be repeated here.
[0117] It should be noted that the first bounding box can also be the largest inscribed rectangle of the outline of the first target object 201 in template image 2. The process of determining the coordinates of the centroid of the first outline based on this largest inscribed rectangle is similar to the above implementation process and will not be repeated here. Furthermore, the second bounding box can also be the largest inscribed rectangle of the outline of the second target object 202 in template image 2.
[0118] It should be noted that the method for determining the centroid coordinates of the second contour can be the same as or different from that of the first contour.
[0119] Optionally, in some embodiments of this application, the method for locating the target object 20 in the image to be detected 3 further includes: acquiring second contour information of the target object 20 in the image to be detected 3; and determining the centroid coordinates of the second contour based on the second contour information. Thus, since the second contour information includes the contour coordinates of the target object in the image to be detected 3, the centroid coordinates of the second contour can be accurately determined.
[0120] Furthermore, the second contour information includes the contour information of the second part of the target object 20 in the image to be detected 3. The second contour information can be obtained through various contour extraction methods, such as neural networks and boundary tracking algorithms.
[0121] Given the first contour information, the centroid coordinates of the second contour can be determined based on the second contour information in the following way:
[0122] Example 1: Determine the minimum circumcircle of the second part of the target object 20's contour 30 based on the second contour information, and then determine the centroid coordinates of the second contour.
[0123] Example 2: Determine the maximum inscribed rectangle of the second part of the target object 20's contour 30 based on the second contour information, and then determine the centroid coordinates of the second contour.
[0124] It should be understood that, in addition to the methods described above for extracting the second contour information, other methods can also be used to determine the second contour information.
[0125] Optionally, in some embodiments of this application, the target object 20 includes a first target object 201 and / or a second target object 202, and the second contour information includes a third contour sub-information and / or a fourth contour sub-information. Obtaining the second contour information of the target object 20 in the image to be detected 3 includes: determining at least one image matching block based on the first target object 201 in the template image 2, the image matching block including at least a portion of the first target object 201; obtaining the third contour sub-information based on the matching degree between the image matching block and the image to be detected 3; and / or determining at least one image matching block based on the second target object 202 in the template image 2, the image matching block including at least a portion of the second target object 202; and obtaining the fourth contour sub-information based on the matching degree between the image matching block and the image to be detected 3. In this way, since the image matching block contains information about the target object 20 in the template image 2, the second contour information can be determined directly based on the image matching block of the template image 2 without introducing other images, thus making the determination of the second contour information more convenient.
[0126] It should be understood that an image matching block can be an M*M image block, where the value of M can be determined according to the actual situation. Furthermore, the number of image matching blocks can be determined based on the size of the first target object 201 or the second target object 202 and the size of the image matching block. All the first target objects 201 in all the image matching blocks can form the contour 30 of the second part of the first target object 201, or all the second target objects 202 in all the image matching blocks can form the contour 30 of the second part of the second target object 202. When multiple image matching blocks are determined, each image matching block can be slid across the image to be detected 3 to traverse the image to be detected 3. If the matching degree between an image matching block and a portion of the image to be detected 3 is greater than or equal to a threshold, then it is determined that the region contains the contour of the first target object 201 or the second target object 202. Therefore, the second contour information, such as the contour 30 of the second part, can be determined based on the matching degree between the image matching block and the image to be detected 3.
[0127] Optionally, in some embodiments of this application, the second contour centroid coordinates include third contour sub-centroid coordinates and / or fourth contour sub-centroid coordinates. Determining the second contour centroid coordinates based on the second contour information includes: determining the third width sub-information and the second length sub-information of the contour of the first target object 201 in the image to be detected 3 based on the second contour information; determining the vertex coordinates of the third outer sub-frame based on the second width sub-information and the second length sub-information; determining the third contour centroid sub-coordinates based on the vertex coordinates of the third outer sub-frame; and / or determining the fourth width sub-information and the fourth length sub-information of the contour of the second target object 202 in the image to be detected 3 based on the fourth contour sub-information; determining the vertex coordinates of the fourth outer sub-frame based on the fourth width sub-information and the fourth length sub-information; and determining the fourth contour centroid sub-coordinates based on the vertex coordinates of the fourth outer sub-frame.
[0128] The third bounding box can be the smallest bounding rectangle of the outline 30 of the second part of the first target object 201 in the image to be detected 3. The second width information can be the width W1 of the smallest bounding rectangle, and the second length information can be the length H1 of the smallest bounding rectangle.
[0129] The vertex coordinates of the third bounding subframe are determined based on the width W1 and length H1 of the minimum bounding rectangle.
[0130] For example, the vertex coordinates (a1, b1), (c1, d1), (e1, f1), and (g1, h1) of the third outer subframe can be determined using the following formula:
[0131] a1=-W1 / 2*Cos(Phi1)–H1 / 2*Sin(Phi1)
[0132] b1=-W1 / 2*Sin(Phi1)+H1 / 2*Cos(Phi1)
[0133] c1=W1 / 2*Cos(Phi1)–H1 / 2*Sin(Phi1)
[0134] d1=W1 / 2*Sin(Phi1)+H1 / 2*Cos(Phi1)
[0135] e1=W1 / 2*Cos(Phi1)+H1 / 2*Sin(Phi1)
[0136] f1=W1 / 2*Sin(Phi1)–H1 / 2*Cos(Phi1)
[0137] g1=-W1 / 2*Cos(Phi1)+H1 / 2*Sin(Phi1)
[0138] h1=-W1 / 2*Sin(Phi1)–H1 / 2*Cos(Phi1)
[0139] Where Phi1 is the tilt angle of the third outer subframe.
[0140] Based on the vertex coordinates (a1, b1), (c1, d1), (e1, f1), (g1, h1), determine two intersecting line segments, and determine the centroid of the third contour sub-center based on the intersection point of the two intersecting line segments.
[0141] In the above embodiments, since the third outer subframe is determined based on the width and length information of the contour of the first target object 201 in the image to be detected 3, the third outer subframe can include all the coordinates of the contour of the first target object 20 in the image to be detected 3. Therefore, determining the centroid coordinates of the third contour subframe based on the vertex coordinates of the third outer subframe can more accurately determine the centroid coordinates of the third contour subframe.
[0142] The method for obtaining the centroid coordinates of the fourth contour sub-center can be the same as that for obtaining the centroid coordinates of the third contour sub-center, and will not be repeated here.
[0143] It should be noted that the third bounding box can also be the largest inscribed rectangle of the contour of the first target object 201 in image 3. The process of determining the coordinates of the centroid of the third contour based on this largest inscribed rectangle is similar to the above implementation process and will not be repeated here. Furthermore, the fourth bounding box can also be the largest inscribed rectangle of the contour of the second target object 202 in image 3.
[0144] It should be understood that in practical applications, due to the instability of the object to be detected, the position of the target object 20 in the image to be detected 3 may differ from the position of the target object 20 in the target image. The position transformation information can be determined according to the actual situation.
[0145] Optionally, in some embodiments of this application, the position transformation information includes translation information and / or rotation information. Determining the position transformation information of the target object 20 based on the first center of gravity information and the second center of gravity information includes: determining the translation information and / or rotation information based on the first contour center of gravity coordinates and the second contour center of gravity coordinates. Thus, by determining the translation information and / or rotation information of the target object 20 through the first center of gravity information and the second center of gravity information, the translation and / or rotation of the target object 20 can be determined more accurately, thereby locating the target object 20 more accurately.
[0146] The translation information can be the displacement information of the target object 20 in the image to be detected 3 relative to the position of the target object 20 in the template image 2 in the horizontal and / or vertical directions; the rotation information can be the rotation angle of the target object 20 in the image to be detected 3 relative to the target object 20 in the template image 2.
[0147] For example, the affine transformation matrix can be determined based on the centroid coordinates of the first and second contours to determine translation and / or rotation information.
[0148] It should be understood that a specific line segment 25 of the target object 20 in the template image 2 can be the outline of any part of the target object 20 in the template image 2, or it can be a line segment of a specific part.
[0149] Optionally, in some embodiments of this application, the method for locating the target object 20 in the image to be detected 3 further includes: obtaining the first contour information of the target object 20 in the template image 2; and determining the position information of a specific line segment 25 of the target object 20 in the template image 2 based on the first contour information and the inflection point information of the target object 20 in the template image 2.
[0150] like Figures 3 to 6 As shown, the inflection point information of the target object 20 in template image 2 can be the coordinates of the inflection points A2, B2, C2, D2, E2, F2, G2, and H2 of the outline of the target object 20. Based on the outline 28 of the first part of the target object 20 in template image 2 and the coordinates of the inflection points, the positional information of specific line segments 25 (A2, B2), (B2, C2), (C2, D2), (E2, F2), (F2, G2), and (G2, H2) is determined, for example, the coordinates of the aforementioned specific line segments 25.
[0151] In the above embodiments, since the area near the inflection point of the target object 20 is prone to deformation or information loss, the position information of the specific line segment 25 determined based on the first contour information and the inflection point information of the target object 20 in the template image 2 can provide more accurate contour information for the image to be detected 3, which is beneficial for locating the target object 20 in the image to be detected 3.
[0152] Optionally, in some embodiments of this application, the method for locating the target object 20 in the image to be detected 3 further includes: the outline of the target object 20 in the image to be detected 3 has an occluded area.
[0153] It should be understood that, such as Figures 3 to 7 As shown, when there is an occluded area in the outline of the target in the image to be detected 3, the outline of the target object 20 in the image to be detected 3 will be incomplete. At this time, the second outline information is usually also incomplete.
[0154] In the above embodiments, when there is an occluded area in the outline of the target object 20 in the image to be detected 3, the position information and position transformation information of the specific line segment 25 of the target object 20 in the template image 2 can be used to obtain more complete outline information of the target object 20 in the image to be detected 3, which is more conducive to locating the target object 20 in the image to be detected 3.
[0155] Optionally, in some embodiments of this application, the method for locating the target object 20 in the image to be detected 3 further includes: determining the matching degree between the contour of the target object 20 in the image to be detected 3 and the contour of the target object 20 in the template image 2; and determining the second centroid information if the matching degree meets a preset condition. In this way, when the difference between the contour of the target object 20 in the image to be detected 3 and the contour of the target object 20 in the template image 2 is too large, the determination of the second centroid coordinates and the subsequent processing are no longer required, thus improving the efficiency of locating the target object 20 in the image to be detected 3.
[0156] The matching degree can be used to represent the similarity between the contour of target object 20 in the image to be detected 3 and the contour of target object 20 in the template image 2. For example, the matching degree can be determined by a template matching algorithm. If the matching degree is greater than or equal to a preset value, it means that the contour of target object 20 in the image to be detected 3 is highly similar to the contour of target object 20 in the template image 2. That is, when there is an occluded area in the contour of target object 20 in the image to be detected 3, the missing part of the contour of target object 20 in the image to be detected 3 is small. In this way, the second centroid information can be determined according to the above method.
[0157] If the matching degree is less than the preset value, it can be temporarily determined that the target object 20 in the image to be detected 3 is abnormal, so as to proceed to the next step of judgment.
[0158] It should be noted that the preset conditions and preset values can be determined according to the actual situation. For example, the preset condition can be that the matching degree is less than or equal to the preset value, indicating that the contour of the target object 20 in the image to be detected 3 has a high similarity to the contour of the target object 20 in the template image 2.
[0159] Optionally, in some embodiments of this application, the translation information includes first translation information and / or second translation information, and the rotation information includes first rotation information and / or second rotation information; determining the translation information and / or rotation information based on the first profile centroid coordinates and the second profile centroid coordinates includes: determining the first translation information and / or the first rotation information based on the first profile sub-centroid coordinates and the third profile sub-centroid coordinates; and / or, determining the second translation information and / or the second rotation information based on the second profile sub-centroid coordinates and the fourth profile sub-centroid coordinates.
[0160] For example, the affine transformation matrix of the first target 201 in the detection image 3 relative to the first target 201 in the template image 2 can be determined by the first profile sub-centroid coordinates and the second profile sub-centroid coordinates, so as to obtain the first translation information and the first rotation information; the affine transformation matrix of the second target 202 in the detection image 3 relative to the second target 202 in the template image 2 can be determined by the second profile sub-centroid coordinates, so as to obtain the second translation information and the second rotation information.
[0161] Optionally, in some embodiments of this application, the first target object 201 is a cover plate, the second target object 202 is an adapter piece, the adapter piece is attached to the cover plate, and the adapter piece and the cover plate have an overlapping area.
[0162] The cover plate is used to cover the casing of the battery cell, and it is usually equipped with electrode terminals for inputting or outputting electrical energy. The adapter plate is used to electrically connect the tabs and electrode terminals on the battery assembly.
[0163] To facilitate understanding by those skilled in the art, this application also provides an embodiment for a specific application scenario. For example, the scenario of inspecting the adapter plate and cover plate in a battery cell.
[0164] like Figures 2 to 7As shown, template image 2 can be an image containing adapter piece 23, cover plate 21, and blue film 24. Image 3 to be detected can be an image containing adapter piece 23, cover plate 21, and blue film 24. Furthermore, in image 3 to be detected, blue film 24 covers a portion of adapter piece 23 and cover plate 21. Target object 20 can be adapter piece 23 and cover plate 21. First contour information can be the contour information of a portion of adapter piece 23 and cover plate 21. The first contour centroid coordinates include two contour centroid coordinates: the contour centroid coordinates of adapter piece 23 determined by the aforementioned method based on a portion of the contour of adapter piece 23 at a specific position in template image 2, and the contour centroid coordinates of cover plate 21 determined by the aforementioned method based on a portion of the contour of cover plate 21 at a specific position. The second contour centroid coordinates also include two contour centroid coordinates. These can be the contour centroid coordinates of the adapter piece 23 determined by the aforementioned method based on a portion of the contour at a specific location in the image to be detected 3, and the contour centroid coordinates of the cover plate 21 determined by the aforementioned method based on a portion of the contour at a specific location in the cover plate 21. The contour at the specific location of the adapter piece 23 can be a portion or the complete contour of a component on the adapter piece 23 with a significant color difference from adjacent areas; the contour at the specific location of the cover plate 21 can be a portion or the complete contour of a component on the cover plate 21 with a significant color difference from adjacent areas (e.g., black adhesive 22). The positional information of the specific line segment 25 of the target object 20 in the template image 2 can be the positional information of the specific locations of the cover plate 21 and the adapter piece 23. The blue film 24 and the black adhesive 22 can be used for insulation.
[0165] In practical applications, the first contour information can be stored in advance in the storage medium in .shm file format; the centroid coordinates of the first contour can be stored in advance in the storage medium in .ini file format; and the position information of a specific line segment 25 can be stored in advance in the storage medium in .tif file format.
[0166] Figure 8 This is a schematic structural block diagram of a device for locating a target object in an image to be detected, as disclosed in an embodiment of this application. Figure 8 As shown, this application embodiment also provides a device for locating a target object in an image to be detected. The device 80 includes: a determining module 81, which is used to determine the position transformation information of the target object based on first centroid information and second centroid information, wherein the first centroid information includes the first contour centroid coordinates of the target object in the template image, and the second centroid information includes the second contour centroid coordinates of the target object in the image to be detected; the position transformation information is the position transformation information of the target object in the image to be detected relative to the target object in the template image; and a positioning module 82, which is used to locate the target object in the image to be detected based on the position transformation information and the position information of the markers on the target object in the template image.
[0167] Optionally, in some embodiments of this application, the marker is a specific line segment on the outline of the target object. The determining module 81 is further configured to determine the preset target outline in the image to be detected based on the position transformation information and the position information of the specific line segment of the target object in the template image. The determining module 81 is further configured to determine the target outline in the image to be detected based on the detection area containing the preset target outline in the image to be detected, so as to locate the target object in the image to be detected.
[0168] Optionally, in some embodiments of this application, the determining module 81 is further configured to determine the target contour based on the relationship between the gradient value in the region to be detected and a preset threshold.
[0169] Optionally, in some embodiments of this application, the region to be detected includes multiple sub-regions to be detected; the determining module 81 is further configured to determine multiple sub-regions to be detected arranged adjacent to each other along the preset target contour according to the preset target contour; the determining module 81 is further configured to determine the target contour according to the relationship between the gradient values in the multiple sub-regions to be detected and the preset threshold.
[0170] Optionally, in some embodiments of this application, the apparatus for locating a target object in an image to be detected further includes: an acquisition module, which is used to acquire first contour information of the target object in a template image; and a determination module 81 is further used to determine the centroid coordinates of the first contour based on the first contour information.
[0171] Optionally, in some embodiments of this application, the target object includes a first target object and / or a second target object; the first contour information includes first contour sub-information and / or second contour sub-information; the first contour centroid coordinates include first contour sub-centroid coordinates and / or second contour sub-centroid coordinates; the determining module 81 is further configured to determine, based on the first contour information, a first width sub-information and a first length sub-information of the contour of the first target object in the template image; the determining module 81 is further configured to determine, based on the first width sub-information and the first length sub-information, the vertex coordinates of the first enclosing sub-frame; the determining module 81 is further configured to determine, based on the vertex coordinates of the first enclosing sub-frame, the centroid coordinates of the first contour sub-frame; and / or, the determining module 81 is further configured to determine, based on the second contour sub-information, a second width sub-information and a second length sub-information of the contour of the second target object in the template image; the determining module 81 is further configured to determine, based on the second width sub-information and the second length sub-information, the vertex coordinates of the second enclosing sub-frame; and the determining module 81 is further configured to determine, based on the vertex coordinates of the second enclosing sub-frame, the centroid coordinates of the second contour sub-frame.
[0172] Optionally, in some embodiments of this application, the acquisition module is further configured to acquire the second contour information of the target object in the image to be detected; the determination module 81 is further configured to determine the centroid coordinates of the second contour based on the second contour information.
[0173] Optionally, in some embodiments of this application, the target object includes a first target object and / or a second target object, the second contour information includes third contour sub-information and / or fourth contour sub-information, and the determining module 81 is further configured to determine at least one image matching block based on the first target object in the template image, the image matching block including at least a portion of the first target object; the obtaining module is further configured to obtain the third contour sub-information based on the matching degree between the image matching block and the image to be detected; and / or, the determining module 81 is further configured to determine at least one image matching block based on the second target object in the template image, the image matching block including at least a portion of the second target object; the obtaining module is further configured to obtain the fourth contour sub-information based on the matching degree between the image matching block and the image to be detected.
[0174] Optionally, in some embodiments of this application, the second contour centroid coordinates include the third contour sub-centroid coordinates and / or, the fourth contour sub-centroid coordinates. The determining module 81 is further configured to determine the third width sub-information and the third length sub-information of the contour of the first target object in the image to be detected based on the third contour sub-information. The determining module 81 is further configured to determine the vertex coordinates of the third outer sub-frame based on the third width sub-information and the third length sub-information. The determining module 81 is further configured to determine the third contour sub-centroid coordinates based on the vertex coordinates of the third outer sub-frame. And / or, the determining module 81 is further configured to determine the fourth width sub-information and the fourth length sub-information of the contour of the second target object in the image to be detected based on the fourth contour sub-information. The determining module is further configured to determine the vertex coordinates of the fourth outer sub-frame based on the fourth width sub-information and the fourth length sub-information. The determining module is further configured to determine the fourth contour centroid sub-coordinates based on the vertex coordinates of the fourth outer sub-frame.
[0175] Optionally, in some embodiments of this application, the apparatus for locating a target object in an image to be detected further includes: an acquisition module for acquiring first contour information of the target object in a template image; and a determination module 81 for determining the position information of a specific line segment of the target object in the template image based on the first contour information and the inflection point information of the target object in the template image.
[0176] Optionally, in some embodiments of this application, the position transformation information includes translation information and / or rotation information, and the determining module 81 is further configured to determine the translation information and / or rotation information based on the first profile centroid coordinates and the second profile centroid coordinates.
[0177] Optionally, in some embodiments of this application, the translation information includes first translation information and second translation information, and the rotation information includes first rotation information and second rotation information; the determining module 81 is used to determine the first translation information and / or the first rotation information based on the first profile sub-centroid coordinates and the third profile sub-centroid coordinates; and / or, the determining module 81 is used to determine the second translation information and / or the second rotation information based on the second profile sub-centroid coordinates and the fourth profile sub-centroid coordinates.
[0178] Optionally, in some embodiments of this application, the first target object is a cover plate, the second target object is an adapter piece, the adapter piece is attached to the cover plate, and the adapter piece and the cover plate have an overlapping area.
[0179] Optionally, in some embodiments of this application, the outline of the target object in the image to be detected has an occluded area.
[0180] Optionally, in some embodiments of this application, the determining module 81 is further configured to determine the matching degree between the contour of the target object in the image to be detected and the contour of the target object in the template image; the determining module 81 is further configured to determine the second centroid information when the matching degree meets the preset conditions.
[0181] Figure 9 This is a schematic diagram of the hardware structure of a device for locating a target object in an image to be detected according to an embodiment of this application. Figure 9 The apparatus 800 shown for locating a target object in an image to be detected includes a memory 801, a processor 802, a communication interface 803, and a bus 804. The memory 801, processor 802, and communication interface 803 are interconnected via the bus 804.
[0182] The memory 801 may be a read-only memory (ROM), a static storage device, or a random access memory (RAM). The memory 801 may store a program, and when the program stored in the memory 801 is executed by the processor 802, the processor 802 and the communication interface 803 are used to execute the various steps of the method for locating a target object in an image to be detected according to the embodiments of this application.
[0183] The processor 802 may be a general-purpose central processing unit (CPU), microprocessor, application-specific integrated circuit (ASIC), graphics processing unit (GPU), or one or more integrated circuits, used to execute relevant programs to implement the functions required by the unit in the apparatus for locating a target object in an image to be detected according to the embodiments of this application, or to execute the method for locating a target object in an image to be detected according to the embodiments of this application.
[0184] The processor 802 can also be an integrated circuit chip with signal processing capabilities. In implementation, each step of the method for locating a target object in an image to be detected according to this application embodiment can be completed by the integrated logic circuitry in the processor 802 or by software instructions.
[0185] The processor 802 described above can also be a general-purpose processor, a digital signal processor (DSP), an ASIC, a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly implemented by the hardware processor, or implemented by a combination of hardware and software modules in the processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 801. The processor 802 reads the information in memory 801 and, in conjunction with its hardware, completes the functions required by the units included in the device for locating a target object in an image to be detected in the embodiments of this application, or executes the method for locating a target object in an image to be detected in the embodiments of this application.
[0186] The communication interface 803 uses transceiver devices, such as, but not limited to, transceivers, to enable communication between the device 800 and other devices or communication networks. For example, traffic data from unknown devices can be obtained through the communication interface 803.
[0187] Bus 804 may include a pathway for transmitting information between various components of device 800 (e.g., memory 801, processor 802, communication interface 803).
[0188] It should be noted that although the above-described device 800 only shows a memory, processor, and communication interface, those skilled in the art should understand that in specific implementations, device 800 may also include other devices necessary for normal operation. Furthermore, depending on specific needs, those skilled in the art should understand that device 800 may also include hardware devices for implementing other additional functions. Moreover, those skilled in the art should understand that device 800 may only include the devices necessary for implementing the embodiments of this application, and may not necessarily include... Figure 9 All the devices shown.
[0189] This application also provides a computer-readable storage medium storing program code for execution by a device, the program code including instructions for performing the steps of the method for locating a target in an image to be detected.
[0190] This application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions that, when executed by a computer, cause the computer to perform the above-described method for locating a target object in an image to be detected.
[0191] The aforementioned computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0192] It should be noted that the apparatus, computer-readable storage medium, and computer program product for locating target objects in an image to be detected provided in the above embodiments of this application can respectively achieve the corresponding location of target objects in the image to be detected in the aforementioned method embodiments, and have the beneficial effects of the corresponding method embodiments. The relevant descriptions can be referred to the aforementioned method embodiments, and will not be repeated here.
[0193] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0194] In the description of this application, it should be noted that, unless otherwise stated, "a plurality of" means two or more. Furthermore, the terms "first," "second," "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0195] Although this application has been described with reference to preferred embodiments, various modifications can be made thereto and components can be replaced with equivalents without departing from the scope of this application. In particular, the technical features mentioned in the various embodiments can be combined in any manner, provided there is no structural conflict. This application is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A method for locating a target object in an image to be detected, characterized in that, The method includes: The position transformation information of the target object is determined based on the first centroid information and the second centroid information, wherein the first centroid information includes the first contour centroid coordinates of the target object in the template image, and the second centroid information includes the second contour centroid coordinates of the target object in the image to be detected; the position transformation information is the position transformation information of the target object in the image to be detected relative to the target object in the template image. The target object in the image to be detected is located based on the position transformation information and the position information of the markers on the target object in the template image; The marker is a specific line segment on the outline of the target object, and the specific line segment is part or complete of the outline of the target object. Locating the target object in the image to be detected based on the position transformation information and the position information of the marker on the target object in the template image includes: Based on the position transformation information and the position information of the specific line segment in the template image, the preset target contour in the image to be detected is determined; Based on the detection region containing the preset target contour in the image to be detected, the target contour in the image to be detected is determined in order to locate the target object in the image to be detected.
2. The method according to claim 1, characterized in that, The step of determining the target contour in the image to be detected based on the detection region containing the preset target contour includes: The target contour is determined based on the relationship between the gradient value and the preset threshold in the region to be detected.
3. The method according to claim 2, characterized in that, The region to be detected includes multiple sub-regions to be detected. Determining the target contour based on the relationship between gradient values and preset thresholds within the regions to be detected includes: Based on the preset target contour, a plurality of the sub-regions to be detected are determined, arranged adjacent to each other along the preset target contour; The target contour is determined based on the relationship between gradient values within multiple sub-regions to be detected and the preset threshold.
4. The method according to claim 1, characterized in that, The method further includes: Obtain the first contour information of the target object in the template image; The centroid coordinates of the first contour are determined based on the first contour information.
5. The method according to claim 4, characterized in that, The target object includes a first target object and / or a second target object; the first contour information includes first contour sub-information and / or second contour sub-information; the first contour centroid coordinates include first contour sub-centroid coordinates and / or second contour sub-centroid coordinates; determining the first contour centroid coordinates based on the first contour information includes: Based on the first contour sub-information, determine the first width sub-information of the contour of the first target object in the template image and the first length sub-information of the contour of the first target object in the template image; The vertex coordinates of the first outer sub-frame are determined based on the first width sub-information and the first length sub-information; The centroid coordinates of the first contour sub-frame are determined based on the vertex coordinates of the first outer sub-frame; and / or, The second width sub-information and the second length sub-information of the contour of the second target object in the template image are determined based on the second contour sub-information; The vertex coordinates of the second outer sub-frame are determined based on the second width sub-information and the second length sub-information; The centroid coordinates of the second contour sub-frame are determined based on the vertex coordinates of the second outer sub-frame.
6. The method according to claim 1, characterized in that, The method further includes: Obtain the second contour information of the target object in the image to be detected; The centroid coordinates of the second contour are determined based on the second contour information.
7. The method according to claim 6, characterized in that, The target object includes a first target object and / or a second target object, the second contour information includes a third contour sub-information and / or a fourth contour sub-information, and the step of obtaining the second contour information of the target object in the image to be detected includes: At least one image matching block is determined based on the first target object in the template image, and the image matching block includes at least a portion of the first target object; The third contour sub-information is obtained based on the matching degree between the image matching block and the image to be detected; and / or, At least one image matching block is determined based on the second target object in the template image, the image matching block including at least a portion of the second target object; The fourth contour sub-information is obtained based on the matching degree between the image matching block and the image to be detected.
8. The method according to claim 7, characterized in that, The second contour centroid coordinates include the third contour sub-centroid coordinates and / or, the fourth contour sub-centroid coordinates. Determining the second contour centroid coordinates based on the second contour information includes: The third width sub-information and the third length sub-information of the contour of the first target object in the image to be detected are determined based on the third contour sub-information. The vertex coordinates of the third outer sub-frame are determined based on the third width sub-information and the third length sub-information; The centroid coordinates of the third contour sub-frame are determined based on the vertex coordinates of the third outer sub-frame; and / or, The fourth width sub-information and the fourth length sub-information of the contour of the second target object in the image to be detected are determined based on the fourth contour sub-information. The vertex coordinates of the fourth outer sub-frame are determined based on the fourth width sub-information and the fourth length sub-information; The centroid coordinates of the fourth contour sub-frame are determined based on the vertex coordinates of the fourth outer sub-frame.
9. The method according to claim 1, characterized in that, The method further includes: Obtain the first contour information of the target object in the template image; The position information of a specific line segment of the target object in the template image is determined based on the first contour information and the inflection point information of the target object in the template image.
10. The method according to claim 1, characterized in that, The position transformation information includes translation information and / or rotation information. Determining the position transformation information of the target object based on the first center of gravity information and the second center of gravity information includes: The translation information and / or the rotation information are determined based on the centroid coordinates of the first contour and the centroid coordinates of the second contour.
11. The method according to claim 10, characterized in that, The translation information includes first translation information and / or second translation information, and the rotation information includes first rotation information and / or second rotation information; Determining the translation information and / or the rotation information based on the centroid coordinates of the first contour and the second contour includes: The first translation information and / or the first rotation information are determined based on the centroid coordinates of the first and third contour sub-contours. And / or, The second translation information and / or the second rotation information are determined based on the centroid coordinates of the second and fourth contour sub-contours.
12. The method according to claim 5, characterized in that, The first target object is a cover plate, and the second target object is an adapter piece. The adapter piece is attached to the cover plate, and there is an overlapping area between the adapter piece and the cover plate.
13. The method according to claim 1, characterized in that, The outline of the target object in the image to be detected has an occluded area.
14. The method according to any one of claims 1 to 13, characterized in that, The method further includes: Determine the degree of matching between the contour of the target object in the image to be detected and the contour of the target object in the template image; If the matching degree meets the preset conditions, the second centroid information is determined.
15. A device for locating a target object in an image to be detected, characterized in that, The device includes: The determining module is configured to determine the position transformation information of the target object based on first centroid information and second centroid information, wherein the first centroid information includes the first contour centroid coordinates of the target object in the template image, and the second centroid information includes the second contour centroid coordinates of the target object in the image to be detected; the position transformation information is the position transformation information of the target object in the image to be detected relative to the target object in the template image. The positioning module is used to locate the target object in the image to be detected based on the position transformation information and the position information of the marker on the target object in the template image; The marker is a specific line segment on the outline of the target object, and the specific line segment is part or complete outline of the target object. The determining module is also used to determine the preset target outline in the image to be detected based on the position transformation information and the position information of the marker on the target object in the template image. The determining module is further configured to determine the target contour in the image to be detected based on the detection area containing the preset target contour in the image to be detected, so as to locate the target object in the image to be detected.
16. The apparatus according to claim 15, characterized in that, The determining module is further configured to determine the target contour based on the relationship between the gradient value and the preset threshold in the region to be detected.
17. The apparatus according to claim 16, characterized in that, The region to be detected includes multiple sub-regions to be detected, and the determining module is further configured to determine multiple sub-regions to be detected that are arranged adjacent to each other along the preset target contour based on the preset target contour; The determining module is further configured to determine the target contour based on the relationship between gradient values within multiple sub-regions to be detected and the preset threshold.
18. The apparatus according to claim 15, characterized in that, The device further includes: The acquisition module is used to acquire the first contour information of the target object in the template image; The determining module is further configured to determine the centroid coordinates of the first contour based on the first contour information.
19. The apparatus according to claim 18, characterized in that, The target object includes a first target object and / or a second target object. The first contour information includes first contour sub-information and / or second contour sub-information. The first contour centroid coordinates include first contour sub-centroid coordinates and / or second contour sub-centroid coordinates. The determining module is further configured to determine, based on the first contour sub-information, a first width sub-information of the contour of the first target object in the template image and a first length sub-information of the contour of the first target object in the template image. The determining module is further configured to determine the vertex coordinates of the first outer sub-frame based on the first width sub-information and the first length sub-information; The determining module is further configured to determine the centroid coordinates of the first contour sub-frame based on the vertex coordinates of the first outer sub-frame; and / or, The determining module is further configured to determine, based on the second contour sub-information, the second width sub-information of the contour of the second target object in the template image and the second length sub-information of the contour of the second target object in the template image; The determining module is further configured to determine the vertex coordinates of the second outer sub-frame based on the second width sub-information and the second length sub-information; The determining module is further configured to determine the centroid coordinates of the second contour sub-frame based on the vertex coordinates of the second outer sub-frame.
20. The apparatus according to claim 19, characterized in that, The device further includes: The acquisition module is also used to acquire the second contour information of the target object in the image to be detected; The determining module is further configured to determine the centroid coordinates of the second contour based on the second contour information.
21. The apparatus according to claim 20, characterized in that, The target object includes a first target object and / or a second target object, the second contour information includes a third contour sub-information and / or a fourth contour sub-information, and the determining module is further configured to determine at least one image matching block based on the first target object in the template image, the image matching block including at least a portion of the first target object; The acquisition module is further configured to acquire the third contour sub-information based on the matching degree between the image matching block and the image to be detected; and / or, The determining module is further configured to determine at least one image matching block based on the second target object in the template image, the image matching block including at least a portion of the second target object; The acquisition module is further configured to acquire the fourth contour sub-information based on the matching degree between the image matching block and the image to be detected.
22. The apparatus according to claim 21, characterized in that, The second contour centroid coordinates include the third contour sub-centroid coordinates and / or the fourth contour sub-centroid coordinates. The determining module is further configured to determine the third width sub-information of the contour of the first target object in the image to be detected and the third length sub-information of the contour of the first target object in the image to be detected based on the third contour sub-information. The determining module is further configured to determine the vertex coordinates of the third outer sub-frame based on the third width sub-information and the third length sub-information; The determining module is further configured to determine the centroid coordinates of the third contour sub-frame based on the vertex coordinates of the third outer sub-frame; and / or, The determining module is further configured to determine, based on the fourth contour sub-information, the fourth width sub-information of the contour of the second target object in the image to be detected and the fourth length sub-information of the contour of the second target object in the image to be detected; The determining module is further configured to determine the vertex coordinates of the fourth outer sub-frame based on the fourth width sub-information and the fourth length sub-information; The determining module is also used to determine the centroid coordinates of the fourth contour sub-frame based on the vertex coordinates of the fourth outer sub-frame.
23. The apparatus according to claim 15, characterized in that, The device further includes: The acquisition module is used to acquire the first contour information of the target object in the template image; The determining module is further configured to determine the position information of a specific line segment of the target object in the template image based on the first contour information and the inflection point information of the target object in the template image.
24. The apparatus according to claim 15, characterized in that, The position transformation information includes translation information and / or rotation information, and the determining module is further configured to determine the translation information and / or the rotation information based on the centroid coordinates of the first contour and the centroid coordinates of the second contour.
25. The apparatus according to claim 24, characterized in that, The translation information includes first translation information and second translation information, and the rotation information includes first rotation information and second rotation information; the determining module is used to determine the first translation information and / or the first rotation information based on the first profile sub-centroid coordinates and the third profile sub-centroid coordinates; And / or, The determining module is used to determine the second translation information and / or the second rotation information based on the centroid coordinates of the second and fourth contour sub-contours.
26. The apparatus according to claim 19, characterized in that, The first target object is a cover plate, and the second target object is an adapter piece. The adapter piece is attached to the cover plate, and there is an overlapping area between the adapter piece and the cover plate.
27. The apparatus according to claim 15, characterized in that, The outline of the target object in the image to be detected has an occluded area.
28. The apparatus according to any one of claims 15 to 27, characterized in that, The determining module is further configured to determine the matching degree between the contour of the target object in the image to be detected and the contour of the target object in the template image; The determining module is further configured to determine the second centroid information when the matching degree meets the preset conditions.
29. A device for locating a target object in an image to be detected, characterized in that, It includes a processor and a memory, the memory being used to store a program, and the processor being used to call and run the program from the memory to perform the method of any one of claims 1 to 14.
30. A computer-readable storage medium, characterized in that, Includes a computer program that, when run on a computer, causes the computer to perform the method of any one of claims 1 to 14.