Target tracking detection method, system and device based on AI and medium
The AI-based method accurately distinguishes and tracks targets with and without holes by using distinct processing centers, enhancing tracking accuracy and stability in complex environments.
Patent Information
- Application Number
- CN202411211692.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-08-30
AI Technical Summary
Traditional target tracking detection methods fail to accurately distinguish and track targets with holes and without holes in complex real environments, leading to low tracking accuracy.
An AI-based method that distinguishes between targets with and without holes by determining different processing strategies, using the center of the maximum contour for hole-free targets and the center of the maximum inscribed circle for targets with holes, reducing unnecessary calculations and improving tracking stability and efficiency.
The method enhances tracking accuracy and stability by adapting to targets with and without holes, reducing misidentification and improving computational efficiency through targeted processing strategies.
Smart Images

Figure CN119180935A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of artificial intelligence, and specifically to an AI-based target tracking detection method, system, device and medium. Background Art
[0002] Object tracking and detection is an important technology in the field of computer vision and is widely used in security monitoring, intelligent transportation, human-computer interaction and many other fields.
[0003] Traditional target tracking detection methods usually fail to fully consider the impact of holes on target detection, resulting in low tracking accuracy. In recent years, with the development of artificial intelligence technology, especially the breakthrough of deep learning technology, new solutions have been provided for target tracking detection. However, how to accurately distinguish and track targets with holes and without holes in complex real environments is still a problem that needs to be solved in this field.
[0004] Therefore, how to provide a detection method that can effectively distinguish and accurately track targets with holes and targets without holes has become an important technical challenge faced by technical personnel in this field. Summary of the invention
[0005] The present application provides an AI-based target tracking and detection method, system, device and medium, which can more accurately identify and locate targets by distinguishing between targets with holes and targets without holes and adopting different processing strategies respectively, thereby reducing misidentification or missed identification caused by differences in target morphology.
[0006] In a first aspect of the present application, an AI-based target tracking and detection method is provided, which is applied to a target tracking and detection platform. The method comprises: Acquire a target image, and process the target image to distinguish between a target with holes and a target without holes; Determine a first maximum contour of the hole-free object, and determine a first center of the hole-free object according to the first maximum contour; Dividing the target with holes into an object area and a hole area, determining the maximum inscribed circle of the object area, and taking the center of the maximum inscribed circle as the second center; The object without holes is processed according to the first center, and the object with holes is processed according to the second center.
[0007] By adopting the above technical solution, by distinguishing between targets with holes and targets without holes, and adopting different processing strategies (such as using the center of the maximum contour and the center of the maximum inscribed circle as the processing reference), the method can more accurately identify and locate the target, and reduce the misidentification or missed identification caused by differences in target morphology. For targets without holes, using the center of the first maximum contour as the tracking reference can ensure that the tracking point can remain relatively stable when the target moves, rotates or slightly deforms, thereby improving the continuity and accuracy of tracking. For targets with holes, using the center of the maximum inscribed circle of the object area can effectively avoid the tracking point offset problem caused by the existence of holes, and further enhance the stability of tracking. By first distinguishing the target type and then processing them separately, it is avoided to use a unified and potentially inefficient processing method for all targets. In particular, for the processing of targets with holes, by focusing on the object area rather than the entire target area, unnecessary calculations are reduced, and the operating efficiency of the overall algorithm is improved.
[0008] Optionally, determining the maximum inscribed circle of the object area includes: Determine a second maximum contour of the object area and a third maximum contour of the hole area, construct a binary image of the target with a hole according to the second maximum contour and the third maximum contour, and determine a third center of the hole area according to the third maximum contour; The first minimum circumscribed rectangle of the binary image is determined by a contour function, and the four sides of the first minimum circumscribed rectangle are offset respectively based on the third center to obtain four first maximum inscribed circles, and the second largest inscribed circle with the largest radius among the four first maximum inscribed circles is used as the maximum inscribed circle.
[0009] By adopting the above technical solution, the second maximum contour of the object area and the third maximum contour of the hole area are determined respectively, and a binary image is constructed, so that the area to be analyzed can be clearly defined. Subsequently, the four sides of the first minimum circumscribed rectangle are offset based on the third center of the hole area to generate four potential maximum inscribed circle candidates, and the one with the largest radius is finally selected as the maximum inscribed circle. This process fully considers the influence of holes on the shape of the object area, thereby improving the accuracy of the maximum inscribed circle positioning. For targets with holes, their shapes are often more complex than those without holes. The embodiment of the present application can flexibly deal with holes of different shapes and sizes by constructing a binary image, determining the minimum circumscribed rectangle, and the center-based offset strategy, so as to achieve effective processing of complex morphological targets. This adaptability enables the method to perform well in a variety of application scenarios. Although the embodiment of the present application involves multiple steps, each step is intended to reduce unnecessary calculations and improve calculation efficiency. For example, the analysis object is simplified by constructing a binary image, and the potential maximum inscribed circle candidates are quickly generated by offsetting the edges of the minimum circumscribed rectangle. These optimization measures make the entire calculation process more efficient, and can reduce calculation time while ensuring accuracy. Since the embodiment of the present application can accurately determine the maximum inscribed circle of a target with a hole and use its center as a processing reference, it can maintain high robustness during target tracking and detection. Even if the target moves, rotates, or slightly deforms, as long as the change in the hole area does not affect the determination of the maximum inscribed circle, the embodiment of the present application can maintain stable tracking and detection effects.
[0010] Optionally, the step of offsetting four sides of the first minimum circumscribed rectangle based on the third center to obtain four first maximum inscribed circles includes: Establishing a rectangular coordinate system with the target endpoint of the first minimum circumscribed rectangle as the origin, wherein the target endpoint is any endpoint of the first minimum circumscribed rectangle; Determine the coordinates of two endpoints on a target edge, and determine a first straight line equation according to the two endpoints, wherein the target edge is any one of the four sides of the first minimum circumscribed rectangle; Determine a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints; An overlapping area between the new rectangle and the object area is determined, and a first maximum inscribed circle of the overlapping area is calculated.
[0011] By adopting the above technical solution, a rectangular coordinate system is established with the target endpoint of the first minimum circumscribed rectangle as the origin, and the straight line equation is calculated and the new rectangle is determined based on the coordinate system. The embodiment of the present application can accurately control the offset process to ensure that the new rectangle can fit the boundary of the object area closely, thereby obtaining a more accurate maximum inscribed circle. In the offset process, by introducing the coordinates of the third center (i.e., the center of the hole area), the present application can take into account the influence of the hole on the shape of the object area and avoid mistakenly including the hole area in the calculation range of the inscribed circle. This processing method makes the maximum inscribed circle finally obtained more in line with the actual situation of the object area. Although the method involves multiple steps such as coordinate transformation, straight line equation calculation and new rectangle determination, these steps are all standard operations based on geometry and linear algebra, with high computational efficiency. In addition, by only offsetting the four sides of the first minimum circumscribed rectangle and calculating the inscribed circle of the overlapping area with the object area, the embodiment of the present application avoids complex iterative calculations of the entire image, further improving computational efficiency.
[0012] Optionally, determining a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints includes: Construct a second straight line equation, a third straight line equation and a fourth straight line equation according to the first straight line equation, wherein the second straight line equation passes through the third center and is parallel to the first straight line equation, the third straight line equation passes through the first endpoint and is perpendicular to the first straight line equation, and the fourth straight line equation passes through the second endpoint and is perpendicular to the second straight line equation, and the two endpoints include the first endpoint and the second endpoint; A new rectangle is determined according to the first endpoint, the second endpoint, the third endpoint and the fourth endpoint, wherein the third endpoint is the point where the second straight line equation intersects the third straight line equation, and the fourth endpoint is the point where the second straight line equation intersects the fourth straight line equation.
[0013] By adopting the above technical solution, a second straight line equation passing through the third center (i.e., the center of the hole area) and parallel to the first straight line equation is constructed, and the embodiment of the present application can accurately control the direction and distance of the offset. At the same time, by constructing the third straight line equation and the fourth straight line equation perpendicular to the first straight line equation and the second straight line equation, it can be ensured that the edge of the new rectangle maintains a perpendicular relationship with the edge of the original circumscribed rectangle, thereby maintaining the shape of the new rectangle regular. Due to the existence of holes, the shape of the object area may become complicated. Through this method, even if the position and size of the hole change, it is possible to adapt to this change by adjusting the position of the second straight line equation, thereby ensuring that the new rectangle can fit the boundary of the object area closely. The vertices of the new rectangle are determined by the method of analytic geometry (i.e., the solution of the straight line equation and the calculation of the intersection), avoiding complex iteration and search processes. This method has high computational efficiency and can complete the determination of the new rectangle in a short time. The embodiment of the present application provides a new idea for processing target objects containing holes. By further optimizing the construction of the straight line equation and the process of calculating the intersection, the efficiency and accuracy of the algorithm can be further improved.
[0014] Optionally, constructing a second straight line equation, a third straight line equation and a fourth straight line equation according to the first straight line equation includes: Determining whether the first slope of the first straight line equation meets a preset condition; When the first slope of the first straight line equation meets the preset conditions, a second straight line equation is constructed based on the first slope and the third center, a second slope is obtained based on the ratio of a preset value to the first slope, a third straight line equation is determined based on the second slope and the coordinates of the first endpoint, and a fourth straight line equation is determined based on the second slope and the coordinates of the second endpoint.
[0015] By adopting the above technical solution, the applicability of the first slope is judged by preset conditions, so that the algorithm can flexibly adjust the construction method of the straight line equation according to different situations. This flexibility helps the algorithm better adapt to holes of different shapes and sizes, as well as object boundaries of different directions and angles. When constructing the second straight line equation, the first slope and the coordinates of the third center are directly used for calculation, ensuring that the second straight line equation is parallel to the first straight line equation and passes through the center of the hole. At the same time, the second slope is determined by the ratio of the preset value to the first slope, which can ensure that the third straight line equation and the fourth straight line equation are perpendicular to the first straight line equation and the second straight line equation, thereby improving the accuracy of the straight line equation. The ratio relationship between the slopes is used to determine the new slope, avoiding complex trigonometric function calculations or iterative solution processes. This simplified calculation method not only improves the calculation efficiency, but also reduces the errors that may occur during the calculation process. By screening and adjusting the construction method of the straight line equation by preset conditions, the algorithm can maintain stable performance in the face of noise, errors or abnormal situations. Even if there is a certain degree of uncertainty in the input data, the algorithm can obtain accurate results through reasonable adjustments.
[0016] Optionally, calculating the first maximum inscribed circle of the overlapping area includes: Define an orthogonal rectangle according to the second minimum circumscribed rectangle of the overlapping area, and divide the orthogonal rectangle into a plurality of grids, each grid representing a point; Calculating the shortest distance from each grid to the boundary of the overlapping area, and storing the shortest distance of each grid in a matrix, wherein the rows and columns of the matrix correspond to the positions of the grids, and the values of the matrix correspond to the shortest distances; A maximum value is searched in the matrix, and the maximum value is determined as the radius of the first largest inscribed circle.
[0017] By adopting the above technical solution, the overlapping area is divided into multiple grids, and the closest distance from each grid to the boundary of the overlapping area is calculated, so that the shape and size of the overlapping area can be described more meticulously. This method can capture the details of the overlapping area better than the traditional method based on the overall shape or boundary, thereby improving the accuracy of calculating the maximum inscribed circle radius. The complex geometric calculation problem is converted into a numerical search problem in a matrix, which greatly simplifies the calculation process. By constructing a distance matrix and using matrix operations to search for the maximum value, the radius of the maximum inscribed circle can be quickly determined without complex iterations or optimization calculations. Since the embodiment of the present application is based on grid division and distance calculation, the complexity and irregularity of the overlapping area boundary can be better handled. Even if the shape of the overlapping area is complex and changeable, the embodiment of the present application can also adapt by adjusting the grid size and density, thereby maintaining the robustness of the algorithm.
[0018] Optionally, constructing the binary image of the target with holes according to the second maximum contour and the third maximum contour includes: Creating a completely black image of the same size as the original image of the target with holes as a mask, using the second largest contour as a boundary, and filling the interior of the second largest contour with white to obtain an object mask; Determine the position of the hole in the image according to the third maximum contour, and create a hole mask according to the position, wherein the hole mask is a black circular or elliptical mask; The hole mask is combined with the object mask using an XOR operation to construct a binary image of the object with holes.
[0019] By adopting the above technical solution, the hole mask is designed as a black circular or elliptical mask, which enables the method to flexibly handle holes of different shapes and sizes. Although the shape of the hole may be more complex in practical applications, the circular or elliptical shape is usually sufficient as an approximate representation to meet the needs of most application scenarios. By filling the second largest contour with white to create an object mask, and performing an XOR operation on the hole mask and the object mask, the object can be effectively distinguished from the hole. The characteristics of the XOR operation make it possible to retain only those areas that neither belong to the object mask nor the hole mask when merging the mask (in this scenario, since the all-black image is used as the initial mask, only the different parts of the object mask and the hole mask are actually retained), thereby generating a clear binary image. The embodiment of the present application simplifies the image processing process by constructing masks and merging them using simple logical operations. Compared with complex image segmentation and morphological operations, this method is more intuitive and easy to implement.
[0020] In a second aspect of the present application, an AI-based target tracking and detection system is provided, including an image processing module, a non-hole processing module, a hole processing module, and an execution module, wherein: An image processing module, configured to acquire a target image and process the target image to distinguish between a target with holes and a target without holes; a non-hole processing module, configured to determine a first maximum contour of the non-hole target, and determine a first center of the non-hole target according to the first maximum contour; a hole processing module configured to divide the target with holes into an object area and a hole area, determine a maximum inscribed circle of the object area, and use the center of the maximum inscribed circle as the second center; An execution module is configured to process the object without holes according to the first center, and to process the object with holes according to the second center.
[0021] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the methods described above.
[0022] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed, any of the methods described above is executed.
[0023] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. By distinguishing the target image, the target is divided into two types: with holes and without holes. This subdivision enables the subsequent processing to be more accurately optimized for different types of targets. The center of the target without holes is determined by the maximum contour, while the center of the target with holes is determined by the maximum inscribed circle of the object area. This method effectively avoids the influence of holes on the positioning of the target center, thereby improving the accuracy of target detection; 2. Accurate target center positioning is the basis of target tracking stability. For targets without holes, the center is determined by the first maximum contour, which can ensure that even if the target undergoes certain deformation or rotation in the image, the tracking system can stably lock the target center. For targets with holes, the center is determined by the maximum inscribed circle of the object area, which can effectively avoid the interference of holes on the tracking process and improve the tracking stability. 3. By distinguishing the target types and adopting targeted processing strategies, unnecessary calculations are reduced. For example, for targets without holes, only the maximum contour needs to be considered; while for targets with holes, the object area is mainly considered. This differentiated processing not only improves the efficiency of the algorithm, but also makes resource allocation more reasonable. 4. It can flexibly deal with targets of different shapes, including those with holes and those without holes. In practical applications, the target shapes may be varied. This highly adaptable method can ensure that it can work effectively in various complex scenarios and improve the robustness of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a flowchart of the AI-based target tracking and detection method disclosed in the embodiment of the present application; Figure 2 is a binary image of a target with holes disclosed in an embodiment of the present application; Figure 3 is a schematic diagram of the positions of the first minimum circumscribed rectangle and the third center disclosed in the embodiment of the present application; Figure 4 is a schematic diagram of an embodiment of offsetting the side of the first minimum circumscribed rectangle disclosed in an embodiment of the present application; Figure 5 is a schematic diagram of another embodiment of offsetting the side of the first minimum circumscribed rectangle disclosed in the embodiment of the present application; Figure 6 It is a schematic diagram showing the effects disclosed in the embodiments of the present application; Figure 7 It is a module schematic diagram of an AI-based target tracking and detection system disclosed in an embodiment of the present application; Figure 8 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application.
[0025] Explanation of the reference numerals: 701, image processing module; 702, non-hole processing module; 703, hole processing module; 704, execution module; 801, processor; 802, communication bus; 803, user interface; 804, network interface; 805, memory. DETAILED DESCRIPTION
[0026] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0027] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.
[0028] In the description of the embodiments of the present application, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0029] This embodiment discloses a target tracking detection method based on AI (artificial intelligence), which is applied to a target tracking detection platform. Figure 1 is a flow chart of the AI-based target tracking and detection method disclosed in the embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps: S110, acquiring a target image, and processing the target image to distinguish between targets with holes and targets without holes; Obtain a target image including the target object, and perform denoising on the target image to eliminate noise interference in the image, such as random noise, sensor noise, etc. This helps to improve the accuracy and efficiency of subsequent processing. It may be necessary to perform image enhancement processing, such as contrast enhancement, edge sharpening, etc., to better highlight the target features for subsequent analysis. Feature extraction is a key step in distinguishing between targets with holes and those without holes. This usually involves identifying features such as shape, texture, and edges in the image. For hole detection, special attention is paid to blank or low-brightness areas inside the target, which may indicate the presence of holes. The target contour is extracted by contour detection algorithms (such as Canny edge detector, Hough transform, etc.). For targets with holes, their contours may contain small internal contours (representing holes), while the contours of targets without holes are relatively simple, usually with only one external contour. Analyzing the hierarchy and topological relationship of the contours can further confirm whether the target contains holes. For example, if nested contours are detected, it is likely that there are holes inside the target. Based on the results of the above feature extraction, a classification algorithm (such as support vector machine, neural network, etc.) is used to classify the target and distinguish between targets with holes and targets without holes. The recognition process may also need to consider other factors, such as the size, shape, texture, etc. of the target to improve the accuracy and robustness of the classification.
[0030] S120, determining a first maximum contour of the hole-free object, and determining a first center of the hole-free object according to the first maximum contour; Edge detection is performed on the hole-free target image. Edge detection is a basic technique in image processing, which is used to identify points in the image where the brightness changes significantly. These points usually correspond to the boundaries of the object. Common edge detection algorithms include Canny edge detector, Sobel operator, etc. On the basis of edge detection, the complete outline of the target is extracted from the image through contour extraction algorithms (such as Hough transform, contour tracking, etc.). Since the target is hole-free, its contour should be continuous and does not contain small internal contours. If there are multiple contours in the image, they need to be screened according to the target characteristics (such as size, shape, position, etc.) to determine the first largest contour of the hole-free target. Usually, the first largest contour refers to the contour with the largest area or the longest perimeter, because it is most likely to represent the main detection target. When the first largest contour of the hole-free target is determined, the first center of the target can be determined by calculating the geometric center of the contour. The geometric center (also called the center of mass or centroid) is the average position of the mass of all points on the contour, which can be obtained by weighted averaging the points on the contour. For discrete contours, the weighted average of pixel coordinates can be used to calculate the geometric center. Another way to determine the center of an object is to use the minimum enclosing rectangle or ellipse of the contour. Calculate the parameters of the minimum enclosing rectangle or ellipse (such as center coordinates, size, orientation, etc.) based on the contour points. Then, the center of the minimum enclosing rectangle or ellipse is used as the first center of the object. This method is particularly effective when dealing with objects with regular shapes.
[0031] S130, dividing the target with holes into an object area and a hole area, determining a maximum inscribed circle of the object area, and taking the center of the maximum inscribed circle as a second center; The extracted contours are analyzed, and the contours belonging to the outside of the object and the contours belonging to the inside of the hole are distinguished according to the hierarchy and topological relationship of the contours. Usually, the contour outside the object is the largest or outermost contour, while the contour inside the hole is a smaller contour nested inside the object contour. Based on these contours, the image is divided into the object area (i.e., the area surrounded by the outer contour) and the hole area (i.e., the area surrounded by the inner contour). The inscribed circle refers to the largest circle that is tangent to the boundary of the object area and completely located in the object area. Finding the largest inscribed circle is an optimization problem that can be solved by a variety of algorithms, such as variants of the minimum circle cover problem, algorithms based on convex hull or concave hull, etc. A common method is to use Voronoi diagrams or Delaunay triangulations to approximate the shape of the object area and search for the largest inscribed circle based on this. Another method is to iteratively try circles with different positions and radii until a circle with the largest radius that is tangent to the boundary of the object area is found. When the largest inscribed circle of the object area is determined, its center can be used as the second center of the target with a hole. This center position is usually more representative of the actual position of the target with a hole than simply taking the geometric center of the object outline, because it takes into account the impact of the hole on the target shape.
[0032] Determining the maximum inscribed circle of the object area comprises: Determine a second maximum contour of the object area and a third maximum contour of the hole area, construct a binary image of the target with a hole according to the second maximum contour and the third maximum contour, and determine a third center of the hole area according to the third maximum contour; The first minimum circumscribed rectangle of the binary image is determined by a contour function, and the four sides of the first minimum circumscribed rectangle are offset respectively based on the third center to obtain four first maximum inscribed circles, and the second largest inscribed circle with the largest radius among the four first maximum inscribed circles is used as the maximum inscribed circle.
[0033] Create a binary image on the original image using the maximum contour of the object area and the maximum contour of the hole area. Figure 2 is a binary image of a target with holes disclosed in the embodiment of the present application, such as Figure 2As shown, in this binary image, the object area is marked as 1 (or white), while the background and other areas (including holes) are marked as 0 (or black). For the third largest contour of the hole area, the geometric center calculation or the minimum circumscribed rectangle / ellipse method can be used to determine its center, that is, the third center. This center will be used in the subsequent inscribed circle calculation. On the binary image, use the contour function (such as minAreaRect in OpenCV) to find the minimum circumscribed rectangle containing the object area. This rectangle will be used as a reference for the subsequent inscribed circle calculation. Based on the third center, the four sides of the first minimum circumscribed rectangle are offset respectively. The offset distance can be adjusted as needed, but it is usually related to the size and position of the hole. For each side, after the offset, it will intersect with the boundary of the object area at two points. Through these two points and the third center, an inscribed circle can be determined. Therefore, four inscribed circles will be generated for the four sides. Compare the radii of these four inscribed circles, and select the one with the largest radius as the maximum inscribed circle of the object area.
[0034] By determining the maximum contour of the object area and the maximum contour of the hole area, the scope of the object and the hole can be more accurately defined. This helps to reduce the error caused by inaccurate contour recognition. Constructing a binary image and offsetting the edge of the first minimum circumscribed rectangle based on the third center of the hole area to find the possible maximum inscribed circle position, this method takes into account the actual impact of the hole on the shape of the object, thereby improving the accuracy of the maximum inscribed circle determination. The embodiment of the present application not only considers the overall shape of the object area, but also pays special attention to the position and size of the hole area, and finds multiple possible maximum inscribed circle positions by offsetting the edge of the circumscribed rectangle, and selects the one with the largest radius. This multi-step verification and selection process enhances the robustness of the algorithm, enabling it to cope with holes of different shapes and sizes. The embodiment of the present application is not only applicable to targets with a single hole, but can also be extended to targets with multiple holes or complex shapes. By appropriately adjusting the algorithm parameters and steps, the target detection requirements in different application scenarios can be flexibly responded to.
[0035] The step of constructing the binary image of the object with holes according to the second maximum contour and the third maximum contour comprises: creating a completely black image of the same size as the original image of the object with holes as a mask, using the second maximum contour as a boundary, and filling the interior of the second maximum contour with white to obtain an object mask; Determine the position of the hole in the image according to the third maximum contour, and create a hole mask according to the position, wherein the hole mask is a black circular or elliptical mask; The hole mask is combined with the object mask using an XOR operation to construct a binary image of the object with holes.
[0036] The second largest contour is regarded as the boundary, and the area inside the contour is filled with white (i.e., the pixel value is set to 255) in the mask image. This filling process is usually implemented using a filling algorithm in a graphics library, such as a seed filling algorithm. The filled image is called the "object mask", which represents the position and shape of the object in the image. Based on the third largest contour (i.e., the contour of the hole area), the specific position of the hole in the image can be determined. This step usually involves geometric calculations of the contour, such as calculating the centroid (center point) or bounding box of the contour. Based on the location and possible shape (circular or elliptical) of the hole, a black circular or elliptical mask of the corresponding size and shape is created on the mask image. The size and shape of this mask should match the actual size and shape of the hole to ensure that subsequent operations can accurately remove the hole area from the object mask. The hole mask is merged with the object mask using an exclusive OR operation (XOR). The characteristic of the exclusive OR operation is that when the two compared bits are different, the result is 1 (true), otherwise it is 0 (false). In this scenario, since the hole mask is black (pixel value is 0) and the object mask is white (pixel value is 255) outside the hole position, the XOR operation will remove the black area (hole) in the hole mask from the object mask while leaving other positions unchanged. After the XOR operation, a new mask image is obtained, which only contains the object area (excluding the hole), and the object area is white and the background is black. This image is the binary image of the target with holes that we want to construct. It clearly shows the shape and position of the object while removing the influence of the hole area.
[0037] By filling the second largest contour with white to form an object mask, it is ensured that only the main part of the target object is retained, excluding noise and unnecessary edges. The creation of the hole mask takes into account the actual position and shape of the hole (black circle or ellipse), which enables the hole to be accurately represented in the binary image, thereby improving the accuracy of subsequent processing. Creating a completely black image of the same size as the original image as the starting point of the mask simplifies the mask generation process. By applying the object contour and the hole contour to this basic mask respectively, the target object and the hole area can be clearly distinguished. The object mask and the hole mask are merged using an XOR operation. This method is concise and efficient, and can directly generate a binary image containing hole information without complex image processing operations. By decomposing the problem into the generation of object mask and hole mask, and the merging between them, the complex image processing task is simplified into a few simple steps, thereby improving the processing efficiency. Since the binary image only contains black and white colors, subsequent image processing operations (such as contour detection, shape analysis, etc.) will also be more efficient. The embodiment of the present application can handle holes of different shapes, sizes and positions because it does not construct a mask based on the specific shape or size of the hole, but determines its position based on the maximum contour of the hole. This makes the method more robust when dealing with complex images. By using XOR operations to merge masks, errors caused by mask overlap or misalignment are reduced, and the accuracy and reliability of the binary image are improved.
[0038] The step of offsetting the four sides of the first minimum circumscribed rectangle based on the third center to obtain four first maximum inscribed circles comprises: Establishing a rectangular coordinate system with the target endpoint of the first minimum circumscribed rectangle as the origin, wherein the target endpoint is any endpoint of the first minimum circumscribed rectangle; Determine the coordinates of two endpoints on a target edge, and determine a first straight line equation according to the two endpoints, wherein the target edge is any one of the four sides of the first minimum circumscribed rectangle; Determine a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints; An overlapping area between the new rectangle and the object area is determined, and a first maximum inscribed circle of the overlapping area is calculated.
[0039] Figure 3 : is a schematic diagram of the positions of the first minimum circumscribed rectangle and the third center disclosed in the embodiment of the present application, such as Figure 3As shown in the figure, the rectangle formed by the four endpoints a, b, e and f is the first minimum circumscribed rectangle, the circle in the figure is the hole, and c is the center of the hole (i.e., the third center). Select one of the endpoints of the first minimum circumscribed rectangle as the origin to establish a rectangular coordinate system. This selection is arbitrary, but usually a corner point of the rectangle is selected for ease of calculation and representation. The establishment of the coordinate system allows us to use mathematical equations to describe the sides and internal points of the rectangle. Select one of the four sides of the first minimum circumscribed rectangle as the target side. Next, determine the coordinates of the two endpoints on this target side, and use the coordinates of these two endpoints to calculate the straight line equation of the side. The straight line equation is usually expressed in the form of Ax+By+C=0, where A, B, C are constants, and x and y are points in the coordinate system. Using the coordinates of the third center (a known point that may represent an important position inside the object, such as the center of a hole), the straight line equation of the target side, and the coordinates of the two endpoints on the target side, a straight line parallel to the target side and passing through the third center can be calculated. This new straight line will serve as a side of the new rectangle. In a similar way, the other three sides can be calculated to form a new rectangle. This new rectangle may represent an extension or offset of the third center after taking into account the direction of the target side. Determine the overlap area between the new rectangle and the object area (i.e., inside the outline of the actual object in the original image). This overlapping area may be a complex shape, but it contains the parts we are interested in, such as holes or internal depressions. Finally, calculate the first largest inscribed circle in the overlapping area. This inscribed circle is the largest circle that satisfies the following conditions: it is completely inside the overlapping area and touches the boundary of the overlapping area at least two points (i.e., it is inscribed). Calculating such a circle usually requires some geometric or numerical optimization methods, such as gradient descent, linear programming, or specialized geometric algorithms.
[0040] By selecting any endpoint of the first minimum circumscribed rectangle as the origin to establish a rectangular coordinate system, this flexibility allows the algorithm to adapt to objects of different shapes and positions, enhancing the versatility and robustness of the algorithm. By determining the straight line equation of the target side (i.e., any side of the first minimum circumscribed rectangle), and using this equation combined with the coordinates of the third center to calculate the new rectangle (i.e., the offset rectangle), this method ensures the accuracy of the calculation. Since the straight line equation can accurately describe the position and direction of the line segment, the offset calculation can be performed accurately. After determining the new rectangle, the algorithm further calculates the overlapping area between the new rectangle and the object area, and searches for the first largest inscribed circle in the overlapping area. This step aims to find an inscribed circle that is as large as possible and completely located in the object area. For some application scenarios (such as target detection, object recognition, path planning, etc.), such an inscribed circle has very important practical significance and can provide more accurate shape description or boundary information. Although the process involves multiple steps and calculations, each step has a clear mathematical basis and efficient algorithm support (such as the calculation of straight line equations, the offset of rectangles, the determination of overlapping areas and the calculation of inscribed circles, etc.). These steps work together to significantly improve the computational efficiency of the entire process.
[0041] Determining a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints includes: Construct a second straight line equation, a third straight line equation and a fourth straight line equation according to the first straight line equation, wherein the second straight line equation passes through the third center and is parallel to the first straight line equation, the third straight line equation passes through the first endpoint and is perpendicular to the first straight line equation, and the fourth straight line equation passes through the second endpoint and is perpendicular to the second straight line equation, and the two endpoints include the first endpoint and the second endpoint; A new rectangle is determined according to the first endpoint, the second endpoint, the third endpoint and the fourth endpoint, wherein the third endpoint is the point where the second straight line equation intersects the third straight line equation, and the fourth endpoint is the point where the second straight line equation intersects the fourth straight line equation.
[0042] Construct a second line through the third center and parallel to the equation of the first line, construct a third line through the first endpoint and perpendicular to the equation of the first line, and construct a fourth line through the second endpoint and perpendicular to the equation of the second line. The third endpoint is the point where the equations of the second and third lines intersect. This is usually done by solving a system of simultaneous equations of the two equations. The coordinates of the solution are the coordinates of the third endpoint. The fourth endpoint is the point where the equations of the second and fourth lines intersect. Again, this is done by solving a system of simultaneous equations of the two equations. The coordinates of the solution are the coordinates of the fourth endpoint. Determine the new rectangle based on the first, second, third, and fourth endpoints.
[0043] like Figure 4 As shown, a and b are points before offset, A and B are points after offset, L1 is the first straight line equation, the first straight line equation L1 is translated and passes through point c to obtain the second straight line equation L2, a third straight line equation is set perpendicular to the first straight line equation and passes through point a, and a fourth straight line equation is set perpendicular to the first straight line equation and passes through point b. Figure 4 (a) and Figure 4 (b) are the cases where the equation of the first straight line is horizontal and vertical respectively.
[0044] This method ensures the precision and accuracy of the new rectangle by accurately calculating the intersection of the line equation to determine the vertices (i.e., endpoints). Regardless of the accuracy of the original data, as long as the input data is correct, the generated rectangle will be drawn strictly according to these data, reducing human errors. It can flexibly construct new rectangles based on different inputs (such as different line equations, center point and endpoint coordinates). This means that it can adapt to a variety of application scenarios, and the desired rectangle shape and position can be obtained by simply adjusting the input parameters. Although it involves the construction of line equations and the calculation of intersections, these operations are relatively efficient in computers. Once the line equations are determined, calculating the intersections (i.e., the vertices of the rectangle) usually only requires basic mathematical operations, which makes the whole process computationally feasible and relatively fast.
[0045] The constructing of the second straight line equation, the third straight line equation and the fourth straight line equation according to the first straight line equation comprises: determining whether the first slope of the first straight line equation meets a preset condition; When the first slope of the first straight line equation meets the preset conditions, a second straight line equation is constructed based on the first slope and the third center, a second slope is obtained based on the ratio of a preset value to the first slope, a third straight line equation is determined based on the second slope and the coordinates of the first endpoint, and a fourth straight line equation is determined based on the second slope and the coordinates of the second endpoint.
[0046] Figure 5 is a schematic diagram of an embodiment of offsetting the side of the first minimum circumscribed rectangle disclosed in an embodiment of the present application, such as Figure 5As shown, the rectangle formed by the four endpoints a, b, e and f is the first minimum circumscribed rectangle, the points to be offset are a and b, and the offset results are A and B. If the slope of the first linear equation meets the preset conditions (i.e., not zero and not positive infinity), the first linear equation L1 is formed according to a and b, a and b are the first endpoint and the second endpoint respectively, the second linear equation L2 has the same slope as L1, and the second linear equation L2 passes through point c (the center of the hole), thereby determining the second linear equation L2. The product of the slope of the third linear equation L3 and the slope of the first linear equation L1 is -1, and the third linear equation L3 passes through point a, so the third linear equation L3 is obtained. Because the third linear equation L3 intersects with the second linear equation L2 at point A, the coordinates of A are obtained. The product of the slope of the fourth linear equation L4 and the slope of the first linear equation L1 is -1, and the fourth linear equation L4 passes through point b, so the fourth linear equation L4 is obtained. Because the fourth linear equation L4 intersects with the second linear equation L2 at point B, the coordinates of B are obtained. The two fixed points (e and f) and the offset results (points A and B) are reassembled into a new rotated rectangle, and the new rotated rectangle is compared with the original image to obtain the overlapping area, so as to draw the maximum inscribed circle in the overlapping area.
[0047] The calculating the first maximum inscribed circle of the overlapping area comprises: Define an orthogonal rectangle according to the second minimum circumscribed rectangle of the overlapping area, and divide the orthogonal rectangle into a plurality of grids, each grid representing a point; Calculating the shortest distance from each grid to the boundary of the overlapping area, and storing the shortest distance of each grid in a matrix, wherein the rows and columns of the matrix correspond to the positions of the grids, and the values of the matrix correspond to the shortest distances; A maximum value is searched in the matrix, and the maximum value is determined as the radius of the first largest inscribed circle.
[0048] Define an orthogonal rectangle based on the minimum enclosing rectangle of the overlapping area (i.e., the second minimum enclosing rectangle). This orthogonal rectangle should completely contain the overlapping area, and its boundaries are parallel to the coordinate axes (i.e., horizontally and vertically). Divide this orthogonal rectangle into multiple grids. Each grid represents a point, and the divisions of these grids should be fine enough to accurately reflect the shape and size of the overlapping area. The density of the grid division depends on the required computational accuracy and performance requirements. For each grid point (or the center point of the grid), calculate its closest distance to the boundary of the overlapping area. This distance can be calculated in a variety of ways, such as using a point-to-polygon distance calculation algorithm, or by traversing the boundary segments of the overlapping area to find the closest point to the grid point. The calculated closest distances are stored in a matrix, where the rows and columns of the matrix correspond to the positions of the grids, and the values of the matrix correspond to the closest distances of each grid point to the boundary of the overlapping area. In the matrix storing the closest distances of all grid points to the boundary of the overlapping area, search for the maximum value. This maximum value represents the radius of the largest inscribed circle that can be placed in the overlapping area. Because the center of the inscribed circle must be within the overlapping area, and its radius cannot exceed the shortest distance from the center to the boundary of the overlapping area, the maximum value in the matrix is the radius of the first largest inscribed circle.
[0049] By mapping the overlapping area to an orthogonal rectangle and further dividing the rectangle into multiple grids, a detailed division of the overlapping area can be achieved. Each grid represents a point and calculates the closest distance from the point to the boundary of the overlapping area. This method can capture the shape and size of the overlapping area more accurately, thereby more accurately calculating the radius of the largest inscribed circle. After converting the problem into a matrix operation, the efficiency of matrix operations can be used to speed up the calculation process. Each row and column of the matrix corresponds to the position of the grid, and the value of the matrix stores the closest distance from each grid to the boundary of the overlapping area. This data structure makes the subsequent maximum value search operation simple and efficient. After visualizing the overlapping area and the grid system, you can intuitively understand the distance from each grid point to the boundary and how these distances affect the radius of the largest inscribed circle. This intuitiveness helps to verify the correctness of the calculation results and make adjustments and optimizations when necessary.
[0050] S140: Process the object without holes according to the first center, and process the object with holes according to the second center.
[0051] Figure 6 It is a schematic diagram showing the effects disclosed in the embodiments of the present application. Figure 6As shown, the outer rectangular frame is the minimum circumscribed rectangle of the whole, the inner rectangular frame is the minimum circumscribed rectangle of the hole, and the inner circle is the maximum inscribed circle of the object area. For example, in the suction of recyclables, recyclables without holes can be sucked according to the first center, and recyclables with holes can be sucked according to the second center.
[0052] The success rate of inscribed circle detection is 93.25%. The specific error statistics are shown in the following table.
[0053] There are the following problems: (1) Bottle recognition is normal, hole recognition is normal, but the correct inscribed circle is not detected (the circle may be biased towards a narrower area); (2) Bottle recognition is abnormal (the detected bottle is covered by other bottles and becomes a mask area of multiple bottles), hole recognition is normal, but the correct inscribed circle is not detected; (3) The hole is blocked and the hole is missed (the hole is not identified); (4) Misdetected holes; (5) There really is a bottle with two holes; (6) Draw the inscribed circle to the side of the bottle; (7)Others.
[0054] This embodiment also discloses an AI-based target tracking and detection system. Figure 7 is a schematic diagram of a module of an AI-based target tracking and detection system disclosed in an embodiment of the present application, such as Figure 7 As shown, the system includes an image processing module 701, a non-hole processing module 702, a hole processing module 703 and an execution module 704, wherein: An image processing module 701 is configured to acquire a target image and process the target image to distinguish between a target with holes and a target without holes; A hole-free processing module 702 is configured to determine a first maximum contour of the hole-free object, and determine a first center of the hole-free object according to the first maximum contour; A hole processing module 703 is configured to divide the target with holes into an object area and a hole area, determine the maximum inscribed circle of the object area, and use the center of the maximum inscribed circle as the second center; The execution module 704 is configured to process the object without holes according to the first center, and process the object with holes according to the second center.
[0055] The hole processing module 703 is configured to: Determine a second maximum contour of the object area and a third maximum contour of the hole area, construct a binary image of the target with a hole according to the second maximum contour and the third maximum contour, and determine a third center of the hole area according to the third maximum contour; The first minimum circumscribed rectangle of the binary image is determined by a contour function, and the four sides of the first minimum circumscribed rectangle are offset respectively based on the third center to obtain four first maximum inscribed circles, and the second largest inscribed circle with the largest radius among the four first maximum inscribed circles is used as the maximum inscribed circle.
[0056] The hole processing module 703 is further configured to: Creating a completely black image of the same size as the original image of the target with holes as a mask, using the second largest contour as a boundary, and filling the interior of the second largest contour with white to obtain an object mask; Determine the position of the hole in the image according to the third maximum contour, and create a hole mask according to the position, wherein the hole mask is a black circular or elliptical mask; The hole mask is combined with the object mask using an XOR operation to construct a binary image of the object with holes.
[0057] The hole processing module 703 is further configured to: Establishing a rectangular coordinate system with the target endpoint of the first minimum circumscribed rectangle as the origin, wherein the target endpoint is any endpoint of the first minimum circumscribed rectangle; Determine the coordinates of two endpoints on a target edge, and determine a first straight line equation according to the two endpoints, wherein the target edge is any one of the four sides of the first minimum circumscribed rectangle; Determine a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints; An overlapping area between the new rectangle and the object area is determined, and a first maximum inscribed circle of the overlapping area is calculated.
[0058] The hole processing module 703 is further configured to: Construct a second straight line equation, a third straight line equation and a fourth straight line equation according to the first straight line equation, wherein the second straight line equation passes through the third center and is parallel to the first straight line equation, the third straight line equation passes through the first endpoint and is perpendicular to the first straight line equation, and the fourth straight line equation passes through the second endpoint and is perpendicular to the second straight line equation, and the two endpoints include the first endpoint and the second endpoint; A new rectangle is determined according to the first endpoint, the second endpoint, the third endpoint and the fourth endpoint, wherein the third endpoint is the point where the second straight line equation intersects the third straight line equation, and the fourth endpoint is the point where the second straight line equation intersects the fourth straight line equation.
[0059] The hole processing module 703 is further configured to: Determining whether the first slope of the first straight line equation meets a preset condition; When the first slope of the first straight line equation meets the preset conditions, a second straight line equation is constructed based on the first slope and the third center, a second slope is obtained based on the ratio of a preset value to the first slope, a third straight line equation is determined based on the second slope and the coordinates of the first endpoint, and a fourth straight line equation is determined based on the second slope and the coordinates of the second endpoint.
[0060] The hole processing module 703 is further configured to: Define an orthogonal rectangle according to the second minimum circumscribed rectangle of the overlapping area, and divide the orthogonal rectangle into a plurality of grids, each grid representing a point; Calculating the shortest distance from each grid to the boundary of the overlapping area, and storing the shortest distance of each grid in a matrix, wherein the rows and columns of the matrix correspond to the positions of the grids, and the values of the matrix correspond to the shortest distances; A maximum value is searched in the matrix, and the maximum value is determined as the radius of the first largest inscribed circle.
[0061] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0062] This embodiment also discloses an electronic device, referring to Figure 8 The electronic device may include: at least one processor 801 , at least one communication bus 802 , a user interface 803 , a network interface 804 , and at least one memory 805 .
[0063] The communication bus 802 is used to realize the connection and communication between these components.
[0064] The user interface 803 may include a display screen (Display) and a camera (Camera), and the optional user interface 803 may also include a standard wired interface and a wireless interface.
[0065] The network interface 804 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0066] Among them, the processor 801 may include one or more processing cores. The processor 801 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 805, and calling data stored in the memory 805. Optionally, the processor 801 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 801 can integrate one or more combinations of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 801, and it can be implemented separately through a chip.
[0067] Among them, the memory 805 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 805 includes a non-transitory computer-readable storage medium. The memory 805 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 805 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 805 may also be optionally at least one storage device located away from the aforementioned processor 801. As Figure 8 As shown, the memory 805 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program of an AI-based target tracking and detection method.
[0068] exist Figure 8 In the electronic device shown, the user interface 803 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 801 can be used to call the application program of the AI-based target tracking and detection method stored in the memory 805. When executed by one or more processors 801, the electronic device executes one or more methods in the above-mentioned embodiments.
[0069] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.
[0070] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0071] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0072] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0073] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0074] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory 805 and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory 805 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk.
[0075] The above is only an exemplary embodiment of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. An AI-based target tracking detection method, characterized in that: Applied to a target tracking and detection platform, the method comprises: Acquire a target image, and process the target image to distinguish between a target with holes and a target without holes; Determine a first maximum contour of the hole-free object, and determine a first center of the hole-free object according to the first maximum contour; Dividing the target with holes into an object area and a hole area, determining the maximum inscribed circle of the object area, and taking the center of the maximum inscribed circle as the second center; The object without holes is processed according to the first center, and the object with holes is processed according to the second center.
2. The AI-based target tracking detection method according to claim 1, characterized in that: Determining the maximum inscribed circle of the object area comprises: Determine a second maximum contour of the object area and a third maximum contour of the hole area, construct a binary image of the target with a hole according to the second maximum contour and the third maximum contour, and determine a third center of the hole area according to the third maximum contour; The first minimum circumscribed rectangle of the binary image is determined by a contour function, and the four sides of the first minimum circumscribed rectangle are offset respectively based on the third center to obtain four first maximum inscribed circles, and the second largest inscribed circle with the largest radius among the four first maximum inscribed circles is used as the maximum inscribed circle.
3. The AI-based target tracking detection method according to claim 2, characterized in that: The step of offsetting the four sides of the first minimum circumscribed rectangle based on the third center to obtain four first maximum inscribed circles comprises: Establishing a rectangular coordinate system with the target endpoint of the first minimum circumscribed rectangle as the origin, wherein the target endpoint is any endpoint of the first minimum circumscribed rectangle; Determine the coordinates of two endpoints on a target edge, and determine a first straight line equation according to the two endpoints, wherein the target edge is any one of the four sides of the first minimum circumscribed rectangle; Determine a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints; An overlapping area between the new rectangle and the object area is determined, and a first maximum inscribed circle of the overlapping area is calculated.
4. The AI-based target tracking detection method according to claim 3, characterized in that: Determining a new rectangle according to the first straight line equation, the coordinates of the third center and the coordinates of the two endpoints includes: Construct a second straight line equation, a third straight line equation and a fourth straight line equation according to the first straight line equation, wherein the second straight line equation passes through the third center and is parallel to the first straight line equation, the third straight line equation passes through the first endpoint and is perpendicular to the first straight line equation, and the fourth straight line equation passes through the second endpoint and is perpendicular to the second straight line equation, and the two endpoints include the first endpoint and the second endpoint; A new rectangle is determined according to the first endpoint, the second endpoint, the third endpoint and the fourth endpoint, wherein the third endpoint is the point where the second straight line equation intersects the third straight line equation, and the fourth endpoint is the point where the second straight line equation intersects the fourth straight line equation.
5. The AI-based target tracking detection method according to claim 3, characterized in that: The constructing of the second straight line equation, the third straight line equation and the fourth straight line equation according to the first straight line equation comprises: Determining whether the first slope of the first straight line equation meets a preset condition; When the first slope of the first straight line equation meets the preset conditions, a second straight line equation is constructed based on the first slope and the third center, a second slope is obtained based on the ratio of a preset value to the first slope, a third straight line equation is determined based on the second slope and the coordinates of the first endpoint, and a fourth straight line equation is determined based on the second slope and the coordinates of the second endpoint.
6. The AI-based target tracking detection method according to claim 3, characterized in that: The calculating the first maximum inscribed circle of the overlapping area comprises: Define an orthogonal rectangle according to the second minimum circumscribed rectangle of the overlapping area, and divide the orthogonal rectangle into a plurality of grids, each grid representing a point; Calculating the shortest distance from each grid to the boundary of the overlapping area, and storing the shortest distance of each grid in a matrix, wherein the rows and columns of the matrix correspond to the positions of the grids, and the values of the matrix correspond to the shortest distances; A maximum value is searched in the matrix, and the maximum value is determined as the radius of the first largest inscribed circle.
7. The AI-based target tracking detection method according to claim 2, characterized in that: The step of constructing the binary image of the target with holes according to the second maximum contour and the third maximum contour comprises: Creating a completely black image of the same size as the original image of the target with holes as a mask, using the second largest contour as a boundary, and filling the interior of the second largest contour with white to obtain an object mask; Determine the position of the hole in the image according to the third maximum contour, and create a hole mask according to the position, wherein the hole mask is a black circular or elliptical mask; The hole mask is combined with the object mask using an XOR operation to construct a binary image of the object with holes.
8. An AI-based target tracking and detection system, characterized in that: It includes an image processing module, a non-hole processing module, a hole processing module and an execution module, wherein: An image processing module, configured to acquire a target image, and process the target image to distinguish between a target with holes and a target without holes; a non-hole processing module, configured to determine a first maximum contour of the non-hole target, and determine a first center of the non-hole target according to the first maximum contour; a hole processing module configured to divide the target with holes into an object area and a hole area, determine a maximum inscribed circle of the object area, and use the center of the maximum inscribed circle as the second center; An execution module is configured to process the object without holes according to the first center, and to process the object with holes according to the second center.
9. An electronic device, characterized in that: It includes a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 7 is executed.
Citation Information
Patent Citations
Method of acquiring initial contour during moving target detection based on level set
CN106169186A
Circular feature detection method and device and storage device
CN112508009A
Knitted sheet hole automatic identification method
CN116468717A
Workpiece contour fitting positioning method and device and storage medium
CN116958515A
Catenary geometric parameter measurement method based on binocular machine vision
CN117036359A
