A method, apparatus, and electronic device for detecting target objects.
By combining image segmentation and sub-target contour analysis with the DeepLabV3+ model trained using the PyTorch deep learning framework, the problem of low efficiency and accuracy in target object detection is solved, achieving efficient and accurate automated detection.
Patent Information
- Application Number
- CN202310533819.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-12
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2043-05-12
AI Technical Summary
Existing technologies suffer from low efficiency and low accuracy in target object detection, especially due to the large workload and low accuracy caused by traditional manual review methods.
Image segmentation techniques are used to extract the target contour of the target object, determine the minimum bounding rectangle, and segment it into multiple sub-target contours according to preset conditions. The qualification of the target object is determined by whether the first contour line of the sub-target contour meets the preset rules. The DeepLabV3+ network model is trained using the PyTorch deep learning framework to improve the accuracy of image segmentation.
It improves the efficiency and accuracy of target object detection, reduces the false detection rate, and achieves more efficient and accurate automated detection.
Smart Images

Figure CN116597140B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, and electronic device for detecting target objects. Background Technology
[0002] Currently, after obtaining an image containing the target object, the traditional manual review method is used to determine whether the image is acceptable. However, this method suffers from low efficiency and low accuracy due to the large workload involved.
[0003] How to improve the detection efficiency and accuracy of target objects is a question worth discussing. Summary of the Invention
[0004] This application provides a target object detection method, apparatus, electronic device, and storage medium to improve the detection efficiency and accuracy of target objects.
[0005] In a first aspect, embodiments of this application provide a target object detection method, including:
[0006] Acquire the image to be detected, which includes the target object and the background object;
[0007] Perform image segmentation on the image to be detected and extract the target contour of the target object;
[0008] Determine the minimum bounding rectangle of the target outline;
[0009] The target contour is segmented according to preset conditions to obtain multiple sub-target contours;
[0010] If the first contour line of multiple sub-target contours conforms to preset rules, the target object is deemed to have passed detection. Here, the first contour line is the length of the line segment of the sub-target contour along the width of the minimum enclosing rectangle.
[0011] In the above method, the success of the target object is determined by whether the first contour line of multiple sub-target contours conforms to preset rules. Compared with manual inspection of the target object, this method improves both inspection efficiency and accuracy.
[0012] Optionally, image segmentation is performed on the image to be detected to extract the target contour of the target object, specifically including:
[0013] A pre-established image segmentation model is used to segment the image to be detected and extract the target contour of the target object.
[0014] In the above method, the target contour of the target object can be extracted more accurately through the image segmentation model, which makes it easier to determine whether the target object detection is qualified based on the target contour.
[0015] Optionally, the image segmentation model can be pre-built in the following ways:
[0016] The DeepLabV3+ network model was trained using the PyTorch deep learning framework to obtain an image segmentation model.
[0017] The method described above requires significantly fewer training samples for training the DeepLabV3+ network model using the PyTorch deep learning framework compared to existing classification-based methods for object detection. Furthermore, after continuous adjustments to the learning rate (LR) and batch size, the MIOU (Mean Intersection over Union, the current model's evaluation score) can reach approximately 96%. This means that the image segmentation model described above can more accurately extract the target contours of objects, facilitating subsequent determination of whether object detection is successful based on these contours.
[0018] Optionally, the target contour can be segmented according to preset conditions to obtain multiple sub-target contours, specifically including:
[0019] The target contour is divided into multiple sub-target contours according to a preset number of parts.
[0020] In the above method, the target contour is divided into multiple sub-target contours according to a preset number of parts. This facilitates subsequent determination of whether the target object passes inspection based on the sub-target contours, thereby improving the accuracy of subsequent target object detection.
[0021] Optionally, if the first contour line of multiple sub-target contours conforms to preset rules, the target object is determined to be qualified for detection, specifically including:
[0022] Multiple sub-target contours are grouped according to a preset number to obtain multiple sub-target contour sets, with each sub-target contour set containing the same number of sub-target contours.
[0023] Determine a first length for the set of sub-target contours, where the first length represents the average value of multiple first contour lines in the set of sub-target contours;
[0024] Compare the first lengths of multiple sets of sub-target contours;
[0025] If the first length of multiple sub-target contour sets is proportional, the target object is deemed to have passed the detection.
[0026] In the above method, the first length is obtained by determining the average value of multiple first contour lines in the sub-target contour set. This makes it more accurate to determine whether the target object is qualified based on whether the first length is proportional. This can greatly improve the detection accuracy and reduce the false detection rate.
[0027] Optionally, the above methods also include:
[0028] If the first length of multiple sub-target contour sets is disproportionate, the target object is determined to be unqualified.
[0029] In the above method, when the first lengths of multiple sub-target contour sets are disproportionate, the target object is determined to be unqualified, which facilitates the determination of the target object's detection result.
[0030] Secondly, embodiments of this application provide a target object detection device, comprising:
[0031] The acquisition module is used to acquire the image to be detected, which includes the target object and the background object.
[0032] The processing module is used to perform image segmentation on the image to be detected and extract the target contour of the target object;
[0033] The processing module is also used to determine the minimum bounding rectangle of the target contour;
[0034] The processing module is also used to segment the target contour according to preset conditions to obtain multiple sub-target contours;
[0035] The detection module is used to determine that the target object is qualified if the first contour line of multiple sub-target contours conforms to preset rules. The first contour line is the line segment length of the sub-target contour in the direction of the width of the minimum enclosing rectangle.
[0036] Thirdly, embodiments of this application also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it causes the processor to implement any of the data recognition methods described in the first aspect above.
[0037] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the data recognition method of the first aspect.
[0038] Fifthly, embodiments of this application also provide a computer program product, including a computer program that is executed by a processor to implement the data recognition method as described in any of the first aspects above.
[0039] The technical effects of any of the implementation methods in aspects two through five can be found in the technical effects of the corresponding implementation methods in aspect one, and will not be repeated here. Attached Figure Description
[0040] Figure 1 This is a schematic diagram illustrating an application scenario of a target object detection method provided in an embodiment of this application;
[0041] Figure 2 This is a schematic diagram illustrating an application scenario of another target object detection method provided in an embodiment of this application;
[0042] Figure 3 A flowchart of a target object detection method provided in an embodiment of this application;
[0043] Figure 4a A schematic diagram of an image to be detected provided in an embodiment of this application;
[0044] Figure 4b A schematic diagram of another image to be detected provided in an embodiment of this application;
[0045] Figure 5 This is a schematic diagram of a target contour provided in an embodiment of this application;
[0046] Figure 6 A schematic diagram of a minimum bounding rectangle provided for an embodiment of this application;
[0047] Figure 7 A schematic diagram of a sub-target contour provided in an embodiment of this application;
[0048] Figure 8 A schematic diagram of a first contour line provided in an embodiment of this application;
[0049] Figure 9 A schematic diagram of a set of sub-target contours provided in an embodiment of this application;
[0050] Figure 10 A schematic diagram of another first contour line provided in an embodiment of this application;
[0051] Figure 11 A flowchart illustrating an exemplary target object detection method provided in this application embodiment;
[0052] Figure 12 A schematic diagram of a target object detection device provided in an embodiment of this application;
[0053] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0055] The application scenarios described in this application are for the purpose of more clearly illustrating the technical solutions of this application, and do not constitute a limitation on the technical solutions provided in this application. Those skilled in the art will understand that with the emergence of new application scenarios, the technical solutions provided in this application are also applicable to similar technical problems. In the description of this application, unless otherwise stated, "multiple" means two or more.
[0056] Currently, after obtaining an image containing the target object, the traditional manual review method is used to determine whether the image is acceptable. However, this method suffers from low efficiency due to the large workload involved.
[0057] In existing technologies, classification-based methods can be used to classify various types of target objects. However, these methods require a large amount of data from different categories for clustering training, and each category needs a large amount of homogeneous data. This requires both a large amount of qualified training data and a large amount of unqualified training data. However, the collected training data often lacks sufficient unqualified training data, leading to overfitting and false detections. Furthermore, these classification-based methods also require finding definite boundaries for each category before performing clustering operations. However, while the boundary determination method is effective, it cannot classify features not included in the dataset, resulting in insufficient generalization ability and low accuracy.
[0058] In summary, current methods for processing images to be detected suffer from low detection accuracy and low detection efficiency.
[0059] To address the aforementioned problems, embodiments of this application provide a target object detection method, apparatus, and electronic device. For example, an image to be detected is acquired. The image to be detected includes a target object and a background object. Image segmentation is performed on the image to be detected to extract the target contour of the target object. The minimum bounding rectangle of the target contour is determined. The target contour is segmented according to preset conditions to obtain multiple sub-target contours. If the first contour line of the multiple sub-target contours conforms to preset rules, the target object detection is deemed successful. The first contour line is the line segment length of the sub-target contour in the direction of the width of the minimum bounding rectangle.
[0060] like Figure 1As shown in the figure, an application scenario diagram of an optional target object detection method according to an embodiment of this application is illustrated, including a server 100 and a terminal 101. The server 100 and the terminal 101 can be connected through a network to realize the target object detection method of this application.
[0061] Users can use server 100 to interact with terminal 101 via the network, such as receiving or sending messages. Various client applications can be installed on terminal 101, such as programming applications, web browser applications, search applications, etc.
[0062] In this embodiment, the server 100 can be a standalone server or a server cluster consisting of multiple servers. The terminal 101 can be various electronic devices with a display screen that support web browsing, including but not limited to smartphones, tablets, desktop computers, etc.
[0063] like Figure 2 As shown in the diagram, another optional target object detection method according to an embodiment of this application is illustrated in an application scenario, including a server 202, an image acquisition device 201, and a target object 200. The server 100 and the image acquisition device 201 can be connected via a network to implement the target object detection method of this application.
[0064] Image acquisition device 201 captures an image to be detected containing the target object. Image acquisition device 201 sends the image to be detected to server 202. Server 202 acquires the image to be detected. The image to be detected includes the target object and background objects. Image segmentation is performed on the image to be detected to extract the target contour of the target object. The minimum bounding rectangle of the target contour is determined. The target contour is segmented according to preset conditions to obtain multiple sub-target contours. If the first contour line of the multiple sub-target contours conforms to preset rules, the target object is determined to be qualified for detection. The first contour line is the length of the line segment of the sub-target contour in the direction of the width of the minimum bounding rectangle.
[0065] like Figure 3 As shown in the flowchart of a detection method provided in this application embodiment, it may specifically include the following steps.
[0066] S301. Obtain the image to be detected, which includes the target object and the background object.
[0067] In one possible scenario, the server can retrieve the image to be inspected from a database. In another, an image acquisition device can capture the image to be inspected and then send it to the server. Upon receiving the image, the server begins to check whether the target object is qualified. Alternatively, the terminal can send the image to be inspected to the server. Upon receiving the image, the server begins to check whether the target object is qualified.
[0068] For example, such as Figure 4a as well as Figure 4b As shown, the image to be detected may include the warning tape of the target object, as well as the sand around the warning tape of the background object.
[0069] S302. Perform image segmentation on the image to be detected and extract the target contour of the target object.
[0070] In one possible embodiment, the server can use a pre-established image segmentation model to segment the image to be detected and extract the target contour of the target object.
[0071] The embodiments of this application can train the DeepLabV3+ network model based on the PyTorch deep learning framework to obtain an image segmentation model.
[0072] The training method for image segmentation models is described below:
[0073] This application embodiment can obtain training samples from a database. The training samples can be images to be detected or undetected images. The training samples contain target objects and background objects. The target objects can be detected successfully or undetected. Using the above training samples, the DeepLabV3+ network model is trained based on the PyTorch deep learning framework to obtain an image segmentation model.
[0074] The method described above requires significantly fewer training samples for training the DeepLabV3+ network model using the PyTorch deep learning framework compared to existing classification-based methods for object detection. Furthermore, after continuous adjustments to the learning rate (LR) and batch size, the MIOU (Mean Intersection over Union, the current model's evaluation score) can reach approximately 96%. This means that the image segmentation model described above can more accurately extract the target contours of objects, facilitating subsequent determination of whether object detection is successful based on these contours.
[0075] like Figure 5As shown in the figure, this application provides a schematic diagram of a target outline. Assuming the target object is a warning tape, Figure 5 The white area in the middle is the target outline of the warning tape for the target object.
[0076] S303. Determine the minimum bounding rectangle of the target outline.
[0077] In one alternative embodiment, the server may determine the minimum bounding rectangle of the target contour.
[0078] It is understood that this application does not specifically limit the method for determining the minimum bounding rectangle of the target contour. For example, the server can find the coordinates of the leftmost, rightmost, topmost, and bottommost pixels belonging to the target contour, and take the coordinates x0 of the leftmost pixel and the coordinates y0 of the topmost pixel to form the coordinates (x0, y0) of the top left corner of the minimum bounding rectangle; take the coordinates x1 of the rightmost pixel and the coordinates y1 of the bottommost pixel to form the coordinates (x1, y1) of the bottom right corner of the minimum bounding rectangle; and use the two coordinates (x0, y0) and (x1, y1) to determine the minimum bounding rectangle of the target contour.
[0079] like Figure 6 As shown in the diagram, this application provides a schematic diagram of a minimum bounding rectangle. Assuming the target object is a warning tape, the white area in the diagram represents the target outline of the warning tape. The dashed line in the diagram represents the minimum bounding rectangle of the target outline.
[0080] S304. The target contour is divided according to preset conditions to obtain multiple sub-target contours.
[0081] In one optional embodiment, the preset conditions may include dividing the target contour into multiple sub-target contours according to a preset number of parts. It is understood that the preset number of parts can be an empirical value pre-set by those skilled in the art, and the preset number of parts can be reasonably set according to specific application scenarios.
[0082] like Figure 7 As shown in the diagram, this application embodiment provides a schematic diagram of a sub-target contour. Assume the preset number of equal parts is 50. The server can divide the target contour into 50 equal parts according to the preset number of parts.
[0083] In the above method, the target contour is divided according to preset conditions, which facilitates the subsequent determination of whether the target object is qualified based on the sub-target contours. At the same time, when the preset condition is that the target contour is divided equally, the accuracy of subsequent detection can be improved.
[0084] S305. If the first contour line of multiple sub-target contours conforms to the preset rules, the target object is determined to be qualified for detection.
[0085] Wherein, the first contour line is the length of the line segment of the sub-target contour in the direction of the width of the minimum enclosing rectangle.
[0086] It is understandable that the common edge of two adjacent sub-target contours in the direction of the width of the minimum enclosing rectangle can be the first contour line of the two adjacent sub-target contours.
[0087] like Figure 8 As shown, this application embodiment provides a schematic diagram of a first contour line. In the figure, (1), (2), (3), and (4) are sub-target contours of the target contour. Among them, z and i are the line segment lengths of the sub-target contour (1) in the direction of the width of the minimum enclosing rectangle. That is, z and i are the first contour lines of the sub-target contour (1). i and j are the line segment lengths of the sub-target contour (2) in the direction of the width of the minimum enclosing rectangle. That is, i and j are the first contour lines of the sub-target contour (2). j and k are the line segment lengths of the sub-target contour (3) in the direction of the width of the minimum enclosing rectangle. That is, j and k are the first contour lines of the sub-target contour (3). k and m are the line segment lengths of the sub-target contour (3) in the direction of the width of the minimum enclosing rectangle. That is, k and m are the first contour lines of the sub-target contour (4).
[0088] In this embodiment, the server can group multiple sub-target contours according to a preset number to obtain multiple sub-target contour sets. Each sub-target contour set contains the same number of sub-target contours. It is understood that the preset number can be an empirical value pre-set by those skilled in the art, and the preset number can be reasonably set according to specific application scenarios.
[0089] For example, such as Figure 9 As shown, suppose there are 50 sub-target contours. The default quantity is 10. Then each set of sub-target contours contains 5 sub-target contours. m1 is one set of sub-target contours. m2 is another set of sub-target contours. m1 and m2 each contain 5 sub-target contours. For another example, suppose there are 100 sub-target contours. The default quantity is 10. Then each set of sub-target contours contains 10 sub-target contours.
[0090] In this embodiment of the application, after obtaining multiple sets of sub-target contours, the server can determine a first length for each set of sub-target contours. The first length represents the average value of multiple first contour lines in the set of sub-target contours.
[0091] It is understandable that, since the common edge of two adjacent sub-target contours in the direction of the width of the minimum enclosing rectangle can simultaneously be the first contour line of both of these adjacent sub-target contours, to prevent the first length from being calculated based on the same first contour line in different sets of sub-target contours, the server can determine the first contour line in the set of sub-target contours according to the set calculation conditions and calculate the first length.
[0092] For example, suppose that in the image to be detected, the first contour lines of the sub-target contours are distributed on the upper and lower sides of the sub-target contours. The calculation conditions could include: in each set of sub-target contours, taking the upper first contour line for each sub-target contour, calculating the average value of the sub-target contours, and obtaining the first length. As another example, suppose that in the image to be detected, the first contour lines of the sub-target contours are distributed on the left and right sides of the sub-target contours. The calculation conditions could include: in each set of sub-target contours, taking the left first contour line for each sub-target contour, calculating the average value of the sub-target contours, and obtaining the first length.
[0093] For example, such as Figure 10 In the schematic diagram of the first contour line shown, (1), (2), (3), and (4) are sub-target contours of the target contour. Specifically, z and i are the first contour lines of sub-target contour (1). i and j are the first contour lines of sub-target contour (2). j and k are the first contour lines of sub-target contour (3). k and m are the first contour lines of sub-target contour (4). Assume the first contour lines are z = 4, i = 5, j = 6, k = 7, and m = 8. The server can group the above multiple sub-target contours into sets of two sub-target contours each, resulting in a first set of sub-target contours including sub-target contour (1) and sub-target contour (2). A second set of sub-target contours includes sub-target contour (3) and sub-target contour (4). Since... Figure 10 The first contour line is distributed on the upper and lower sides of the sub-target contour. Assume the calculation conditions include: in each sub-target contour set, take the lower first contour line of each sub-target contour, calculate the average value of the sub-target contours, and obtain the first length. Then the average value of the first contour line in the first sub-target contour set is (5+6) / 2 = 10.5. That is, the first length of the first sub-target contour set is 10.5. The second sub-target contour set includes sub-target contour (3) and sub-target contour (4). The average value of the first contour line in the second sub-target contour set is (7+8) / 2 = 7.5. That is, the first length of the second sub-target contour set is 7.5.
[0094] In an embodiment of the present application, the second preset rule may include comparing the first lengths of the above-mentioned multiple sub-target contour sets to determine whether the first lengths of the multiple sub-target contour sets are proportional. When the first lengths of the multiple sub-target contour sets are proportional, it indicates that the target object has not been bent, and it is determined that the target object passes the detection. When the first lengths of the multiple sub-target contour sets are not proportional, it indicates that the target object has been bent, and it is determined that the target object fails the detection.
[0095] In the above method, by determining the average value of multiple first contour lines in the sub-target contour set, the first length is obtained. This makes it more accurate to determine whether the target object passes the detection based on whether the first lengths are proportional. It can greatly improve the detection accuracy and reduce the false detection rate.
[0096] Optionally, after the server in the embodiment of the present application determines whether the target object passes the detection, it may also send a message indicating qualified or unqualified detection to the terminal. For example, the server may send a message indicating qualified detection to the terminal in the form of information. Another example is that the server may send a message indicating unqualified detection to the terminal by email. The present application does not make specific limitations on this.
[0097] The following Figure 3 embodiment of
[0098] For example, assume that the target object is a warning tape. The server can obtain the image to be detected from the terminal. Use an image segmentation model to perform image segmentation on the image to be detected and extract the target contour of the warning tape. The server then finds the coordinates corresponding to the leftmost, rightmost, topmost, and bottommost four pixels belonging to the target contour, and takes the coordinate x0 of the leftmost pixel and the coordinate y0 of the topmost pixel to form the coordinate value (x0, y0) of the upper left corner of the minimum bounding rectangle; take the coordinate x1 of the rightmost pixel and the coordinate y1 of the bottommost pixel to form the coordinate value (x1, y1) of the lower right corner of the minimum bounding rectangle; use the two coordinate values (x0, y0) and (x1, y1) to determine the minimum bounding rectangle of the target contour. The server divides the target contour into 50 equal parts according to a preset number of parts to obtain multiple sub-target contours. Group the multiple sub-target contours according to a preset number of 10 to obtain 10 sub-target contour sets. Among them, the number of sub-target contours in each sub-target contour set is the same.
[0099] Suppose the first length of the first sub-target contour set is 3. The first length of the second sub-target contour set is 4.5. The first length of the third sub-target contour set is 6.75… The first length of the tenth sub-target contour set is 115.33. Then the first lengths of the multiple sub-target contour sets are proportional, and it is determined that the warning tape passes the detection.
[0100] Such as Figure 11As shown in the figure, this application provides an exemplary target object detection method flowchart.
[0101] S1101. Obtain the image to be detected;
[0102] S1102. Using a pre-established image segmentation model, perform image segmentation on the image to be detected and extract the target contour of the target object;
[0103] S1103. Determine the minimum bounding rectangle of the target outline;
[0104] S1104. Divide the target contour into multiple sub-target contours according to a preset number of parts;
[0105] S1105. Group the multiple sub-target contours according to the preset grouping to obtain a set of multiple sub-target contours;
[0106] S1106. Determine the average value of the first contour line of the sub-target contour set to obtain the first length;
[0107] S1107. Determine whether the first length of the multiple sub-target contour sets is proportional. If yes, proceed to S1108; otherwise, proceed to S1109.
[0108] S1108, The test result is confirmed to be qualified;
[0109] S1109, The test result is determined to be unqualified.
[0110] Figure 12 This is a schematic diagram of the structure of a target object detection device provided in an embodiment of this application, as shown below. Figure 12 As shown, the device includes: an acquisition module 1201, a processing module 1202, and a detection module 1203.
[0111] The acquisition module 1201 is used to acquire the image to be detected, which includes the target object and the background object.
[0112] Processing module 1202 is used to perform image segmentation on the image to be detected and extract the target contour of the target object;
[0113] The processing module 1202 is also used to determine the minimum bounding rectangle of the target contour;
[0114] The processing module 1202 is also used to segment the target contour according to preset conditions to obtain multiple sub-target contours;
[0115] The detection module 1203 is used to determine that the target object is qualified if the first contour line of multiple sub-target contours conforms to preset rules. The first contour line is the line segment length of the sub-target contour in the direction of the width of the minimum enclosing rectangle.
[0116] Optionally, image segmentation is performed on the image to be detected to extract the target contour of the target object. The processing module 1202 is specifically used for:
[0117] A pre-established image segmentation model is used to segment the image to be detected and extract the target contour of the target object.
[0118] Optionally, the image segmentation model can be pre-built in the following ways:
[0119] The DeepLabV3+ network model was trained using the PyTorch deep learning framework to obtain an image segmentation model.
[0120] Optionally, the target contour is segmented according to preset conditions to obtain multiple sub-target contours. The processing module 1202 is specifically used for:
[0121] The target contour is divided into multiple sub-target contours according to a preset number of parts.
[0122] Optionally, if the first contour line of multiple sub-target contours conforms to preset rules, the target object is determined to be qualified for detection. The detection module 1203 is specifically used for:
[0123] Multiple sub-target contours are grouped according to a preset number to obtain multiple sub-target contour sets, with each sub-target contour set containing the same number of sub-target contours.
[0124] Determine a first length for the set of sub-target contours, where the first length represents the average value of multiple first contour lines in the set of sub-target contours;
[0125] Compare the first lengths of multiple sets of sub-target contours;
[0126] If the first length of multiple sub-target contour sets is proportional, the target object is deemed to have passed the detection.
[0127] Optionally, the detection module 1203 is also used for:
[0128] If the first length of multiple sub-target contour sets is disproportionate, the target object is determined to be unqualified.
[0129] Based on the same technical concept, this application also provides an electronic device that can realize the function of the aforementioned target object detection device.
[0130] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0131] At least one processor 1301 and a memory 1302 connected to at least one processor 1301. In this embodiment, the specific connection medium between the processor 1301 and the memory 1302 is not limited. Figure 13 The example shown is the connection between processor 1301 and memory 1302 via bus 1300. Bus 1300 is... Figure 13 The connections between other components are shown in bold lines only and are not intended to be limiting. The Bus 1300 can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 13 The term is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, the processor 1301 can also be called a controller; there is no restriction on the name.
[0132] In this embodiment, memory 1302 stores instructions executable by at least one processor 1301. By executing the instructions stored in memory 1302, at least one processor 1301 can perform the target object detection method described above. Processor 1301 can implement... Figure 11 The functions of each module in the device shown.
[0133] The processor 1301 is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory 1302 and calling data stored in memory 1302, the processor can perform various functions and process data, thereby monitoring the device as a whole.
[0134] In one possible design, processor 1301 may include one or more processing units. Processor 1301 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, driver interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 1301. In some embodiments, processor 1301 and memory 1302 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.
[0135] The processor 1301 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing 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 target object detection method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules within the processor.
[0136] Memory 1302, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 1302 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 1302 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 1302 may also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0137] By designing and programming the processor 1301, the code corresponding to the target object detection method described in the foregoing embodiments can be embedded into the chip, thereby enabling the chip to execute the code during runtime. Figure 3 The target object detection method of the illustrated embodiment. How to design and program the processor 1301 is a technique well-known to those skilled in the art and will not be described further here.
[0138] It should be noted that the electronic device provided in this application embodiment can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.
[0139] This application also provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the target object detection method described above.
[0140] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0141] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the function specified in one or more boxes.
[0142] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0143] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0144] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for detecting a target object, characterized in that, The method includes: Acquire an image to be detected, the image to be detected including a target object and a background object; The image to be detected is segmented to extract the target contour of the target object; Determine the minimum bounding rectangle of the target contour; The target contour is divided according to preset conditions to obtain multiple sub-target contours; If the first contour line of the plurality of sub-target contours conforms to a preset rule, the target object is determined to be qualified for detection. The first contour line is the line segment length of the sub-target contour in the direction of the width of the minimum enclosing rectangle. The step of determining that the target object is qualified for detection when the first contour line of the plurality of sub-target contours conforms to a preset rule specifically includes: The multiple sub-target contours are grouped according to a preset number to obtain multiple sub-target contour sets, and each sub-target contour set contains the same number of sub-target contours. Determine a first length for the set of sub-target contours, wherein the first length represents the average value of a plurality of first contour lines in the set of sub-target contours; Compare the first lengths of multiple sets of sub-target contours; If the first length of the plurality of sub-target contour sets is proportional, the target object is determined to be qualified for detection.
2. The method according to claim 1, characterized in that, The step of performing image segmentation on the image to be detected and extracting the target contour of the target object specifically includes: A pre-established image segmentation model is used to segment the image to be detected and extract the target contour of the target object.
3. The method according to claim 2, characterized in that, The image segmentation model is pre-established in the following manner: The image segmentation model is obtained by training the DeepLabV3+ network model using the PyTorch deep learning framework.
4. The method according to claim 1, characterized in that, The step of segmenting the target contour according to preset conditions to obtain multiple sub-target contours specifically includes: The target contour is divided into multiple sub-target contours according to a preset number of equal parts.
5. The method according to claim 1, characterized in that, The method further includes: If the first length of the multiple sub-target contour sets is disproportionate, the target object is determined to be unqualified.
6. A target object detection device, characterized in that, include: An acquisition module is used to acquire an image to be detected, the image to be detected including a target object and a background object; The processing module is used to perform image segmentation on the image to be detected and extract the target contour of the target object; The processing module is also used to determine the minimum bounding rectangle of the target contour; The processing module is also used to segment the target contour according to preset conditions to obtain multiple sub-target contours; The detection module is used to determine that the target object is qualified for detection if the first contour line of the plurality of sub-target contours conforms to a preset rule. The first contour line is the line segment length of the sub-target contour in the direction of the width of the minimum enclosing rectangle. When the first contour line of the plurality of sub-target contours conforms to a preset rule, the target object is determined to be qualified for detection. The detection module is specifically used for: The multiple sub-target contours are grouped according to a preset number to obtain multiple sub-target contour sets, and each sub-target contour set contains the same number of sub-target contours. Determine a first length for the set of sub-target contours, wherein the first length represents the average value of a plurality of first contour lines in the set of sub-target contours; Compare the first lengths of multiple sets of sub-target contours; If the first length of the plurality of sub-target contour sets is proportional, the target object is determined to be qualified for detection.
7. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.
9. A computer program product, characterized in that, When the computer program product is invoked by a computer, it causes the computer to perform the steps of the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Defect detection method and system, electronic equipment and storage medium
CN115965588A