An image red rectangular mark frame detection method based on HSV color space

CN122714574BActive Publication Date: 2026-10-30CHONGQING SHOUXUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611178828.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-10-30
Estimated Expiration
2046-08-05

AI Technical Summary

Technical Problem

[0004]此类方法存在以下局限性:其一,对图像中存在的所有矩形结构均会产生响应,无法有效区分特定颜色的矩形标注框与背景中几何形状相似的其他矩形物体(如窗户、建筑物边缘、产品外壳等),导致误检率偏高;其二,当标注框颜色与背景对比度较低或存在部分遮挡时,边缘检测的完整性难以保证,易导致矩形漏检

Benefits of technology

[0019]本发明的有益效果:本发明通过将HSV颜色空间的红色像素提取与矩形几何特征多级验证有机结合,相较于仅依赖几何特征或仅依赖颜色信息的传统检测方法,可有效排除背景中同色非矩形目标与异色矩形干扰区域的影响,显著降低红色矩形标注框的误检率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122714574B_ABST
    Figure CN122714574B_ABST
Patent Text Reader

Abstract

The application provides an image red rectangular mark detection method based on an HSV color space, and the method comprises the following steps: converting a to-be-detected image to the HSV color space to obtain hue, saturation and lightness components, setting at least two red detection intervals to screen pixels, and obtaining an initial red region mask; performing morphological processing and connected domain area filtering on the mask; performing contour detection on the optimized mask; performing polygon approximation on the filtered contour, judging whether the contour meets the rectangular feature, and converting the contour meeting the condition into a rectangular mark; calculating the intersection and union ratio between the rectangular marks, and outputting the position coordinates of the red rectangular marks; and through the combination of the red pixel extraction and the multi-level verification of the rectangular geometric feature, the application can exclude the interference of the non-rectangular targets with the same color and the rectangular regions with different colors, and reduce the false detection rate. The adaptive threshold mechanism is used to dynamically adjust the detection lower limit of the saturation and lightness, and the robustness is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision and image processing technology, and in particular to a method for detecting red rectangular bounding boxes in images based on the HSV color space. Background Technology

[0002] In numerous image processing applications, using rectangles of specific colors (especially red) to mark target areas is a common visualization technique. For example, in security monitoring systems, red boxes are often used to identify abnormal events; in highway incident detection systems, red boxes mark vehicles awaiting review; in industrial quality inspection equipment, red boxes delineate defect locations; in medical image analysis software, red boxes mark lesion areas; and in smart terminal applications, users often use red boxes to mark key information in screenshots. Downstream automated processing (such as automatic cropping, content magnification, and secondary recognition) typically requires precise acquisition of the position and boundary coordinates of these red rectangles.

[0003] Existing rectangular bounding box detection technologies can be mainly divided into the following two categories: (I) Rectangle Detection Method Based on Geometric Features These methods do not rely on color information, but extract geometrically rectangular structures from images through edge detection (such as the Canny operator), line detection (such as the Hough transform), or corner detection.

[0004] This type of method has the following limitations: First, it will respond to all rectangular structures in the image, and cannot effectively distinguish between rectangular bounding boxes of specific colors and other rectangular objects with similar geometric shapes in the background (such as windows, building edges, product shells, etc.), resulting in a high false detection rate; Second, when the color of the bounding box has low contrast with the background or is partially occluded, the integrity of edge detection is difficult to guarantee, which can easily lead to missed detection of rectangles.

[0005] (II) Region Detection Method Based on Color Features This type of method extracts pixel regions of specific colors by converting the image to a color space such as HSV and based on preset hue, saturation, and brightness thresholds.

[0006] This type of method has the following limitations: First, it relies solely on color information and fails to incorporate the inherent rectangular geometric features of the bounding box (such as rectangularity, convexity, and hollow border structure), thus easily misclassifying non-rectangular objects of the same color family in the image (such as red vehicles, red clothing, and red signs) as target boxes. Second, when the bounding box contains red content, the color segmentation result may cause the bounding box outline to stick to the internal red area, leading to contour distortion. Third, it lacks an effective deduplication mechanism for overlapping detection boxes, and the same bounding box may generate multiple redundant detection results due to the double-line effect at the edges. Finally, using a fixed color threshold makes it difficult to adapt to image changes under different lighting conditions, resulting in insufficient robustness of the method.

[0007] In summary, existing technologies fail to provide a solution that organically combines specific color detection with rectangular geometric verification and is specifically optimized for the hollow border structure of the annotation box. As a result, the detection accuracy of red rectangular annotation boxes needs to be improved under complex backgrounds and varying lighting conditions, and the false detection rate is relatively high. Summary of the Invention

[0008] This invention aims to at least solve the technical problems existing in the prior art, and innovatively proposes a method for detecting red rectangle annotation boxes in images based on the HSV color space.

[0009] To achieve the above-mentioned objectives of this invention, this invention provides a method for detecting red rectangular bounding boxes in images based on the HSV color space, the method comprising: S1. Obtain the image to be detected and convert the image to be detected to the HSV color space to obtain the hue component, saturation component and lightness component of the image; S2. Based on the periodic distribution characteristics of the hue components in the HSV color space, set at least two red hue detection intervals, filter the pixels belonging to the red hue range, and obtain the initial red region mask. After obtaining the initial red region mask, a red region connectivity probability model is further established based on the local spatial distribution characteristics of the red region pixels. According to the distance relationship, directional consistency relationship and edge gradient continuity relationship between adjacent red pixels, regional association enhancement is performed on the discontinuous red regions caused by illumination changes, reflection interference or local occlusion to generate an enhanced red region mask. S3. Perform morphological processing and connected component area filtering on the enhanced red region mask to obtain the optimized red region mask. In the morphological processing, the local principal direction is calculated based on the pixel distribution direction inside the red area, and the morphological structural elements are adaptively adjusted according to the local principal direction so that the morphological processing direction is consistent with the edge direction of the red rectangular annotation box. S4. Perform contour detection on the optimized red area mask to obtain multiple candidate contours, and perform multi-level serial geometric filtering on the candidate contours. In the process of multi-level serial geometric filtering of candidate contours, a contour credibility evaluation model based on prior constraints of rectangular structure is further established. The credibility score of candidate contours is calculated by comprehensively considering contour area, edge continuity, corner point distribution uniformity and internal red pixel filling rate. The candidate contours are then dynamically sorted and filtered according to the credibility score. S5. Perform polygon approximation on the filtered candidate contours, determine whether they meet the rectangular structure features, and convert the candidate contours that meet the conditions into rectangular annotation boxes. In the process of judging the rectangular structure, the judgment is based not only on the number of approximate vertices, but also on the consistency of the angles formed by the four vertices, the ratio of the side lengths, and the rectangle preservation characteristics after perspective transformation. After the polygon approximation process, for the candidate contours that are distorted by the change of viewing angle, the candidate contours are mapped to the standard rectangular space by establishing a perspective compensation matrix before the rectangular structure is verified. S6. Calculate the intersection-union ratio (IUR) between multiple rectangular annotation boxes. When the IUR between multiple rectangular annotation boxes exceeds a preset threshold, merge or filter the rectangular annotation boxes obtained by repeated detection, and output the position coordinates of the red rectangular annotation boxes obtained by detection.

[0010] As an optional embodiment of the present invention, optionally, the red hue detection interval in step S2 is two, specifically: First red hue detection range: ; Second red hue detection zone: ; in, For hue components, Indicates the upper limit of the hue. Represents the saturation component. Indicates the lower limit of saturation. Indicates the lightness component. Indicates the lower limit of brightness. Indicates the lower limit of the hue.

[0011] As an optional embodiment of the present invention, the values ​​of the saturation lower limit and the brightness lower limit may be dynamically determined using an adaptive threshold mechanism.

[0012] As an optional embodiment of the present invention, the expression for the adaptive threshold mechanism is optionally: in, Indicates the basic threshold for saturation. Indicates the average saturation of the image. Indicates the adaptive coefficient of saturation. Indicates the basic threshold of brightness. Indicates average brightness. This represents the brightness adaptive coefficient.

[0013] As an optional embodiment of the present invention, in step S3, the morphological processing may include at least closing operation processing and / or opening operation processing.

[0014] As an optional embodiment of the present invention, optionally, in step S3, the morphological kernel size needs to be proportionally adjusted according to the image resolution during morphological processing, and the expression for the proportional adjustment is: in, Indicates the size of the morphological nucleus. Indicates the width of the image. Indicates the height of the image.

[0015] As an optional embodiment of the present invention, if the image to be detected has obvious overall color shift in step S1, then the grayscale world algorithm or the perfect reflection algorithm is used for white balance correction.

[0016] As an optional embodiment of the present invention, the multi-level serial geometric filtering in step S4 may include contour area filtering, aspect ratio filtering, rectangularity filtering, convexity filtering, and area ratio filtering.

[0017] As an optional embodiment of the present invention, the convexity filtering may include: Obtain the point set of the candidate contour and calculate the contour area; Based on the candidate contour, the convex hull point set is obtained using the convex hull calculation function, and the convex hull area is calculated; The convexity ratio is obtained based on the contour area and the convex hull area. Candidate profiles with a convexity ratio greater than or equal to x are retained.

[0018] As an optional embodiment of the present invention, the polygon approximation process in step S5 may optionally include: Calculate the perimeter of the filtered candidate contours; Approximate accuracy parameters are calculated based on the perimeter. Based on the approximate accuracy parameter, an approximate vertex sequence is obtained, and the number of vertices in the approximate vertex sequence is counted. If the number of vertices is 4, the candidate contour is determined to satisfy the rectangular structure feature; otherwise, it is determined not to satisfy the rectangular structure feature, and the candidate contour with the number of vertices is retained.

[0019] The beneficial effects of this invention are as follows: By organically combining the extraction of red pixels in the HSV color space with multi-level verification of rectangular geometric features, this invention can effectively eliminate the influence of non-rectangular targets of the same color and rectangular interference areas of different colors in the background, and significantly reduce the false detection rate of red rectangular bounding boxes compared with traditional detection methods that rely solely on geometric features or solely on color information.

[0020] This invention employs an adaptive threshold mechanism to dynamically determine the detection limits for saturation and brightness. It can automatically adjust the detection parameters according to the overall illumination and color distribution of different images. Compared with traditional fixed threshold detection methods, it has better robustness to images under complex lighting conditions and with different degrees of color shift, and is suitable for a wider range of scenarios.

[0021] Furthermore, this invention optimizes the red region mask through proportionally adaptive morphological processing and introduces an intersection-union-ratio deduplication mechanism to merge and filter duplicated rectangular boxes. This effectively solves the problem of redundant results caused by multiple detections of the same annotation box, and can also handle abnormal situations such as overlapping or broken annotation box outlines. The final output of the red rectangular annotation box has higher position coordinate accuracy.

[0022] The present invention has a clear detection process and moderate computational complexity. It can automatically adapt to input images of different resolutions and meet the downstream automated processing needs of automatic positioning of red rectangular annotation boxes in various image processing scenarios. It has high practical and promotional value.

[0023] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0024] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart of a method for detecting red rectangular bounding boxes in images based on the HSV color space, according to the present invention. Figure 2 This is a flowchart of the overall process of a red rectangle bounding box detection method for images based on the HSV color space according to the present invention. Figure 3 This is a schematic diagram of the dual-range division of red hue in the HSV color space of this invention; Figure 4 This is an example diagram of the contour that satisfies the area filtering requirement of the present invention; Figure 5 This is a flowchart of the overlapping rectangle merging algorithm based on IoU of the present invention; Figure 6This is an example image of the detection results of the present invention (comparison of the original image, the red mask image, and the final labeled image). Detailed Implementation

[0025] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0026] Example 1 like Figures 1 to 6 As shown, a method for detecting red rectangular bounding boxes in an image based on the HSV color space is described, the method comprising: S1. Acquire the image to be detected and convert it to the HSV color space to obtain the hue component, saturation component, and lightness component of the image; after conversion, calculate the average lightness of the image. and average saturation This is for use in subsequent steps.

[0027] like Below the preset threshold (A recommended value of 80) indicates that the image is in a low-light environment. In this case, the original image is subjected to contrast-limited adaptive histogram equalization (CLAHE) and then converted to HSV space to enhance the contrast of dark details and improve the recall rate of subsequent red detection.

[0028] In step S1, it is necessary to explain in detail that the HSV color space is a color model oriented towards human visual perception, which describes color as three relatively independent attribute components: Hue (H): Represents the type of color, such as red, green, blue, etc. In the HSV model, hue is usually measured in degrees, ranging from 0° to 360° (in computer vision libraries such as OpenCV, it is often normalized to 0 to 180 to accommodate 8-bit storage). Red hues are distributed around 0° (360°).

[0029] Saturation (S): Represents the purity or vividness of a color. Values ​​typically range from 0 to 255. Higher saturation results in a more vivid color; lower saturation makes the color closer to gray.

[0030] Value (V): Represents the lightness or darkness of a color, and is directly related to the intensity of light. The value typically ranges from 0 to 255. A value of 0 represents pure black, while the maximum value represents the brightest state.

[0031] Unlike the RGB (red, green, blue) color space commonly used in computer displays, HSV effectively decouples the chromaticity information (H, S) and luminance information (V) of a color. In the RGB space, the redness of a pixel is determined by the R, G, and B components, and is highly susceptible to changes in light intensity. In the HSV space, the hue (H) component describes the essential properties of a color relatively independently, and is less affected by differences in brightness caused by changes in light intensity.

[0032] 2. The core reason for choosing the HSV color space for red detection In step 1 of this invention, the input image is converted from BGR format to HSV color space, mainly based on the following four technical considerations: (1) The separation characteristics of color and brightness improve the robustness of illumination. In practical applications such as highway monitoring and security surveillance, lighting conditions are extremely complex and variable, including day-night cycles, shadows, headlight glare, and drastic changes in light ratio at tunnel entrances and exits. In RGB color space, a red pixel may appear as (255, 200, 200) under strong light, but may attenuate to (80, 30, 30) in shadow. Although the naked eye can still distinguish it as red, setting a fixed threshold based on the RGB three channels is extremely difficult. A threshold that is too wide can easily introduce a large number of false detections, while a threshold that is too narrow will lead to a large number of missed detections.

[0033] The HSV color space primarily concentrates luminance information in the V channel. Even if the V value fluctuates drastically due to light intensity, the variation range of its H and S components remains relatively small as long as the inherent color of the object remains unchanged. Therefore, this invention can lock in the essence of "red" by setting relatively stable threshold ranges for the H and S channels. Simultaneously, in conjunction with the adaptive threshold mechanism for the V channel in step 2, the lower limit of luminance is dynamically adjusted only when necessary, thereby maintaining a stable red segmentation effect under all-weather lighting conditions.

[0034] (2) The distribution characteristics of red hue on the HSV color wheel are adapted to dual-range detection. In the HSV color wheel, red hue is not a continuous range of values, but rather lies on either side of the 0° starting point of the color wheel—that is, near 0° (e.g., 0°-10°) and near 360° (e.g., 350°-360°). In OpenCV, H is mapped to the range of 0-180, with red corresponding to two separate ranges: 0-10 and 170-180.

[0035] This distribution characteristic is precisely what the RGB space cannot intuitively represent. This embodiment fully utilizes the color wheel properties of the HSV space and creatively employs a dual-interval mask merging scheme with H∈[0,10] and H∈[170,180] to completely cover all red hue ranges. This is an efficient logic that is difficult to implement simply in the RGB space—achieving equal coverage in RGB usually requires complex multi-condition combination judgments (such as (R>G)&(R>B) and a difference threshold), which has low computational efficiency and makes threshold adjustment difficult.

[0036] (3) The intuitiveness and interpretability of threshold setting During the engineering deployment and parameter tuning phases, technicians often adjust color thresholds based on subjective visual experience. HSV space parameters (such as "hue offset of 5 degrees" and "saturation greater than 80") have clear visual meanings, making the parameter tuning process intuitive and controllable. In contrast, the combined thresholds of RGB channels lack intuitive color correspondences, making parameter fine-tuning difficult and hindering the rapid transfer and adaptation of the method to different imaging devices and scenarios.

[0037] (4) Lower computational complexity Converting images from BGR to HSV is a standard, lightweight operation in computer vision libraries (such as OpenCV), involving only pixel-by-pixel linear / non-linear color space transformations. Compared to directly using deep learning models to extract color features or perform semantic segmentation, HSV conversion and subsequent thresholding operations can be processed at high speed on a CPU platform, meeting the stringent requirements for processing frame rate and response latency in the near real-time detection scenarios this method targets (such as highway event detection and security linkage).

[0038] In summary, this embodiment chooses the HSV color space as the color analysis domain for detection by the red-marked box not only because HSV has inherent robustness to changes in illumination, but also to fully utilize the dual-range distribution characteristics of red hues on the HSV color wheel to achieve accurate color selection, while simultaneously considering the efficiency of algorithm implementation and the convenience of parameter adjustment. This choice forms a reliable front-end foundation for all subsequent morphological processing and geometric filtering steps in this invention.

[0039] S2. Based on the periodic distribution characteristics of the hue components in the HSV color space, set at least two red hue detection intervals, filter the pixels belonging to the red hue range, and obtain the initial red region mask. In step S2, the red hue detection range in this embodiment is two, specifically: First red hue detection range: ; Second red hue detection zone: ; in, For hue components, This indicates the upper limit of the hue, preferably 10. Represents the saturation component. Indicates the lower limit of saturation. Indicates the lightness component. Indicates the lower limit of brightness. This indicates the lower limit of the hue, preferably 170.

[0040] The values ​​of the lower limits for saturation and brightness are dynamically determined using an adaptive threshold mechanism.

[0041] The expression for the adaptive threshold mechanism is: in, This represents the basic threshold for saturation (preferably 80). Indicates the average saturation of the image. This represents the saturation adaptive coefficient (preferably 0.8). Indicates the basic threshold value for brightness (preferably 80). Indicates average brightness. This represents the brightness adaptive coefficient (preferably 0.8).

[0042] This adaptive mechanism enables the red detection threshold to be dynamically adjusted according to the overall lighting conditions of the image. It automatically increases the threshold in strong light to reduce false detections and appropriately decreases the threshold in weak light to ensure recall.

[0043] Perform a bitwise OR operation on the masks of the two intervals to obtain the initial red area mask.

[0044] S3. Perform morphological processing and connected component area filtering on the initial red region mask to obtain the optimized red region mask. The morphological processing in step S3 includes at least closing operation processing and / or opening operation processing.

[0045] In step S3, the morphological kernel size needs to be adjusted proportionally according to the image resolution during morphological processing. The expression for the proportional adjustment is: in, Indicates the size of the morphological nucleus. Indicates the width of the image. Indicates the height of the image.

[0046] Morphological closing operation (dilation followed by erosion): kernel size is Kclose (default 3×3), used to connect broken areas at the edge of the annotation box caused by color extraction and fill small holes; Morphological opening operation (optional, erosion followed by dilation): kernel size is Kopen (default 2×2), used to remove isolated noise points; Connected area filtering: Directly remove connected components with an area smaller than min_area_connected (default 50 pixels²) to reduce the computational load of subsequent contour detection.

[0047] It should also be noted that the entire algorithm flow in this embodiment, from color segmentation to geometric verification, adopts lightweight traditional image processing operations throughout, without computationally intensive steps such as model inference and large-scale matrix operations. In addition to the lightweight characteristics of the front-end HSV conversion, the subsequent steps have also been designed to further control the overall computational complexity: on the one hand, a large number of irrelevant noise pixels are removed in advance through morphological processing, and only red connected regions that meet the area requirements are retained for subsequent contour detection and geometric filtering, which greatly reduces unnecessary computational overhead; on the other hand, the subsequent multi-level serial geometric filtering follows the sorting logic of "coarse first and fine later". First, the vast majority of unqualified candidate contours are eliminated by contour area and aspect ratio filtering with extremely low computational cost, and only a small number of high-confidence candidates are retained for subsequent higher-precision and slightly more computationally expensive convexity ratio calculation and polygon approximation verification. While ensuring detection accuracy, the overall computational load is compressed to the maximum extent, further highlighting the advantages of this method in terms of computational efficiency.

[0048] S4. Perform contour detection on the optimized red area mask to obtain multiple candidate contours, and perform multi-level serial geometric filtering on the candidate contours. In step S4, the multi-level cascaded geometric filtering includes contour area filtering, aspect ratio filtering, rectangularity filtering, convexity filtering, and area ratio filtering.

[0049] The convex filtering includes: Obtain the point set of the candidate contour and calculate the contour area; Based on the candidate contours, a convex hull point set is obtained using a convex hull calculation function, and the convex hull area is calculated; the convexity ratio is obtained based on the contour area and the convex hull area; candidate contours with a convexity ratio greater than or equal to x (0.7) are retained. It should be noted that this embodiment uses existing contour detection algorithms to extract contours from the mask, and performs the following multi-level cascaded geometric filtering on each contour: The specific implementation and differentiation principle of rectangularity filtering are as follows: In highway surveillance images, the red highlighted boxes are hollow rectangular frames, meaning only the border area is red, while most of the interior area is the background color. Falsely detected red objects (such as red vehicles or traffic facilities) are typically solid or large areas of red. This structural difference manifests at the contour level as a significant difference in contour fill rate (rectangularity).

[0050] Hollow bounding box: The detected contour is a closed loop formed by its inner and outer edges (or a thicker edge merged after morphological processing). Contour area. Much smaller than the area of ​​its positive circumscribed rectangle For example, a A bounding box with a pixel width and a border width of 3 pixels has an outline area of ​​approximately [missing information]. The area of ​​the bounding rectangle is 20,000 pixels², and the rectangle's rectangularity is only [missing value]. .

[0051] Solid red object: The detected contour is the outer boundary of its entire red area. The area of ​​the contour is very close to the area of ​​the positive bounding rectangle. For example, a The red solid rectangle of pixels has an outline area of ​​approximately 20,000 pixels² and a rectangularity of 1.0.

[0052] Therefore, by setting a reasonable lower limit threshold for rectangle size (recommended value) This process can precisely retain hollow annotation boxes, thereby eliminating solid red distractors. This step, in conjunction with filtering conditions such as area and aspect ratio, forms a highly efficient multi-level screening mechanism.

[0053] Convex filtering: For the contours that pass the initial area filtering, calculate their convexity ratio, which is the ratio of the contour area to the area of ​​its convex hull. The convex hull is the smallest convex polygon that can completely enclose the contour. This metric is used to measure the fullness and regularity of the contour shape.

[0054] A convexity ratio close to 1.0 indicates that the contour itself is a convex polygon (such as a rectangle or circle) with no obvious concavity.

[0055] Low convexity: The contour has large concave areas or is extremely irregular in shape.

[0056] In the scenario described in this invention, the red marked boxes, after morphological processing, typically appear as well-defined convex quadrilaterals with a convexity ratio usually above 0.8. However, red noise and fragmented areas caused by uneven lighting, occlusion, or reflection often have complex shapes and obvious depressions, resulting in a significantly lower convexity ratio than normal marked boxes. Therefore, setting a lower threshold for the convexity ratio (recommended value 0.7) can effectively filter out irregularly shaped red false targets, further improving detection accuracy.

[0057] The specific calculation method is as follows: Obtain the point set of the contour and calculate the contour area. .

[0058] Call the convex hull calculation function to obtain the convex hull point set and calculate the convex hull area. .

[0059] Calculate the convexity ratio .

[0060] Only keep The outlines will then be used in the subsequent screening process.

[0061] It should also be noted that this multi-level sequential filtering architecture of "coarse screening followed by fine filtering" fully utilizes the inherent geometric features of the red hollow rectangular annotation box to eliminate various scene interferences through a progressive filtering logic, while minimizing the overall computational overhead of the algorithm. Each filtering step is only performed on a small number of candidate targets that have passed the previous screening, avoiding the need to perform high-computation geometric feature calculations on all initial contours. This ensures the efficiency of the algorithm while maintaining detection accuracy, making it suitable for near real-time detection needs on ordinary CPU devices.

[0062] After the above multi-level cascaded geometric filtering, the remaining candidate contours are the red rectangular bounding box contours that meet the requirements. At this point, it is only necessary to extract the boundary coordinates of the smallest positive bounding rectangle corresponding to each retained contour, and output the position and size results of all red rectangular bounding boxes in the image to be detected, thus completing the entire red rectangular bounding box detection process based on the HSV color space.

[0063] S5. Perform polygon approximation on the filtered candidate contours, determine whether they meet the rectangular structure features, and convert the candidate contours that meet the conditions into rectangular annotation boxes. The polygon approximation process in step S5 includes: Calculate the perimeter of the filtered candidate contours; Approximate accuracy parameters are calculated based on the perimeter. Based on the approximate accuracy parameter, an approximate vertex sequence is obtained, and the number of vertices in the approximate vertex sequence is counted. If the number of vertices is 4, the candidate contour is determined to satisfy the rectangular structure feature; otherwise, it is determined not to satisfy the rectangular structure feature, and the candidate contour with the number of vertices is retained.

[0064] In this embodiment, the Douglas-Peucker algorithm is used to approximate the contours that have passed the initial screening into polygons, in order to filter out edge noise and extract the main geometric framework. The specific implementation is as follows: 1. Calculate the perimeter of the profile, peri.

[0065] 2. Determine the approximate accuracy parameter epsilon = contour_approx_epsilon_factor × peri. This factor is preferably 0.02, which means that while preserving the main rectangular structure, it tolerates local deformation or jagged noise within 2% of the contour perimeter.

[0066] 3. Obtain the approximate polygon vertex set. After this precision approximation, a regular red rectangular bounding box will be simplified into a convex quadrilateral containing only 4 corner points; while circles, ellipses, or irregular fragments will be simplified into polygons with no more than 4 vertices.

[0067] 4. Perform quadrilateral filtering: retain only the outlines with an exact number of 4 vertices after approximation as candidate rectangles, and convert their corner coordinates to positive circumscribed rectangle format (x1, y1, x2, y2) for output.

[0068] This step makes full use of the geometric prior knowledge of the annotation box, and removes the edge burrs left after morphological processing by shape simplification. It is the last shape constraint to ensure that the detection result accurately fits the edge of the real red box.

[0069] It should be noted that the perimeter of the contour calculated in this step is the sum of the Euclidean distances between all adjacent vertices on the contour. This calculation result is positively correlated with the overall size of the candidate contour, providing a reliable dimensional basis for determining the subsequent polygon approximation accuracy parameters. This method of dynamically determining the approximation accuracy based on the contour size can adapt to the processing needs of different sized bounding boxes: for large red bounding boxes, a larger perimeter corresponds to a larger approximation accuracy threshold epsilon, which can more effectively filter out a large amount of detailed jagged noise at the edges of large boxes; for small bounding boxes, a smaller perimeter corresponds to a smaller approximation accuracy threshold, which can avoid oversimplification and loss of vertex structure information of the contour, and prevent misjudging a regular rectangular box as a non-rectangular contour, effectively improving the adaptability of the polygon approximation step to targets of different sizes.

[0070] S6. Calculate the intersection-union ratio (IUR) between multiple rectangular annotation boxes. When the IUR between multiple rectangular annotation boxes exceeds a preset threshold, merge or filter the rectangular annotation boxes obtained by repeated detection, and output the position coordinates of the red rectangular annotation boxes obtained by detection.

[0071] like Figure 5 As shown, in step S6, this embodiment performs overlap detection and merging on the candidate rectangle list. The specific process is as follows: (1) Sort all candidate boxes by area from smallest to largest; (2) Initialize the empty list merged_boxes; (3) Iterate through each sorted rectangle (bbox) sequentially: Calculate the intersection-union ratio (IoU) of bbox with each existing box in merged_boxes. IoU is defined as the ratio of the intersection area to the union area. If the maximum IoU is greater than or equal to overlap_threshold (default 0.7), it is considered a duplicate detection of the same bounding box. If the "union merging" strategy is adopted, the union bounding rectangle of this box and the existing box will be used as the new merged box to replace the original box; If the "optimal selection and retention" strategy is adopted, the box with a larger area will be retained (the default strategy, applicable to scenarios where the edges of the labeling box are incomplete); If the maximum IoU is less than overlap_threshold, the bbox will be added to merged_boxes as a new box.

[0072] (4) Perform an upper area check on the merged rectangular boxes. If the ratio of the merged box area to the total image area exceeds max_merged_ratio (default 0.7), the merged box will be rejected (to prevent abnormal merging).

[0073] Using IoU as the measurement indicator instead of a simple overlap rate can more accurately reflect the actual overlap degree of the two boxes and improve the merging accuracy.

[0074] Output detection results Output a list of coordinates of rectangular boxes that pass all screening conditions, in the format of (x1,y1,x2,y2), where (x1,y1) is the top-left coordinate and (x2,y2) is the bottom-right coordinate. This coordinate list can be directly transmitted to the downstream image cropping module or content analysis module.

[0075] Asynchronous labeled image saving and storage management (optional) Determine whether to save the visualized image with green labeling boxes according to the configuration parameter save_annotated_image; The saving of labeled images is executed by an asynchronous thread pool, which does not block the main detection process; Regularly clean up labeled image files that exceed the retention period (e.g., 7 days) to ensure that the storage space is controllable.

[0076] Based on the above method, this embodiment further provides a parameter configuration suitable for conventional expressway monitoring scenarios: Optimization configuration for low-light scenarios For low-light scenarios such as nighttime, indoor dim light or backlight, it is recommended to adjust the following parameters to improve the detection recall rate: Lower to 60; Lower to 0.6; Enable CLAHE enhancement preprocessing; Increase to 5 to enhance regional connectivity.

[0077] Under this configuration, the recall rate of red annotation boxes in low-illumination scenarios can be significantly improved compared with the standard configuration.

[0078] High-Resolution Image Configuration For high-resolution surveillance images of 4K and above, it is recommended to adjust the following parameters proportionally: The morphological kernel size is linked to the image size: ; Adjust to 500 or more; Adjust to 100 or more.

[0079] Highway Surveillance Application Example Taking a highway event detection system as an example in this embodiment, the specific application process of the present invention is described as follows: 1. The highway surveillance camera collects real-time images, and the event detection system marks target vehicles to be reviewed with red rectangular boxes on the images; 2. The method of the present invention is adopted to process the images, and the position coordinates of the red annotation boxes are detected; 3. The detection result is transmitted to the cropping judgment module, and the working logic is as follows: if len(detected_boxes) = 1: box = detected_boxes[0] box_area = (box.x2 - box.x1) * (box.y2 - box.y1) image_area = image_width * image_height if box_area / image_area < crop_threshold: # crop_threshold defaults to 0.3 cropped_image = smart_crop_and_zoom(image, box) # Proceed to the subsequent AI review process 4. The AI review module performs secondary recognition on the cropped target area to confirm the authenticity of the event.

[0080] This application example demonstrates the seamless connection capability of the present invention with downstream processing workflows, forming a complete automated closed loop of "detection - cropping - review".

[0081] The AI ​​review module in this embodiment is specifically an existing traffic incident detection neural network model, such as the YOLOv8 traffic incident detection model or a traffic incident recognition network based on the Transformer architecture. These models have been pre-trained on large-scale highway traffic incident datasets and have the ability to recognize many common incidents such as parking, driving against traffic, littering, and traffic accidents. They can be directly integrated into this process to complete secondary review without additional fine-tuning training for the detection method in the red box. They can be easily integrated into the existing highway intelligent monitoring system to achieve fully automated operation of automatic event label extraction and automatic review.

[0082] Example 2 The difference between this embodiment and Embodiment 1 lies in that this embodiment targets complex highway monitoring scenarios with localized lighting interference and perspective distortion. Building upon the basic process of Embodiment 1, it adds several optimized steps, including enhanced association of discontinuous red areas, adaptive morphological processing, contour credibility ranking and filtering, and rectangle verification for perspective distortion compensation. This further improves the detection recall and positioning accuracy of red rectangle bounding boxes in complex scenarios. For oblique bounding boxes with perspective distortion caused by large-angle installed surveillance cameras, and bounding boxes with broken red pixels due to strong light reflection, the optimization strategy of this embodiment effectively reduces the probability of missed and false detections. Its detection performance is significantly better than the basic embodiment in mountainous backlit road sections and low-light, large-angle monitoring scenarios at night, making it adaptable to more complex highway monitoring application environments. Details are as follows: A method for detecting red rectangular bounding boxes in images based on the HSV color space, the method comprising: S1. Obtain the image to be detected and convert the image to be detected to the HSV color space to obtain the hue component, saturation component and lightness component of the image; S2. Based on the periodic distribution characteristics of the hue components in the HSV color space, set at least two red hue detection intervals, filter the pixels belonging to the red hue range, and obtain the initial red region mask. After obtaining the initial red region mask, a red region connectivity probability model is further established based on the local spatial distribution characteristics of the red region pixels. According to the distance relationship, directional consistency relationship and edge gradient continuity relationship between adjacent red pixels, regional association enhancement is performed on the discontinuous red regions caused by illumination changes, reflection interference or local occlusion to generate an enhanced red region mask. In this step, it's important to note that this method first pre-extracts the eight-neighbor connected regions from the initial red mask to obtain all discrete red candidate fragments. Then, it calculates the spatial distance between any two fragments, the angle along the major axis of the fragments, and the difference in edge gradient direction. Only when all three conditions simultaneously meet preset thresholds—namely, the distance between fragment centers is less than 1 / 20 of the original image's shorter side length, the angle along the major axis is less than 15°, and the difference in edge gradient direction is less than 20°—are the two fragments determined to belong to the same discontinuous region caused by interference-induced breaks in the red bounding box. Subsequently, seed filling is performed in the connecting region between the two fragments to supplement the red pixels that were mistakenly filtered out due to illumination interference, thus completing the region association enhancement. This strategy avoids incorrectly connecting adjacent red regions of different bounding boxes, only supplementing red pixels lost due to interference within the same bounding box. This solves the problem of red region breaks caused by local interference without introducing additional false red regions, effectively improving the integrity of red bounding boxes in highly reflective and partially occluded scenes. This provides a more accurate base mask for subsequent contour extraction and shape selection, reducing the probability of missed detections caused by incomplete contours from the source.

[0083] The method for establishing the connectivity probability model of the red region is as follows: First, traverse all red pixels in the initial red region mask, extract the distribution information of red pixels within a preset neighborhood centered on each pixel, and calculate the spatial distance weight between any two red pixels in the neighborhood (the specific calculation method can use the existing inverse distance weighting method), the edge orientation consistency weight (the specific calculation method can use the existing Gaussian kernel weighting method to aggregate the orientation differences of pixels at different positions in the neighborhood; the smaller the orientation difference between two red pixels, the higher the weight value, and the stronger the corresponding orientation consistency), and the gradient continuity weight (the specific calculation method can use the existing Gaussian kernel weighting method to aggregate the orientation differences of pixels at different positions in the neighborhood; the smaller the orientation difference between two red pixels, the higher the weight value, and the stronger the ...). The method can be based on the gradient direction extracted from the original image to be detected using the existing Sobel operator. The smaller the angle between the gradient directions of two adjacent red pixels, the higher the continuity weight is obtained. The three weights are weighted and summed according to a preset ratio to obtain the connectivity probability that two pixels belong to the same red bounding box. A connectivity probability threshold is set (the threshold is 0.65 in this embodiment, which can be adjusted according to the noise level of the scene). All adjacent non-connected red sub-regions with connectivity probabilities higher than the threshold are merged. At the same time, intermediate pixels with connectivity probabilities between two sub-regions in the original mask that meet the requirements are added to obtain a complete enhanced red region mask.

[0084] S3. Perform morphological processing and connected component area filtering on the enhanced red region mask to obtain the optimized red region mask. In the morphological processing, the local principal direction is calculated based on the pixel distribution direction inside the red area, and the morphological structural elements are adaptively adjusted according to the local principal direction so that the morphological processing direction is consistent with the edge direction of the red rectangular annotation box, thereby reducing the edge loss caused by traditional fixed-direction morphological operations. In this step, it's important to note that for each independent connected red region, the coordinates of all its red pixels are first extracted for principal component analysis (PCA). PCA is then used to calculate the first principal component direction of this region, which is taken as the local principal direction. Subsequently, linear structuring elements (STEM) are generated for the corresponding direction. The length of the STEM is set to 1 / 100th of the original image's shorter side, and the width is fixed at 1 pixel. Closing operations are performed along the principal direction, and opening operations are performed perpendicular to the principal direction. This effectively fills the small holes at the edges of the bounding boxes while preserving the original contour features of rectangular bounding boxes at different tilt angles. This avoids the excessive erosion or expansion of the oblique rectangular edges by traditional fixed square STEM elements, solving the problem of insufficient morphological processing accuracy after bounding box contour deformation in perspective distortion scenarios. After completing the direction-adaptive morphological processing, excessively small noisy connected regions are filtered out according to a preset area threshold, ultimately yielding an optimized red region mask suitable for contour extraction.

[0085] S4. Perform contour detection on the optimized red area mask to obtain multiple candidate contours, and perform multi-level serial geometric filtering on the candidate contours. In the process of multi-level serial geometric filtering of candidate contours, a contour credibility evaluation model based on prior constraints of rectangular structure is further established. The credibility score of candidate contours is calculated by comprehensively considering contour area, edge continuity, corner point distribution uniformity and internal red pixel filling rate. The candidate contours are then dynamically sorted and filtered according to the credibility score. In this step, it should be noted that the credibility score is obtained by weighting four dimensions: contour area ratio, edge integrity, corner compliance, and internal fill rate. The specific calculation process is as follows: First, extract the minimum bounding rectangle of the current candidate contour, and then calculate the normalized scores for each of the four dimensions: 1) Outline area ratio score: Calculate the ratio of the candidate outline area to the area of ​​the smallest circumscribed rotating rectangle. The closer the ratio is to 1, the higher the score. 2) Edge integrity score: The number of breakpoints on the candidate contour edge is counted. The fewer the breakpoints, the closer the ratio of the total edge length to the perimeter of the smallest bounding rectangle is to 1, and the higher the score. 3) Corner compliance score: Extract four corner points from the candidate contour, calculate the deviation of the included angle between each pair of the four corner points from 90°, the smaller the deviation and the more symmetrical the distribution of the four corner points, the higher the score; 4) Internal Fill Rate Score: The score is calculated based on the percentage of red pixels inside the smallest outer rotating rectangle. The higher the percentage, the higher the score.

[0086] The final credibility score of the candidate contour is obtained by weighting and summing the scores of the four dimensions with weights of 0.2, 0.25, 0.25, and 0.3. In this embodiment, the credibility score threshold is set to 0.6. Low-quality candidate contours with scores below the threshold are eliminated, and candidates with scores that meet the requirements are retained to enter the subsequent contour approximation steps. When there are multiple overlapping candidate contours in the same target area, candidates with higher scores are retained first, which effectively reduces the amount of computation of redundant candidates and reduces the probability of false detection as a whole.

[0087] Regarding the aforementioned weight settings, those skilled in the art can adaptively adjust the weight allocation based on the lighting conditions, image resolution, and annotation box size distribution characteristics of the actual application scenario without changing the core principles of the present invention. For example, when there is a lot of lighting interference in the scene and the annotation box is prone to local breakage, the weight of the contour area ratio and edge integrity can be appropriately increased; when the image resolution is high and the annotation box size is small, the weight of corner compliance can be appropriately increased, thereby making the screening mechanism more suitable for the specific application scenario and obtaining better detection results.

[0088] S5. Perform polygon approximation on the filtered candidate contours, determine whether they meet the rectangular structure features, and convert the candidate contours that meet the conditions into rectangular annotation boxes. In the process of judging the rectangular structure, the judgment is based not only on the number of approximate vertices, but also on the consistency of the angles formed by the four vertices, the ratio of the side lengths, and the rectangle preservation characteristics after perspective transformation. After the polygon approximation process, for the candidate contours that are affected by perspective distortion due to changes in the viewing angle, the candidate contours are mapped to the standard rectangular space by establishing a perspective compensation matrix before the rectangular structure is verified, so as to improve the detection accuracy of the red rectangle annotation box under different shooting angles. In this step, it should be noted that after the polygon approximates a candidate contour with 4 vertices, the four vertices are arranged in a clockwise order, and the interior angles between adjacent sides are calculated sequentially to obtain the absolute deviation of the four interior angles from 90°. The average deviation of the four interior angles is then calculated. If the average deviation exceeds the preset deviation threshold (set to 15° in this embodiment), the candidate is directly determined not to meet the rectangular structure feature and is eliminated. If the average deviation meets the threshold requirement, the length ratio of the four opposite sides is further calculated to verify whether the length ratio of the opposite sides falls within the preset range (set to 0.8~1.25 in this embodiment), and candidates that meet the feature of approximately equal length of opposite sides of a rectangle are selected.

[0089] For the oblique candidate rectangles that have passed the preliminary verification above, this embodiment introduces perspective distortion compensation verification: establish a perspective compensation matrix based on the coordinates of the four vertices, map the quadrilateral with perspective distortion to a standard regular rectangle space without distortion, calculate the coordinate error of the four vertices after mapping, if the coordinate error is lower than the preset error threshold (set to 1% of the length of the short side of the original image in this embodiment), then the candidate is determined to be a real perspective distortion red rectangle annotation box, the candidate is retained and its original coordinates are output to the subsequent overlap and merging steps, otherwise it is discarded.

[0090] The specific method for establishing the perspective compensation matrix is ​​as follows: First, extract the coordinates of the four original candidate vertices after clockwise sorting. Calculate the approximate lengths of opposite sides of the original quadrilateral based on the Euclidean distance between each pair of the four vertices. Combine this with the aspect ratio of the original frame to generate the coordinates of the four target vertices of a distortion-free standard rectangle. Then, construct a 3×3 perspective transformation coefficient matrix. Substitute the coordinate correspondence between the original vertices and the target vertices into the transformation equations. Solve using the least squares method to obtain all the unknown parameters of the perspective compensation matrix, thus completing the establishment of the perspective compensation matrix.

[0091] This multi-feature joint verification combined with perspective compensation judgment strategy effectively solves the problem that perspective distortion causes oblique rectangular annotation boxes to be misjudged as irregular quadrilaterals in scenarios where surveillance cameras are installed at large angles. Compared with the basic detection process that only relies on the number of vertices, the detection accuracy of red rectangular annotation boxes in complex large-angle scenarios is improved, further expanding the adaptability of this method to various complex shooting scenarios.

[0092] S6. Calculate the intersection-union ratio (IUR) between multiple rectangular annotation boxes. When the IUR between multiple rectangular annotation boxes exceeds a preset threshold, merge or filter the rectangular annotation boxes obtained by repeated detection, and output the position coordinates of the red rectangular annotation boxes obtained by detection.

[0093] In summary, this embodiment enhances the connection of discontinuous red regions to complete the broken red box outline under illumination interference, preserves the original edge features of obliquely distorted rectangles through orientation-adaptive morphological processing, eliminates low-quality false candidates in advance through contour credibility sorting, and completes accurate rectangle determination in complex distortion scenarios through perspective distortion compensation rectangle verification. The multi-step optimization strategy progressively solves the pain points of traditional red rectangle detection methods, such as high false detection rate, high false detection probability, and insufficient positioning accuracy in complex highway monitoring scenarios, such as local backlight, strong light reflection, and large-angle perspective distortion. It effectively improves the detection recall rate and positioning accuracy of red rectangle annotation boxes in complex scenarios, and can stably adapt to the automatic review needs of highway events under various complex installation scenarios and lighting conditions, further improving the environmental adaptability and operational reliability of the entire automated event detection closed-loop process.

[0094] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims

1. A method for detecting red rectangular bounding boxes in images based on the HSV color space, characterized in that, The method includes: S1. Obtain the image to be detected and convert the image to be detected to the HSV color space to obtain the hue component, saturation component and lightness component of the image; S2. Based on the periodic distribution characteristics of the hue components in the HSV color space, set at least two red hue detection intervals, filter the pixels belonging to the red hue range, and obtain the initial red region mask. After obtaining the initial red region mask, a red region connectivity probability model is further established based on the local spatial distribution characteristics of the red region pixels. Based on the distance relationship, directional consistency relationship and edge gradient continuity relationship between adjacent red pixels, regional association enhancement is performed on the discontinuous red regions caused by illumination changes, reflection interference or local occlusion to generate an enhanced red region mask. S3. Perform morphological processing and connected component area filtering on the enhanced red region mask to obtain the optimized red region mask. In the morphological processing, the local principal direction is calculated based on the pixel distribution direction inside the red area, and the morphological structural elements are adaptively adjusted according to the local principal direction so that the morphological processing direction is consistent with the edge direction of the red rectangular annotation box. S4. Perform contour detection on the optimized red area mask to obtain multiple candidate contours, and perform multi-level serial geometric filtering on the candidate contours. In the process of multi-level serial geometric filtering of candidate contours, a contour credibility evaluation model based on prior constraints of rectangular structure is further established. The credibility score of candidate contours is calculated by comprehensively considering contour area, edge continuity, corner point distribution uniformity and internal red pixel filling rate. The candidate contours are then dynamically sorted and filtered according to the credibility score. S5. Perform polygon approximation on the filtered candidate contours, determine whether they meet the rectangular structure features, and convert the candidate contours that meet the conditions into rectangular annotation boxes. In the process of judging the rectangular structure, the judgment is based not only on the number of approximate vertices, but also on the consistency of the angles formed by the four vertices, the ratio of the side lengths, and the rectangle preservation characteristics after perspective transformation. After the polygon approximation process, for the candidate contours that are distorted by the change of viewing angle, the candidate contours are mapped to the standard rectangular space by establishing a perspective compensation matrix before the rectangular structure is verified. S6. Calculate the intersection-union ratio (IUR) between multiple rectangular annotation boxes. When the IUR between multiple rectangular annotation boxes exceeds a preset threshold, merge or filter the rectangular annotation boxes obtained by repeated detection, and output the position coordinates of the red rectangular annotation boxes obtained by detection.

2. The image red rectangle bounding box detection method based on HSV color space as described in claim 1, characterized in that, In step S2, there are two red hue detection ranges, specifically: First red hue detection range: ; Second red hue detection zone: ; in, For hue components, Indicates the upper limit of the hue. Represents the saturation component. Indicates the lower limit of saturation. Indicates the lightness component. Indicates the lower limit of brightness. Indicates the lower limit of the hue.

3. The image red rectangle bounding box detection method based on HSV color space as described in claim 2, characterized in that, The values ​​of the lower limits for saturation and brightness are dynamically determined using an adaptive threshold mechanism.

4. The image red rectangle bounding box detection method based on HSV color space as described in claim 3, characterized in that, The expression for the adaptive threshold mechanism is: in, Indicates the basic threshold for saturation. Indicates the average saturation of the image. Indicates the adaptive coefficient of saturation. Indicates the basic threshold of brightness. Indicates average brightness. This represents the brightness adaptive coefficient.

5. The image red rectangle bounding box detection method based on HSV color space as described in claim 1, characterized in that, In step S3, the morphological processing includes at least closing operation processing and / or opening operation processing.

6. The image red rectangle bounding box detection method based on HSV color space as described in claim 1, characterized in that, In step S3, the morphological kernel size needs to be adjusted proportionally according to the image resolution during morphological processing. The expression for the proportional adjustment is: in, Indicates the size of the morphological nucleus. Indicates the width of the image. Indicates the height of the image.

7. The image red rectangle bounding box detection method based on HSV color space as described in claim 1, characterized in that, If the image to be detected has a significant overall color cast in step S1, then the grayscale world algorithm or the perfect reflection algorithm is used for white balance correction.

8. The image red rectangle bounding box detection method based on HSV color space as described in claim 1, characterized in that, In step S4, the multi-level cascaded geometric filtering includes contour area filtering, aspect ratio filtering, rectangularity filtering, convexity filtering, and area ratio filtering.

9. The image red rectangle bounding box detection method based on HSV color space as described in claim 8, characterized in that, The convex filtering includes: Obtain the point set of the candidate contour and calculate the contour area; Based on the candidate contour, the convex hull point set is obtained using the convex hull calculation function, and the convex hull area is calculated; The convexity ratio is obtained based on the contour area and the convex hull area. Candidate contours with a convexity ratio greater than or equal to x are retained, where x is the convexity ratio threshold.

10. The image red rectangle bounding box detection method based on HSV color space as described in claim 1, characterized in that, The polygon approximation process in step S5 includes: Calculate the perimeter of the filtered candidate contours; Approximate accuracy parameters are calculated based on the perimeter. Based on the approximate accuracy parameter, an approximate vertex sequence is obtained, and the number of vertices in the approximate vertex sequence is counted. If the number of vertices is 4, the candidate contour is determined to satisfy the rectangular structure feature; otherwise, it is determined not to satisfy the rectangular structure feature, and the candidate contour with the number of vertices is retained.

Citation Information

Patent Citations

  • Traditional Chinese medicine pesticide residue detection method and system based on artificial intelligence and medium

    CN120182729A

  • Pier crack detection method based on improved YOLOv8n

    CN121033027A