Control method, device and storage medium for detecting a reduced tennis court area

By performing dimensionality reduction, clustering, and multi-directional projection processing on tennis court images, the problem of poor tennis court detection results was solved, achieving more efficient and accurate region of interest localization.

CN121033400BActive Publication Date: 2026-02-27SHENZHEN EMEET TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511565224.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2026-02-27
Estimated Expiration
2045-10-30

AI Technical Summary

Technical Problem

In existing technologies, the detection effect of tennis courts is not ideal, mainly because full-image scanning and calculation increase the risk of false detection, resulting in unsatisfactory detection results.

Method used

By performing dimensionality reduction and reshaping on the original image of the tennis court, image data in the form of a two-dimensional array is generated. The main colors are identified by clustering pixel colors, a binary mask is generated and connected component analysis is performed to filter out the largest connected region. Finally, the region of interest is determined by multi-directional projection.

Benefits of technology

It improves the accuracy of locating regions of interest on tennis courts, reduces unnecessary computations, and enhances the efficiency of image preprocessing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121033400B_ABST
    Figure CN121033400B_ABST
Patent Text Reader

Abstract

The application discloses a control method and device for reducing the detection range of a tennis court and a storage medium, relates to the technical field of image recognition, and comprises the following steps: performing dimension reduction processing and remodeling processing on an original image of a tennis court to obtain image data in the form of a two-dimensional array; clustering pixel colors in the image data, identifying and screening the main color corresponding to the tennis court; generating a binary mask according to the main color, normalizing the binary mask according to a preset combination operation, and obtaining a target binary mask; performing connected domain analysis on the target binary mask, screening the largest connected region in the target binary mask, and generating a largest connected region mask; and performing multi-direction projection processing on the largest connected region mask to determine a region of interest corresponding to the tennis court. Through the determination process of the region of interest, the application solves the problem of poor detection effect of the tennis court, reduces invalid calculation and interference, and improves preprocessing efficiency and positioning accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image recognition, and particularly relates to a control method, device and storage medium for reducing the detection range of a tennis court. BACKGROUND

[0002] In the field of computer vision, tennis court detection and landing point counting technology is a key technology supporting tennis match analysis, training assistance and other scenarios, and its performance directly affects the practicality of related applications. In related technologies, a processing paradigm of full-image scanning and operation on an entire high-resolution image is usually adopted, and such full-image processing needs to deal with all background disturbances in the image without distinction, which increases the risk of false detection, and finally leads to poor detection effect of the tennis court.

[0003] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY

[0004] The main purpose of the present application is to provide a control method, device and storage medium for reducing the detection range of a tennis court, aiming to solve the technical problem of poor detection effect of the tennis court.

[0005] To achieve the above purpose, the present application provides a control method for reducing the detection range of a tennis court, which comprises:

[0006] The original image of the tennis court is subjected to dimension reduction processing and reshaping processing to obtain image data in the form of a two-dimensional array;

[0007] The pixel colors in the image data are clustered to identify and filter out the main color corresponding to the tennis court;

[0008] After generating a binary mask according to the main color, the binary mask is regularized according to a preset combination operation to obtain a target binary mask;

[0009] The target binary mask is subjected to connected component analysis to filter out the largest connected region in the target binary mask to generate a largest connected region mask;

[0010] The largest connected region mask is subjected to multi-directional projection processing to determine the region of interest corresponding to the tennis court.

[0011] In an embodiment, the original image is reduced to a preset proportion of the original size by dimension reduction operation to obtain a reduced tennis court image;

[0012] The reduced tennis court image is subjected to denoising processing, and the median value of a local pixel region is used to replace the center pixel to generate a processed original image;

[0013] The processed original image is reshaped into a two-dimensional array in row and column order, and the image data meeting the format requirements is output.

[0014] In an embodiment, the pixel colors in the image data are clustered according to a clustering algorithm, and a clustering result containing a preset number of pixel color clusters is output.

[0015] The number of pixels contained in each of the pixel color clusters is counted, and each of the pixel color clusters is sorted according to the size of the number of pixels, to obtain a color cluster list.

[0016] The target pixel color cluster with the largest number of pixels in the color cluster list is screened out, and the color parameter corresponding to the target pixel color cluster is determined as the main color corresponding to the tennis court.

[0017] In an embodiment, all pixels in the image data are traversed, and whether the color corresponding to each of the pixels belongs to the main color is distinguished, to generate an initial binary mask.

[0018] White noise in the initial binary mask is removed by morphological opening operation, and the boundary shape of the main body region of the initial binary mask is restored, to output a standard binary mask.

[0019] Small holes inside the standard binary mask are filled by morphological closing operation, and adjacent fragmented regions are connected, to output a standard binary mask after regularization processing.

[0020] The standard binary mask after regularization processing is enlarged to the same size as the original image, to obtain the target binary mask of the original size.

[0021] In an embodiment, all white pixel regions that are mutually connected in the target binary mask are identified and labeled, to obtain a region mask containing label information of each connected region.

[0022] Each connected region with an identifier in the region mask is traversed, and the number of white pixels contained in each of the connected regions is counted, to generate an area statistics list recording the identifier of each connected region and the corresponding area.

[0023] The target connected region with the largest area value is screened out from the area statistics list, the white pixels in the target connected region in the target binary mask are retained, and the pixels in other regions are all marked as black, to generate the largest connected region mask.

[0024] In an embodiment, the number of white pixels in the largest connected region mask is counted horizontally and row by row, the effective rows are screened according to a preset threshold, the continuous segments of the effective rows are separated and the indexes are recorded, to obtain row continuous segment information.

[0025] filtering out the longest row continuous segment from the row continuous segment information, determining the vertical up and down boundary according to the index corresponding to the longest row continuous segment, and outputting the vertical boundary parameter;

[0026] vertically counting the number of white pixels of the largest connected region mask, filtering out the effective column according to a preset threshold, separating the continuous segment of the effective column and recording the index, and obtaining column continuous segment information;

[0027] filtering out the longest column continuous segment from the column continuous segment information, determining the horizontal left and right boundary according to the index corresponding to the longest column continuous segment, and outputting the horizontal boundary parameter;

[0028] integrating and generating the region of interest according to the vertical boundary parameter and the horizontal boundary parameter.

[0029] In an embodiment, the effectiveness of the boundary index corresponding to the vertical boundary parameter and the horizontal boundary parameter is verified, and the boundary index value that passes the verification is extracted and confirmed to obtain an effective boundary value;

[0030] the vertical coordinate and the horizontal coordinate in the effective boundary value are parsed to determine the rectangular vertex coordinates, and a coordinate pair is generated;

[0031] a closed rectangular region is framed in the original image according to the coordinate pair to obtain the region of interest.

[0032] In an embodiment, it is checked whether the area of the region of interest meets the preset requirement and whether the boundary is completely within the range of the original image, and an invalid region that does not meet the requirement is excluded to obtain an effective region of interest;

[0033] the boundary corresponding to the effective region of interest is projected onto the position of the original image, and the boundary information corresponding to the effective region of interest is converted into a format that can be recognized by a subsequent detection step, and an adapted region of interest parameter is output;

[0034] According to the adapted region of interest parameter, the range and parameter of the region of interest are labeled on the original image to obtain a labeled original image for subsequent detection.

[0035] In addition, to achieve the above-mentioned purpose, the present application also provides a tennis court detection device, which comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the control method for reducing the detection range of the tennis court as described above.

[0036] In addition, in order to achieve the above-mentioned purpose, the application further provides a storage medium, which is a computer readable storage medium, and a computer program is stored on the storage medium, and the computer program is executed by a processor to implement the steps of the control method for reducing the detection range of a tennis court as described above.

[0037] The application provides a control method for reducing the detection range of a tennis court, which comprises the following steps: performing dimension reduction and denoising processing on a tennis court original image, then remodeling the processed image into a two-dimensional array to obtain image data, then clustering and identifying the pixel colors in the image data to screen out the main color corresponding to the tennis court, then generating a binary mask according to the main color and normalizing the binary mask according to a preset combination operation to obtain a target binary mask, then performing connected region analysis on the target binary mask and screening out the largest connected region to generate a largest connected region mask, and finally performing multi-direction projection processing on the largest connected region mask to determine the region of interest corresponding to the tennis court. The technical scheme solves the technical problems that the original image of the tennis court is interfered by noise, the background information is complex, the main body region of the court is difficult to accurately position, the amount of original image data is large, the subsequent processing calculation load is high, and the efficiency is low, improves the accuracy of positioning the region of interest of the tennis court, reduces the invalid calculation amount in the image preprocessing process, and improves the overall efficiency of the tennis court image preprocessing.

[0038] In summary, the application performs dimension reduction and denoising on the original image of the tennis court, remodels the array to obtain image data, clusters and screens the main color, generates a regular binary mask, finds the largest mask in the connected domain, and determines the region of interest through multi-direction projection, thereby solving the technical problem of poor detection effect of the tennis court, reducing invalid calculation and interference, and improving preprocessing efficiency and positioning accuracy. BRIEF DESCRIPTION OF DRAWINGS

[0039] The accompanying drawings incorporated in and forming a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.

[0041] Figure 1 The flowchart of the first embodiment of the control method for reducing the detection range of a tennis court of the application;

[0042] Figure 2 The overall flowchart of the application;

[0043] Figure 3 Mask image of the largest connected region for the present application;

[0044] Figure 4 Flowchart of the seventh embodiment of the control method for reducing the detection range of the tennis court in the present application;

[0045] Figure 5 Flowchart of the eighth embodiment of the control method for reducing the detection range of the tennis court in the present application;

[0046] Figure 6 Region of interest identification image in the present application;

[0047] Figure 7 Structural schematic diagram of the tennis court detection device in the present application.

[0048] The object implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0049] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0050] In the related art, the whole image scanning and operation processing paradigm is usually used for the whole high-resolution image, and such whole image processing needs to deal with all background disturbances in the image without distinction, which not only increases the complexity of algorithm design, but also increases the risk of false detection, ultimately resulting in poor detection effect of the tennis court.

[0051] The present application provides a solution: first, the original image of the tennis court is processed by dimension reduction and reshaping to obtain image data in the form of a two-dimensional array, then the pixel colors in the image data are clustered, the main color corresponding to the tennis court is identified and screened out, then the binary mask is generated according to the main color, and the binary mask is regularized according to the preset combination operation to obtain a target binary mask, then the target binary mask is analyzed by connected domain analysis, the largest connected region in the target binary mask is screened out, a largest connected region mask is generated, and finally the largest connected region mask is processed by multi-directional projection to determine the region of interest corresponding to the tennis court.

[0052] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a tennis court detection device, etc. The present embodiment and the following embodiments will be described below taking the tennis court detection device as an example.

[0053] For better understanding of the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and specific embodiments.

[0054] The embodiment of the present application provides a control method for reducing the detection range of a tennis court, which refers to Figure 1 , Figure 1 The flowchart of the first embodiment of the control method for reducing the detection range of a tennis court is shown in the figure.

[0055] In the embodiment, the control method for reducing the detection range of a tennis court comprises steps S10-S50:

[0056] In step S10, the original image of the tennis court is subjected to dimension reduction processing and reshaping processing to obtain image data in the form of a two-dimensional array.

[0057] In the embodiment, dimension reduction refers to a processing process of reducing the data size by reducing the total number of image pixels and eliminating irregularly distributed speckle points or interference information in the image. The original image refers to the initial image data containing the tennis court and background information obtained directly without any processing. The processed original image refers to an image with reduced pixel number and removed interference information after dimension reduction and denoising operations. Reshaping into a two-dimensional array refers to arranging the pixel information of the processed image in a specific order to form structured data in the form of rows and columns corresponding to different dimensions of image pixel information. Image data refers to a structured pixel information set that can be directly used for subsequent clustering and other computing operations after reshaping into a two-dimensional array.

[0058] As an optional implementation, the original image of the tennis court obtained initially is subjected to dimension reduction processing, the number of pixels in each row and each column of the image is reduced by a fixed ratio, the total number of pixels is reduced while the overall pixel distribution trend of the image is retained. After dimension reduction, denoising processing is performed on the dimension-reduced image, a plurality of pixels adjacent to each pixel in the image are selected, the median value of the color information of the adjacent pixels is calculated, and the color information of the original pixel is replaced with the median value to remove discrete speckle points in the image. After the dimension reduction and denoising processing is completed, the color information of all pixels in each row is extracted in the row order of the processed image, the color information of each row of pixels is taken as a data group, and the data groups of all rows are arranged in the row order to form a two-dimensional array with rows corresponding to image pixel rows and columns corresponding to pixel color information, and finally image data that can be used for subsequent operations is obtained. The image data generated by this method has a significant reduction in data volume, the data processing efficiency is high during subsequent clustering operations, and the interference of discrete noise on subsequent color recognition can be effectively avoided.

[0059] As another optional implementation, the tennis court original image is divided into a plurality of adjacent pixel blocks of the same size, the average value of color information of all pixels in each pixel block is calculated, and the average value is used as the color information of a single new pixel. Each pixel block corresponds to a new pixel. In this way, the total number of pixels of the image is reduced. After dimension reduction is completed, denoising processing is performed on the reduced image. Different weights are set according to the distance between pixels in the image. The closer the distance between pixels, the greater the weight. The weighted average value of each pixel and the pixels within a certain range around the pixel is calculated, and the weighted average value is used to replace the color information of the original pixel. After the dimension reduction and denoising processing are completed, the color information of all pixels in each column of the processed image is extracted in sequence according to the column order. The color information of each column of pixels is used as a data group. The data groups of all columns are arranged in sequence according to the column order to form a two-dimensional array in which the rows correspond to image pixel columns and the columns correspond to pixel color information. Finally, the image data is obtained. This method can retain the overall color characteristics of each pixel block, reduce detail loss, make the color transition of the denoised image more natural, and avoid local color harshness.

[0060] In step S20, the pixel colors in the image data are clustered, and the main color corresponding to the tennis court is identified and screened.

[0061] In this embodiment, clustering refers to a process of dividing all pixel colors in the image data into different groups according to similarity, so that the pixel colors in the same group have small differences and the pixel colors in different groups have large differences. Pixel color refers to the color information corresponding to each pixel in the image data. Screening refers to excluding color groups corresponding to background areas in the clustering results and retaining color groups that meet the characteristics of the site. The main color refers to the core color group that can represent the main area of the tennis court after clustering and screening.

[0062] As an optional implementation, the color information of all pixels in the image data is first extracted, and the color information is divided into a plurality of independent groups according to similarity, and each group corresponds to a characteristic color. After grouping is completed, the number of pixels included in each color group is counted, and the number of pixels of all groups is recorded and sorted. According to the characteristic that the tennis court usually occupies a large area in the image, the color groups with low pixel quantity ranking and small area are excluded, and the color group with the highest pixel quantity ranking is retained. The color corresponding to the color group with the highest pixel quantity ranking is determined as the main color corresponding to the tennis court. This method has high processing efficiency and is suitable for image scenes with small background color area and no large-area continuous background, and can quickly lock the color group of the site.

[0063] As another optional implementation, color information of all pixels in the image data is extracted, and the image data is divided into multiple color groups according to the hue, saturation, and other characteristics of the colors, while the position information of each pixel in the two-dimensional array of the image data is recorded to establish the correspondence between the color groups and the pixel positions. After the grouping is completed, the number of pixels in each color group is counted, and the candidate groups whose pixel number reaches a certain proportion are preliminarily screened out. Further analysis of the position distribution of the pixels in the candidate groups is performed to determine whether the pixels form a continuous region in the two-dimensional array, and the candidate groups with scattered pixel positions are excluded, and the color groups whose pixel number meets the standard and whose positions are continuous are retained, and the corresponding color is determined as the main color corresponding to the tennis court. This method can more accurately identify the main color that truly belongs to the tennis court, reduce the misjudgment caused by the interference of background colors, and is suitable for image scenes with complex backgrounds and large-area continuous background colors.

[0064] In step S30, after the binary mask is generated according to the main color, the binary mask is regularized according to a preset combination operation to obtain a target binary mask.

[0065] In this embodiment, the binary mask refers to an image mask generated according to the main color, which only contains two colors. The preset combination operation refers to an operation set composed of multiple morphological processing steps in a fixed order. Regularization refers to the process of optimizing the initially generated binary mask to eliminate the problems of noise, holes, or irregular boundaries. The target binary mask refers to the final binary mask after the preset combination operation is regularized, which has a clear boundary, no obvious interference, and can accurately correspond to the target region.

[0066] As an optional implementation, the main color is taken as a reference to traverse all pixels in the image after dimensionality reduction and denoising, and the pixels with the same color as the main color are marked as one color, and the remaining pixels with different colors are marked as another color to generate an initial binary mask. Then, the first step of the preset combination operation, morphological opening operation, is performed. First, the initial binary mask is eroded to reduce the boundary of the target region and eliminate isolated noise points in the mask. Then, the eroded mask is dilated to restore the boundary shape of the main body of the target region and avoid excessive shrinkage of the main body region. Subsequently, the second step of the preset combination operation, morphological closing operation, is performed. First, the mask after the opening operation is dilated to expand the boundary of the target region to fill the small holes in the main body. Then, the dilated mask is eroded to shrink the boundary to the original main body range and smooth the edge jaggedness. After the above two combination operations are completed, the target binary mask with regular boundary, no noise, and small holes is obtained. This method is suitable for scenes where the number and size of noise and holes in the initial binary mask are small, and can quickly obtain a regular mask.

[0067] Step S40, connected domain analysis of the target binary mask, screening out the largest connected region in the target binary mask, generating the largest connected region mask.

[0068] In this embodiment, connected domain analysis refers to the process of identifying and labeling the set of pixels with the same color and adjacent to each other in the binary mask, and distinguishing different independent regions. The connected region refers to the independent set of pixels in the binary mask composed of adjacent pixels with the same color. The largest connected region refers to the independent set of pixels with the most pixels among all connected regions. The largest connected region mask refers to a special binary mask formed by retaining only the pixels of the largest connected region in the target binary mask and setting the remaining region pixels to non-target color.

[0069] As an optional implementation, the target binary mask is traversed in full range, starting from the top-left pixel, and the color of each pixel is checked in turn. If it is the target color and has not been marked, the pixel is taken as the starting point, and all adjacent target color pixels are classified into the same region by using neighborhood search, and a unique identifier is assigned to the region. Continue to traverse the remaining unmarked pixels, repeat the above neighborhood search and marking operation, until all target color pixels are classified into corresponding regions and marked. After completing all connected domain marking, count the number of pixels contained in each connected region with a unique identifier, record the number of pixels corresponding to each identifier and sort them. Filter out the identifier with the most pixels, and traverse the target binary mask again to retain the region pixels corresponding to the identifier as the target color, and set all other regions to non-target color, finally generating the largest connected region mask containing only the largest connected region. This method is suitable for scenarios where the connected domains in the target binary mask are scattered and numerous, ensuring accurate identification of the largest region.

[0070] As another alternative implementation, a region information set is initialized first, recording the pixel range and pixel number of each connected region. Then the target binary mask is traversed pixel by pixel in row. When a target color pixel is encountered, it is checked whether the pixel above and to the left of it has already belonged to a recorded connected region. If there is only a recorded region above, the current pixel is attributed to the region, and the pixel number and range of the region are updated. If there is only a recorded region to the left, the current pixel is attributed to the left region and the information is updated. If there are recorded regions above and below, and they are different regions, the two regions are merged, and the pixel number and range of the merged region are updated. If there are no recorded regions above and below, a new connected region is created, the current pixel is attributed to the region, and the initial pixel number and range are recorded. After all pixels are traversed, the region information set is filtered to select the region with the largest pixel number, and the pixel range of the region is extracted. Finally, the target binary mask is traversed according to the pixel range, only the pixels within the range are set to the target color, and the pixels outside the range are set to the non-target color, to generate the maximum connected region mask. This method is suitable for scenarios where the connected regions in the target binary mask are regularly distributed, without obvious diagonal neighbors or small disconnections, and can quickly generate the maximum connected region mask, meeting the demand for high processing efficiency.

[0071] Step S50, the maximum connected region mask is processed by multi-direction projection to determine the region of interest corresponding to the tennis court.

[0072] In this embodiment, the multi-direction projection processing refers to a processing procedure of counting the number of target color pixels in the mask along multiple different directions, and determining the region boundary through the pixel distribution rule. The region of interest corresponding to the tennis court refers to a specific rectangular region determined from the maximum connected region mask, which can completely cover the main range of the tennis court, and is used for subsequent detection processing.

[0073] As an optional implementation, a horizontal direction projection processing is performed on the maximum connected region mask, the mask is traversed row by row along the horizontal direction, the number of target color pixels in each row is counted, a judgment threshold is set, and effective rows in which the number of target color pixels exceeds the threshold are screened out, the effective rows are arranged in index order, and the longest continuous segment of the effective rows is found, the starting index of the segment is taken as the upper boundary of the region, and the terminal index is taken as the lower boundary of the region. Then, a vertical direction projection processing is performed on the maximum connected region mask, the mask is traversed column by column along the vertical direction, the number of target color pixels in each column is counted, the same judgment threshold as the horizontal direction is adopted, effective columns in which the number of target color pixels exceeds the threshold are screened out, the effective columns are arranged in index order, and the longest continuous segment is found, the starting index of the segment is taken as the left boundary of the region, and the terminal index is taken as the right boundary of the region. Finally, the determined upper, lower, left and right boundaries are combined to form a rectangular range, and the rectangular range is the region of interest corresponding to the tennis court. This method is suitable for the scene in which the boundary of the maximum connected region is regular, there is no obvious inclination, and there is no oblique interference on the edge, and can quickly obtain the region of interest covering the main body, thereby meeting the requirement of giving priority to processing efficiency.

[0074] As another optional implementation, a horizontal and vertical direction basic projection processing is first performed on the maximum connected region mask, the number of target color pixels is counted row by row along the horizontal direction, effective rows are screened out, and preliminary upper and lower boundaries are determined, the number of target color pixels is counted column by column along the vertical direction, effective columns are screened out, and preliminary left and right boundaries are determined. Then, an oblique direction projection processing is performed on the maximum connected region mask, the mask is traversed along the oblique direction of a preset degree, the mask is divided into multiple parallel oblique rows along the oblique direction, the number of target color pixels in each oblique row is counted, an effective oblique row is screened out by setting a judgment threshold, the longest continuous segment of the effective oblique row of the first preset degree oblique direction is found, and the effective range in the direction is determined, and the effective range in the second preset degree oblique direction is determined in the same manner. Finally, the preliminary boundaries of the basic projection and the effective ranges of the oblique projection are combined and corrected: if the preliminary boundaries exceed the oblique effective range, the preliminary boundaries are adjusted to the edge of the oblique effective range, and if the preliminary boundaries are within the oblique effective range, the preliminary boundaries remain unchanged, and the rectangular region enclosed by the corrected upper, lower, left and right boundaries is the region of interest corresponding to the tennis court. This method is suitable for the scene in which the boundary of the maximum connected region has slight inclination or the edge has oblique interference pixels, and can obtain a more accurate and more fitted region of interest to the main body of the court.

[0075] Exemplarily, with reference to Figure 2 , Figure 2The present application is a whole flowchart. In the preprocessing scene of the tennis court image, a red clay tennis court event image with a resolution of 2048x1152 is read, which contains red court, white marking line, green net and audience background; first, the image is reduced to 640x360 size, and 5x5 median filter kernel is used for blurring to eliminate the color noise of the court surface caused by dust. Then the K-means color clustering is performed on the pixels of the reduced image, and the number of clusters is set to 4, and the brick red of the red clay, the white marking line, the green net and the gray of the audience seat are clustered respectively, and the pixel category corresponding to the brick red is selected as the main color of the court. Based on the color category, a 640x360 binary mask is generated, in which the brick red pixels are marked as white and the rest are black, and the mask is enlarged back to the original size of 2048x1152 through bicubic interpolation. Morphological opening operation (using 7x7 rectangular structure element, first erosion then dilation) is performed on the enlarged mask to remove the scattered white spots caused by clustering residues, such as the audience seat red clothes misjudgment points, and then the close operation (also using 7x7 rectangular structure element, first dilation then erosion) is performed to fill the small black holes of the red clay court caused by the players' sliding. After processing the mask, the connected domain analysis is performed, and all white connected regions are marked, and the maximum connected region pixel number is calculated to be 40% of the original image, which is determined as the effective region. Then the row projection is performed on the region mask, and the white pixel number is counted row by row, and the longest continuous segment of the effective row is selected by setting 8% of the total number of pixels in each row as the effective threshold, and the upper boundary is set to the 150th row and the lower boundary is set to the 1000th row. Then the column projection is performed, and the white pixel number is counted column by column, and the longest continuous segment of the effective column is selected by setting 8% of the total number of pixels in each column as the effective threshold, and the left boundary is set to the 300th column and the right boundary is set to the 1700th column. Finally, the rectangle region surrounded by the upper and lower boundaries is the region of interest of the red clay tennis court, which completely covers the red clay court range of the competition.

[0076] Further, in the whole process of processing the tennis court image data, a two-dimensional array is used to store the image data, the core reason is that the natural two-dimensional structure attribute of the image data is adapted to the processing logic of each link of the technical scheme. The image is composed of rows and columns of pixels, and the position of each pixel can be uniquely determined by row index and column index. The two-dimensional array can directly map this structure without additional data conversion to preserve the correspondence between pixel position and color information. At the same time, the subsequent scheme of horizontal row-by-row white pixel number statistics, vertical column-by-column white pixel number statistics, and boundary parameter determination based on index, all need to traverse the data by row and column dimensions, and the row and column indexes of the two-dimensional array can be directly used as pixel position identifiers, avoiding the redundant steps of additional position mapping relationship calculation required by other data structures.

[0077] The original image of the tennis court is reduced in dimension and denoised, and the image data is obtained by remodeling the array, the main color is screened by clustering, the regular binary mask is generated, the maximum mask is found in the connected domain, the region of interest is determined by multi-direction projection, and the technical problem of poor detection effect of the tennis court is solved, thereby reducing invalid calculation, reducing interference, and improving preprocessing efficiency and positioning accuracy.

[0078] In the second embodiment of the present application based on any of the above embodiments, the step S10 comprises steps A11-A13.

[0079] In step A11, the original image is reduced to a preset proportion of the original size by a dimension reduction operation to obtain a reduced tennis court image.

[0080] In this embodiment, the preset proportion of the original size refers to a preset proportion for reducing the original image. The reduced tennis court image refers to a tennis court image whose size is reduced to a preset proportion of the original image after dimension reduction operation.

[0081] As an optional implementation, the number of horizontal pixels and the number of vertical pixels of the original image are first determined, and the number of horizontal and vertical pixels of the reduced image is calculated according to the preset proportion. Along the horizontal direction of the original image, the pixels are sequentially traversed from left to right, and the pixels are selected at the calculated horizontal proportion interval. The selected pixels are recorded in order as the horizontal pixel sequence of the reduced image. Then along the vertical direction of the original image, the pixels are sequentially traversed from top to bottom, and the pixels are selected at the calculated vertical proportion interval. The selected pixels are recorded in order as the vertical pixel sequence of the reduced image. Finally, the pixels selected in the horizontal and vertical directions are combined according to the arrangement logic of the original image to form the reduced tennis court image. This method is suitable for scenarios with high processing speed requirements and low detail accuracy requirements.

[0082] As another optional implementation, the original image is first divided into multiple rectangular pixel blocks of the same size according to the preset proportion, and each pixel block contains a certain number of pixels in the horizontal and vertical directions of the original image. For all pixels in each rectangular pixel block, the color information of the pixels is extracted, and the comprehensive average value of the color information is calculated. The color average value corresponding to each pixel block is taken as the color information of a new pixel, and each pixel block corresponds to a new pixel in the reduced image. According to the arrangement order of the rectangular pixel blocks in the original image, all new pixels are sequentially arranged to form the reduced tennis court image. This method is suitable for scenarios with high image smoothness and detail retention requirements and acceptable slow processing speed.

[0083] In step A12, the reduced tennis court image is denoised by replacing the center pixel with the median value of the local pixel region to generate a processed original image.

[0084] In the embodiment, the local pixel region refers to a set of pixels around a certain pixel within a certain range. The median refers to the color information in the middle position after arranging the color information of all pixels in the local pixel region in a certain order. The center pixel refers to the pixel in the center position in the local pixel region. The processed original image refers to the tennis court image after noise removal and reduction.

[0085] As an optional implementation, the basic range of the local pixel region is first set, and a color difference threshold is set. The processing starts from the top left corner of the reduced tennis court image. For the current center pixel, the color information of the local pixels in the basic range is first extracted, the difference between these colors and the original color of the center pixel is calculated, and if the number of pixels with a difference exceeding the threshold is small, it is determined that there is little noise, and the median of the basic range is directly taken to replace the center pixel. If the number of pixels with a difference exceeding the threshold is large, it is determined that there is dense noise, and the range of the local pixel region is expanded, the color information of all pixels in the expanded region is extracted, and the median is taken after arranging in order to replace the center pixel. When processing the edge pixels, the region is only expanded within the image range to ensure that it does not exceed the image boundary. After processing all the pixels in turn, the processed original image is generated. This method can adapt the processing strategy according to the noise density by dynamically adjusting the region range, and can remove dense noise more thoroughly while reducing the excessive modification of normal pixels.

[0086] Step A13, the processed original image is reshaped into a two-dimensional array in row and column order, and the image data meeting the format requirements is output.

[0087] In the embodiment, the row and column order refers to the arrangement order of image pixels in horizontal rows and vertical columns. Meeting the format requirements refers to the array structure, element type, etc. meeting the input specifications of subsequent processing.

[0088] As an optional implementation, the number of rows and columns of the processed original image is first determined, and the color information of all pixels in each row is extracted in the order from left to right and from top to bottom. Each row of color information is taken as a data group, all row data groups are arranged in row order to form a two-dimensional array with rows corresponding to image pixel rows and columns corresponding to pixel color information. The element type of the array is checked to see if it meets the requirements of subsequent processing. If it meets the requirements, the image data is output. This method extracts the image data in row order, which meets the conventional arrangement logic of images, is simple to process, and has good adaptability to subsequent row processing tasks.

[0089] Exemplarily, in the preprocessing scene of the tennis court image, a tennis court original image with a resolution of 1920x1080 is read, and the original image is reduced to a preset scale of 1 / 3 of the original size through dimension reduction operation to obtain a reduced tennis court image with a resolution of 640x360. The reduced image is subjected to denoising processing, a local pixel region with a size of 3x3 is adopted, color information of all pixels in each region is extracted and a median value is taken, the original color of the center pixel of the region is replaced with the median value, and a processed original image is generated; finally, the processed image is reshaped into a two-dimensional array with 640 rows and 360 pixel color information in each row in the order of rows and columns, and image data meeting the format requirements of subsequent K-means clustering is output.

[0090] Due to the dimension reduction, median denoising, and reshaping of the two-dimensional array, the problem of slow subsequent processing and noise interference with color recognition caused by large tennis court image data is solved, and the detection efficiency is improved.

[0091] Based on any of the above embodiments, in Embodiment Three of the present application, the step S20 comprises steps B11-B13:

[0092] Step B11: clustering pixel colors in the image data according to a clustering algorithm, and outputting a clustering result containing a preset number of pixel color clusters.

[0093] In this embodiment, the clustering algorithm refers to an algorithm for dividing numerous pixel colors in an image into multiple independent groups by calculating the similarity between pixel colors. The clustering result refers to a set of each cluster containing a number of similar pixel colors divided according to the preset number after the clustering algorithm is processed.

[0094] As an optional implementation, color information of all pixels is first extracted from the image data row by row and column by column, and arranged into an independent pixel color list. A preset number of pixel color clusters is set according to requirements, and an equal number of pixel colors are randomly selected from the color list as initial cluster centers. Each pixel color in the color list is traversed, the similarity between the color and each initial cluster center is calculated, and the pixel color is classified into the cluster with the highest similarity. After all pixel colors are classified, the average color of all pixel colors in each cluster is calculated, and the center of the corresponding cluster is updated with the average color. The process of reclassifying pixel colors, calculating average colors, and updating cluster centers is repeated until the color difference between all cluster centers after adjacent two updates is less than a preset small threshold, and the iteration is stopped. Finally, a clustering result containing a preset number of pixel color clusters is output. This method has a clear processing flow, does not require additional adjustment of the number of clusters, and has a relatively fast overall calculation speed.

[0095] Step B12: counting the number of pixels contained in each pixel color cluster, and sorting each pixel color cluster according to the size of the number of pixels to obtain a color cluster list.

[0096] In the embodiment, the pixel color cluster refers to an independent grouping composed of similar pixel colors after being divided by a clustering algorithm. The pixel quantity refers to the specific total number of pixels in each pixel color cluster. The color cluster list refers to an ordered set containing each pixel color cluster and its corresponding quantity after being sorted by pixel quantity.

[0097] As an optional implementation, all pixel color clusters are traversed first, and the pixel count is performed for each cluster individually: the pixels in the cluster are extracted one by one, and the count is incremented by one for each extracted pixel, until all pixels in the cluster are extracted, and the identification of each pixel color cluster and its corresponding pixel quantity are recorded. After the quantity statistics of all clusters are completed, the associated information set of cluster identification and pixel quantity is sorted out. Based on the pixel quantity, the associated information is arranged in descending order, ensuring that the clusters in the previous sequence correspond to larger pixel quantities, and the clusters in the subsequent sequence correspond to smaller pixel quantities. After the arrangement is completed, an ordered set containing all pixel color clusters and their quantities is formed, which is the color cluster list. This method does not have a screening step, can completely retain all pixel color clusters, and has simple statistics and sorting logic and fast processing speed.

[0098] Step B13, the target pixel color cluster with the most pixel quantity in the color cluster list is screened out, and the color parameter corresponding to the target pixel color cluster is determined as the main color corresponding to the tennis court.

[0099] In the embodiment, the target pixel color cluster refers to the pixel color cluster containing the most pixel quantity screened out from the color cluster list.

[0100] As an optional implementation, the pixel quantity corresponding to each pixel color cluster in the color cluster list is extracted, and the pixel quantity of the current cluster is compared with the pixel quantity of the next cluster in turn from the starting position of the list, and the identification and corresponding quantity of the cluster with larger pixel quantity after each comparison are recorded. After traversing all clusters in the list, the cluster with the largest pixel quantity in the record is determined as the target pixel color cluster. The color parameter corresponding to the target pixel color cluster is extracted, and the color parameter is directly determined as the main color corresponding to the tennis court. This method can determine the target cluster only by traversal comparison, and has simple steps and fast processing speed.

[0101] Exemplarily, in the preprocessing scene of the tennis court image, a tennis court image data of 640*360, i.e., a two-dimensional array, is taken, a K-means clustering algorithm is used to cluster the pixel colors in the image data, a preset number of pixel color clusters is 4, and a clustering result containing four color clusters of red clay, white lines, green netting and gray stands is output. The number of pixels in each color cluster is counted, the number of red clay clusters is 82000, the number of white clusters is 6500, the number of green clusters is 11000, and the number of gray clusters is 9800. The color cluster list is sorted in descending order of the number of pixels. The red clay cluster with the largest number of pixels in the list is selected as the target pixel color cluster, and the corresponding color parameter is determined as the main color of the tennis court.

[0102] Since the color clusters are divided by clustering, the target cluster is selected by counting and sorting, the problem of main color recognition confusion and low efficiency caused by background interference of the tennis court is solved, and the accuracy and efficiency of the court area extraction are improved.

[0103] Based on any of the above embodiments, in the fourth embodiment of the present application, the step S30 comprises steps C11-C14:

[0104] Step C11, all pixels in the image data are traversed, whether the color corresponding to each pixel belongs to the main color is distinguished, and an initial binary mask is generated by classification.

[0105] In this embodiment, the initial binary mask refers to a mask generated after classification, which uses only two colors to correspond to the pixels belonging to the main color and the pixels not belonging to the main color.

[0106] As an optional implementation, the color parameter of the main color is extracted, and a color difference allowed range is set. Starting from the top left corner of the image data, the pixels are traversed in column priority order. For the current pixel, the color parameter thereof is extracted, and the difference value between the parameter and the main color parameter is calculated. If the difference value is within the preset allowed range, it is determined that the color is changed to the main color, and the pixel is marked as the first type of color; if the difference value exceeds the allowed range, it is determined that the color is not the main color, and the pixel is marked as the second type of color. During the traversal process, the pixels at the edges and corners of the image are judged according to the same rule without special processing. After all the pixels are marked, the first type of color pixels are uniformly set to one color, and the second type of color pixels are uniformly set to another color, to generate an initial binary mask. This method has simple judgment logic, no additional calculation, fast processing speed, and high classification accuracy without misjudging the pixels of the non-main color as the main color.

[0107] Step C12, white noise in the initial binary mask is removed by morphological opening operation, and the boundary shape of the main body region of the initial binary mask is restored, to output a standard binary mask.

[0108] In the embodiment, the morphological opening operation refers to a combined morphological operation of first performing erosion processing on the image and then performing inflation processing, and the core role is to remove small noise points and retain the main region boundary. The white noise refers to the isolated and small-sized noise points in the initial binary mask which have the same color as the main region. The main region refers to the core region in the initial binary mask which has the same color as the main color of the tennis court, is large in size and continuous. The boundary shape refers to the contour shape and structure of the main region boundary. The standard binary mask refers to the binary image mask after the morphological opening operation, which removes the white noise and has a complete main region boundary.

[0109] As an optional implementation, a fixed shape and size of the structure element is determined, and the erosion processing is performed on the initial binary mask: the structure element is used as a template, and the initial binary mask is traversed pixel by pixel. Only when all the pixels in the coverage of the structure element are white, the current center pixel is retained as white, otherwise the center pixel is set to black. Through the operation, the white noise smaller than the structure element is eliminated. After the erosion processing is completed, the same structure element as in the erosion stage is used. The inflation processing is performed on the mask after the erosion: the same pixel-by-pixel traversal is performed. As long as there is at least one white pixel in the coverage of the structure element, the current center pixel is set to white. In this way, the part of the main region boundary reduced in the erosion process is restored, and the original boundary shape of the main region is maintained. After the combined operation of erosion and inflation is completed, the standard binary mask without white noise and with a complete main boundary is output. This method is suitable for the scene where the white noise in the initial binary mask is uniform in size and significantly different from the small details of the main region, and can quickly complete the denoising, but has poor adaptability to noise size changes.

[0110] As another optional implementation, the white pixels in the initial binary mask are analyzed first, the size of all isolated white noise points is counted, and the structure element is dynamically selected according to the size range of the noise points: for the noise points with extremely small size, a small structure element is matched. For the noise points with slightly larger size but still belonging to noise, a medium structure element is matched to ensure that the size of the structure element is slightly larger than the size of the corresponding noise point. According to the principle of processing different regions, different structure elements with corresponding sizes are used to perform erosion processing on the regions with different noise point sizes in the initial binary mask: the pixels in each region are traversed, only the center pixels in the coverage of the structure element which are all white are retained, and the white noise with different sizes is removed. After the erosion is completed, for each region, the inflation processing is performed using the structure element with the same size as in the erosion stage of the region, to restore the part of the main boundary reduced in each region. After the processing of all regions is completed, the regions are spliced and integrated to form a standard binary mask which is free of white noise and has consistent main boundary shape. This method is suitable for the scene where the white noise in the initial binary mask has different sizes, and has higher denoising accuracy and better main boundary protection.

[0111] Step C13, fill the small holes inside the standard binary mask and connect the adjacent tiny areas by morphological closing operation, and output the standard binary mask after the regularization process.

[0112] In this embodiment, the morphological closing operation is a combination of morphological operation, which first expands the image and then erodes it. The core function is to fill the holes inside the region and connect the adjacent small areas. Small holes refer to the small black blank areas inside the main body region of the standard binary mask. Adjacent tiny areas refer to the small white areas near the main body region of the standard binary mask, which are small in size and independent. The regularization process refers to the optimization process of making the main body structure of the standard binary mask more complete and the edge smoother by filling the holes and connecting the tiny areas. The standard binary mask after the regularization process refers to the complete binary image mask after the morphological closing operation, which has no small holes inside and the tiny areas are connected.

[0113] As an optional implementation, the standard binary mask is scanned in full range, and all internal small holes and adjacent tiny areas are identified and marked. The size of the basic structure element is determined according to the maximum size of the hole. For small holes with a size smaller than the basic structure element, the basic size structure element is used. For holes with a size close to or slightly larger than the basic structure element, the size of the structure element is expanded to be slightly larger than the size of the hole. For adjacent tiny areas, the shape of the structure element is adjusted according to the distance between the areas. Then, the morphological closing operation is performed in regions: for the marked small hole region, the corresponding size structure element is first expanded and then eroded. For the tiny area and the periphery, the structure element with adjusted shape is first expanded and then eroded. During the processing, the minimum size structure element is used to quickly sweep the non-hole and non-tiny area part of the main body region to avoid missing small defects. After all the regions are processed, the processing results of each region are spliced and integrated to ensure a natural transition between regions, and finally the standard binary mask after the regularization process is output. This method is suitable for scenes where the hole sizes in the standard binary mask are different and the tiny area distribution is complex, and can more thoroughly optimize the mask structure to generate a regularization mask with better main body integrity and edge smoothness.

[0114] Step C14, enlarge the standard binary mask after the regularization process to the same size as the original image to obtain the target binary mask of the original size.

[0115] In this embodiment, the same size means that the horizontal pixel number and the vertical pixel number of the enlarged mask are completely consistent with the original image. The target binary mask refers to the final binary mask after enlargement, which has the same size as the original image and can match the region positioning of the original image.

[0116] As an optional implementation, the current size of the normalized standard binary mask and the size of the original image are obtained, the magnification ratio of the two is calculated, and the horizontal and vertical pixel numbers of the enlarged target binary mask are determined according to the ratio. A blank binary mask consistent with the target size is created, and each pixel of the blank mask is traversed. For the currently traversed pixel, the corresponding reference pixel position in the normalized standard binary mask is calculated according to the magnification ratio. The color information of the nearest pixel around the reference pixel position is extracted, and the color information is assigned to the currently traversed blank mask pixel. Repeat the above process of calculating the reference position, extracting the color of the adjacent pixel, and assigning the value until all pixels of the blank mask are filled with color. Finally, a target binary mask with the same size as the original image is obtained. This method does not require complex calculation, the operation logic is simple, the overall processing speed is fast, and it is suitable for scenes where the edge accuracy of the mask is not high and the processing efficiency is prioritized.

[0117] Exemplarily, in the pre-processing scene of the tennis court image, take the 640x360 image data of the hard court tennis court, use the K-means clustering algorithm to cluster the pixel colors, and preset the number of pixel color clusters to 5. The clustering results include hard court blue, white marking line, green seat, gray billboard, and brown ground. The number of pixels in each pixel color cluster is counted, and the hard court blue cluster has 78000 pixels, the white cluster has 5200 pixels, the green cluster has 9500 pixels, the gray cluster has 6800 pixels, and the brown cluster has 4300 pixels. According to the number of pixels from large to small, the color cluster list is obtained. The hard court blue cluster with the most pixels in the color cluster list is selected as the target pixel color cluster, and the RGB color parameters corresponding to the target pixel color cluster are determined as the main color of the tennis court.

[0118] By clustering to divide the pixel color clusters, counting and sorting to select the target pixel color cluster, the problem of main color recognition confusion and low processing efficiency caused by background color interference of the tennis court is solved, and the generation accuracy of the target binary mask and the overall process processing efficiency are improved.

[0119] Based on any of the above embodiments, in the fifth embodiment of the present application, the step S40 includes steps D11-D14:

[0120] Step D11, identify and mark all connected white pixel regions in the target binary mask to obtain a region mask containing the label information of each connected region.

[0121] In the embodiment, the white pixel region connected to each other refers to a set of independent pixels formed by white pixels adjacent in up-down and left-right directions without interruption. The connected region marking information refers to information recording the range of each unique identifier corresponding connected region, the number of pixels, and the corresponding relationship between all pixels in the region and the identifier. The region mask refers to associating each pixel with the unique identifier of the connected region to which it belongs, and each pixel position presents an image mask corresponding to the identifier.

[0122] As an optional implementation, a marking counter and a blank region mask with the same size as the target binary mask are initialized first. Starting from the top-left pixel of the target binary mask, each pixel is traversed in row-major order. When a white pixel is traversed and the pixel is not marked in the blank region mask, the marking counter is incremented by one. The current pixel is taken as the starting point, and a four-neighbor search is performed. If the adjacent pixel is white and not marked, it is included in the region corresponding to the current identifier, and the identifier of the adjacent pixel is marked in the blank region mask. Repeat the four-neighbor search until all white pixels connected to the current pixel are marked with the same identifier. Continue to traverse the remaining unmarked pixels, and repeat the above generation of identifier, four-neighbor search, and marking process until all white pixels in the target binary mask are marked. Finally, each pixel in the blank region mask corresponds to the unique identifier of the connected region to which it belongs, forming a region mask containing the marking information of each connected region. This method can accurately identify all white pixel regions connected to each other through four-neighbor search, and will not miss even if the region distribution is scattered and the shape is irregular, with high marking accuracy.

[0123] Step D12, traverse each connected region with identifier in the region mask, count the number of white pixels contained in each connected region, and generate an area statistics list recording each connected region identifier and its corresponding area.

[0124] In the embodiment, the connected region with identifier refers to an independent region composed of white pixels connected to each other in the region mask which is assigned a unique identifier. The number of white pixels refers to the specific total number of white pixels contained in each connected region. The connected region identifier refers to a unique mark used to distinguish different connected regions. The area statistics list refers to an ordered set recording each connected region identifier and its corresponding number of white pixels.

[0125] As an optional implementation, all pixels in the region mask are traversed to collect all unique connected region identifiers after removing duplicates. A blank area statistics table is initialized, and each identifier in the unique identifier list is sequentially filled into the identifier column of the table. For each filled identifier in the table, all pixels in the region mask are traversed again, and the number of white pixels corresponding to the identifier is counted by one each time a pixel with the same identifier is encountered. After the full mask traversal of the current identifier is completed, the final count is filled into the corresponding row of the table. The process of traversing the mask, counting, and filling the table is repeated until all unique identifiers are counted. Finally, the statistics table is sorted into an ordered set according to the identifier order to generate an area statistics list that records each connected region identifier and its corresponding area. This method ensures no error in the statistics results and is suitable for scenarios where accuracy is prioritized over efficiency.

[0126] Step D13: From the area statistics list, the target connected region with the largest area value is selected, the white pixels of the target connected region in the target binary mask are retained, and the pixels of other regions are all marked as black to generate the largest connected region mask.

[0127] In this embodiment, the target connected region refers to the connected region with the largest area value selected from the area statistics list. The largest connected region mask refers to a special binary mask in which only the white pixels of the target connected region in the target binary mask are retained, and the remaining regions are all marked as black.

[0128] As an optional implementation, all entries in the area statistics list are traversed first to extract the area values corresponding to each entry, and the largest area value is determined by successive comparison. Then the identifier of the connected region corresponding to the largest area value is found. Next, the target binary mask and the region mask are called, and the target binary mask is traversed pixel by pixel in row-major order. For the currently traversed pixel, the identifier of the pixel at the corresponding position in the region mask is checked: if the identifier is consistent with the identifier of the target connected region, the white pixel in the target binary mask is retained. If not, the pixel is marked as black. All pixels are continuously traversed until all pixels in the target binary mask are judged and processed. Finally, the largest connected region mask is generated, which only retains the white pixels of the target connected region. This method does not require additional storage of coordinate positions and only needs to traverse the target binary mask and the region mask simultaneously to complete the processing, with low memory usage.

[0129] For example, refer to Figure 3 , Figure 3The maximum connected region mask of the present application is obtained. In the preprocessing scene of the tennis court image, a target binary mask (white color is the candidate court region, black color is the background) with the same size as the original tennis court image of 1920x1080 is used. All the white pixel regions in the target binary mask that are connected to each other are identified and labeled by using the four-neighborhood search, and each region is assigned a unique digital identifier. A region mask containing the label information of each connected region is obtained, and a total of 5 connected regions are labeled, which correspond to the main body of the court, 3 white line fragments, and 1 misjudged white area of the stands. Each connected region with an identifier in the region mask is traversed, and the number of white pixels in each region is counted to generate an area statistics list (identifier 1: 850000 pixels, identifier 2: 1200 pixels, identifier 3: 800 pixels, identifier 4: 950 pixels, identifier 5: 1500 pixels). The target connected region corresponding to the identifier 1 with the largest area value is selected from the list, and the white pixels in the region of the target binary mask are retained. The pixels in the other 4 regions are all marked as black, and the maximum connected region mask is generated.

[0130] Since the maximum region is selected by connected region labeling and area statistics, the problem of interference of non-court white regions caused by line fragments and background misjudgment in the target binary mask is solved, and the accuracy of court extraction and the overall process efficiency are improved.

[0131] Based on any of the above embodiments, in Embodiment Six of the present application, the step S50 includes steps E11-E15:

[0132] In step E11, the number of white pixels in the maximum connected region mask is counted horizontally row by row, the valid rows are selected according to a preset threshold, the continuous segments of the valid rows are separated and the indexes are recorded, and the row continuous segment information is obtained.

[0133] In this embodiment, horizontal row-by-row counting refers to an operation of calculating the number of white pixels in each row of the maximum connected region mask in the order from top to bottom along the horizontal direction of the image. The preset threshold refers to a white pixel number standard that is set in advance for judging whether a row is a valid row. The valid row refers to a row with a white pixel number not exceeding the preset threshold. The valid row continuous segment refers to a continuous row sequence composed of a plurality of adjacent valid rows. The index refers to a serial number used to identify the position of each row in the maximum connected region mask. The row continuous segment information refers to a set of start index and end index of each valid row continuous segment.

[0134] As an optional implementation, the total number of rows of the maximum connected region mask is determined first, and the horizontal row-by-row statistics are performed in the order from top to bottom: for the current row, all pixels in the row are traversed from left to right, and the count is incremented by one every time a white pixel is encountered. After the statistics are completed, the index of the row and the corresponding number of white pixels are recorded synchronously, and until all rows are completed and a complete list of row indexes and white pixel numbers is formed. Then, the rows with a number of white pixels not exceeding the preset threshold are filtered from the list, and are marked as valid rows, while the rows with a number of white pixels exceeding the threshold are marked as invalid rows. Subsequently, the first row of the list is traversed, and when the first valid row is encountered, the index thereof is recorded as the starting index of a certain valid row continuous segment, and the traversal continues downward, and if the next row is still a valid row, the following is continued, and if an invalid row is encountered or the last row is reached, the index of the previous row is recorded as the termination index of the continuous segment. The above process of recording the starting index, tracking the continuity, and determining the termination index is repeated until all valid rows are classified into corresponding continuous segments, and finally the starting index and the termination index of all continuous segments are arranged to obtain the row continuous segment information. This method can clearly control the distribution of all rows, avoid missing or misclassifying valid rows due to single row statistics deviation, and the segmentation logic is direct and highly accurate.

[0135] Step E12, filtering the longest row continuous segment from the row continuous segment information, determining the vertical upper and lower boundaries according to the index corresponding to the longest row continuous segment, and outputting the vertical boundary parameters.

[0136] In this embodiment, the vertical upper and lower boundaries refer to the position parameters composed of the starting index and the termination index of the longest row continuous segment, which define the vertical range of the target region. The vertical boundary parameters refer to a parameter set containing the upper boundary index and the lower boundary index, which are used to clearly define the vertical range of the target region.

[0137] As an optional implementation, the starting index and the termination index of all valid row continuous segments in the row continuous segment information are extracted, and for each continuous segment, the length thereof is calculated by the termination index, the starting index plus one. The length, the starting index, and the termination index of all continuous segments are arranged into an associated list. The associated list is traversed, and the lengths of the continuous segments are compared one by one, and the length value and the corresponding starting index and termination index of the continuous segment with the largest length after each comparison are recorded. After the traversal is completed, the continuous segment corresponding to the recorded length with the largest value is confirmed as the longest row continuous segment, the starting index of the continuous segment is determined as the vertical upper boundary, and the termination index is determined as the vertical lower boundary. The upper boundary index and the lower boundary index are integrated, and the vertical boundary parameters are output. This method can directly locate the continuous segment with the largest length, the operation process is simple, no additional judgment conditions are required, and the processing speed is fast.

[0138] Step E13, count the number of white pixels in the maximum connected region mask row by row vertically, filter the valid columns according to a preset threshold, separate the continuous segments of the valid columns and record the indexes to obtain column continuous segment information.

[0139] In this embodiment, vertical row-by-row statistics refers to the operation of calculating the number of white pixels in each column of the maximum connected region mask column by column in the order from left to right along the vertical direction of the image. The valid column refers to the column whose number of white pixels does not exceed the preset threshold. The valid column continuous segment refers to a continuous column sequence composed of a plurality of adjacent columns which are all valid columns. The column continuous segment information refers to a set of records of the starting index and the ending index of each valid column continuous segment.

[0140] As an optional implementation, the total number of columns of the maximum connected region mask is determined, and the vertical row-by-row statistics is performed column by column in the order from left to right: for the current column, all pixels in the column are traversed from top to bottom, and the count is incremented by one every time a white pixel is encountered. After the statistics is completed, the index of the column and the corresponding number of white pixels are recorded synchronously, until all columns complete the statistics and form a complete list of column indexes and numbers of white pixels. Then, the columns whose number of white pixels does not exceed the preset threshold are filtered out from the list and marked as valid columns, while the columns whose number of white pixels exceeds the threshold are marked as invalid columns. Subsequently, the first column of the list is traversed, and when the first valid column is encountered, its index is recorded as the starting index of a certain valid column continuous segment. Continue to traverse to the right, if the next column is still a valid column, continue to follow, if an invalid column is encountered or the last column is reached, record the index of the previous column as the ending index of the continuous segment. Repeat the above process of recording the starting index, tracking the continuity, and determining the ending index, until all valid columns are classified into corresponding continuous segments. Finally, the starting index and the ending index of all continuous segments are sorted to obtain the column continuous segment information. This method can clearly control the distribution of all columns, avoid missing or misfiltering of valid columns due to single column statistics deviation, and the segmentation logic is direct and accurate.

[0141] Step E14, filter out the longest column continuous segment from the column continuous segment information, determine the left and right boundaries in the horizontal direction according to the index corresponding to the longest column continuous segment, and output the horizontal boundary parameter.

[0142] In this embodiment, the left and right boundaries in the horizontal direction refer to the position parameters that define the horizontal range of the target region, which are composed of the starting index and the ending index of the longest column continuous segment. The horizontal boundary parameter refers to a parameter set containing the left boundary index and the right boundary index, which is used to clearly define the horizontal range of the target region.

[0143] As an optional implementation, the starting index and the ending index of all valid column continuous segments in the column continuous segment information are extracted, and for each continuous segment, the length thereof is calculated through the ending index, the starting index plus one. The lengths of all continuous segments and the corresponding starting and ending indexes are sorted into an associated list of length, starting index, and ending index. Starting from the first entry of the associated list, the length of the current entry is compared with the length of the subsequent entry, and each time a larger length entry is encountered, the record of the current longest segment is updated. After all entries are traversed, the continuous segment corresponding to the current longest segment is confirmed as the longest column continuous segment, the starting index of the continuous segment is determined as the horizontal left boundary, and the ending index is determined as the horizontal right boundary. The left boundary index and the right boundary index are integrated into a set of parameters, and the horizontal boundary parameters are output. This method is suitable for scenarios where the lengths of the continuous segments in the column continuous segment information differ significantly and there are no length-same candidate segments, can quickly output the horizontal boundary parameters, and meets the demand for prioritizing processing efficiency.

[0144] Step E15, integrating the target region according to the vertical boundary parameters and the horizontal boundary parameters.

[0145] As an optional implementation, the upper boundary index and the lower boundary index in the vertical direction are extracted from the vertical boundary parameters, and the starting row and the ending row of the target region in the vertical direction are determined. Then, the left boundary index and the right boundary index in the horizontal direction are extracted from the horizontal boundary parameters, and the starting column and the ending column of the target region in the horizontal direction are determined. According to the rule that the upper boundary index is the top row, the lower boundary index is the bottom row, the left boundary index is the left column, and the right boundary index is the right column, a rectangular range is framed in the largest connected region mask. The rectangular range is directly determined as the target region without additional adjustment, the integration of the vertical and horizontal boundary parameters is completed, and the target region is output. This method frames the region through the boundary parameters, does not require additional statistics or fine-tuning, has simple operation logic, fast integration speed, and no additional calculation cost.

[0146] Exemplarily, in the preprocessing scene of the tennis court image, a tennis court maximum connected region mask (white for court core pixels, black for background) of 1920x1080 size is taken, the number of white pixels in each row is counted horizontally by row, and the effective rows (white pixel number≤50) are screened according to the preset threshold 50, three effective row continuous segments (segment 1: index 80-110, length 31 rows; segment 2: index 120-980, length 861 rows; segment 3: index 990-1020, length 31 rows) are separated, and the row continuous segment information is recorded. The longest row continuous segment (segment 2) is screened from the row continuous segment information, the upper boundary 120 and the lower boundary 980 in the vertical direction are determined according to the index, and the vertical boundary parameters (120, 980) are output. The number of white pixels in each column is counted vertically by column, and the effective columns (white pixel number≤30) are screened according to the preset threshold 30, four effective column continuous segments (segment 1: 200-240, 41 columns; segment 2: 250-1680, 1431 columns; segment 3: 1690-1730, 41 columns; segment 4: 1740-1780, 41 columns) are separated, and the column continuous segment information is recorded. The longest column continuous segment (segment 2) is screened, the left boundary 250 and the right boundary 1680 in the horizontal direction are determined according to the index, and the horizontal boundary parameters (250, 1680) are output. According to the vertical and horizontal boundary parameters, the region of interest (row 120-980, column 250-1680) is integrated and generated.

[0147] Since the boundaries are located by screening the longest continuous segment in segments, the problems of invalid row / column interference and large boundary positioning deviation in the maximum connected region mask are solved, and the efficiency and accuracy of the mark line recognition are improved.

[0148] Based on any of the above embodiments, in the seventh embodiment of the application, refer to Figure 4 , Figure 4 The seventh embodiment is a flowchart of the control method for reducing the detection range of the tennis court. The step E15 includes steps F11-F13:

[0149] Step F11, verify the effectiveness of the boundary index corresponding to the vertical boundary parameter and the horizontal boundary parameter, extract and confirm the boundary index value that passes the verification, and obtain the effective boundary value.

[0150] In this embodiment, the effectiveness of the boundary index refers to whether the boundary index is within the total number of rows / total number of columns of the maximum connected region mask and the corresponding position contains effective target pixels. The effective boundary value refers to the final parameter set that can accurately define the range of the target region by integrating all the boundary indexes that pass the verification.

[0151] As an optional implementation, the total number of rows and the total number of columns of the maximum connected region mask are obtained, and the upper and lower boundary indexes of the vertical boundary parameter and the left and right boundary indexes of the horizontal boundary parameter are extracted. The first step performs range verification: check whether the upper boundary index is greater than or equal to zero and less than or equal to the lower boundary index, whether the lower boundary index is less than or equal to the total number of rows minus one, whether the left boundary index is greater than or equal to 0 and less than or equal to the right boundary index, and whether the right boundary index is less than or equal to the total number of columns minus one. If an index is out of range, adjust it to the nearest reasonable value. The second step performs pixel validity verification: count the number of valid rows within the vertical boundary, calculate the valid row ratio, and at the same time count the valid column ratio within the horizontal boundary. If both ratios are greater than or equal to a preset ratio threshold, the corresponding boundary index is confirmed to be valid. Integrate all the verified upper, lower, left and right boundary indexes to obtain the effective boundary value. This method only relies on the current maximum connected region mask data, does not require external historical library, is suitable for all scenarios, and the range and ratio verification logic is simple, with fast real-time processing speed.

[0152] Step F12, parse the vertical coordinates and horizontal coordinates in the effective boundary value, determine the rectangular vertex coordinates, and generate coordinate pairs.

[0153] In this embodiment, the vertical coordinate refers to the row position index corresponding to the upper and lower boundaries of the target region parsed from the effective boundary value. The horizontal coordinate refers to the column position index corresponding to the left and right boundaries of the target region parsed from the effective boundary value. The rectangular vertex coordinate refers to the position information of the four corner points of the target rectangular region formed by combining the vertical coordinate and the horizontal coordinate. The coordinate pair refers to the paired record formed by combining the vertical coordinate and the horizontal coordinate of each rectangular vertex in a fixed order.

[0154] As an optional implementation, the vertical coordinate group and the horizontal coordinate group are separated from the effective boundary value, and the vertical coordinate group is determined to correspond to the upper and lower edge positions of the rectangular region, and the horizontal coordinate group is determined to correspond to the left and right edge positions. According to the rule that the four vertices of the rectangle are left upper, right upper, left lower and right lower, the upper vertical coordinate and the left horizontal coordinate are combined to obtain the left upper vertex coordinate. The upper vertical coordinate and the right horizontal coordinate are combined to obtain the right upper vertex coordinate. The lower vertical coordinate and the left horizontal coordinate are combined to obtain the left lower vertex coordinate. The lower vertical coordinate and the right horizontal coordinate are combined to obtain the right lower vertex coordinate. According to the fixed order of left upper, right upper, left lower and right lower, each vertex coordinate is arranged in the format of vertical coordinate and horizontal coordinate to form four independent coordinate pairs, and all coordinate pairs are integrated to obtain the final result. This method directly parses and combines coordinates according to a fixed rule without additional verification or format adjustment, has fewer processing steps, simple logic, and fast overall speed.

[0155] Step F13, according to the coordinate pair, frame a closed rectangular region in the original image to obtain the region of interest.

[0156] In the embodiment, the closed rectangular region refers to a rectangular graphic range formed in the original image by connecting four vertex coordinates without gaps and continuous edges.

[0157] As an optional implementation, the position information of the four vertices of the rectangle is extracted from the coordinate pair, and the pixel position corresponding to each vertex is located in the original image respectively. Taking the upper left vertex as the starting point, the upper right vertex is connected to the right along the horizontal direction to form the upper edge of the rectangle. The lower right vertex is connected to the lower left vertex from the upper right vertex along the vertical direction to form the right edge of the rectangle. The lower left vertex is connected to the upper left vertex from the lower right vertex along the horizontal direction to form the lower edge of the rectangle. The upper left vertex is connected to the lower left vertex from the lower right vertex along the vertical direction to form the left edge of the rectangle. After connecting the four edges, a closed rectangular region without gaps is formed in the original image, which is directly determined as the region of interest without additional adjustment or marking. This method directly selects the frame by connecting the vertices without coordinate adjustment or visual marking, and has fewer operation links, simple logic, can quickly locate the region in the original image, and has high processing speed.

[0158] Exemplarily, in the preprocessing scene of the tennis court image, the vertical boundary parameters (150, 950) and the horizontal boundary parameters (220, 1700) corresponding to the 1920*1080 tennis court original image are taken, and the boundary index validity is verified: first, the upper boundary 150 is greater than or equal to 0, the lower boundary 950 is less than or equal to 1079 (total number of rows-1), the left boundary 220 is greater than or equal to 0, and the right boundary 1700 is less than or equal to 1919 (total number of columns-1), and the range verification is passed. Then, the effective row proportion in the vertical boundary is 92% (≥ preset 85%), and the effective column proportion in the horizontal boundary is 90% (≥ preset 85%), and the pixel validity verification is passed. The boundary index value is extracted and confirmed, and the effective boundary value (vertical: 150, 950; horizontal: 220, 1700) is obtained. Analyzing the effective boundary value, the vertical coordinates are 150 (upper) and 950 (lower), and the horizontal coordinates are 220 (left) and 1700 (right), the rectangular vertex coordinates are determined as upper left (150, 220), upper right (150, 1700), lower left (950, 220), and lower right (950, 1700), and the coordinate pair is generated. According to the coordinate pair, the upper right, lower right, and lower left vertices are sequentially connected from the upper left vertex in the 1920*1080 original image to form a closed rectangular region, and the region of interest is obtained.

[0159] Due to the double verification of the boundary index range and the pixel validity, and the coordinate analysis and verification, the deviation of the region of interest caused by the boundary index out-of-bounds and the coordinate confusion is solved, and the marking accuracy and analysis efficiency are improved.

[0160] Based on any of the above embodiments, in the eighth embodiment of the present application, refer to Figure 5 , Figure 5The flowchart of the eighth embodiment of the control method for reducing the detection range of a tennis court is shown in the figure. After step S50, steps G11-G13 are further included.

[0161] In step G11, it is checked whether the area of the region of interest meets the preset requirement and whether the boundary is completely within the range of the original image. Unqualified invalid regions are excluded to obtain valid regions of interest.

[0162] In this embodiment, the preset requirement refers to a standard set in advance for determining whether the area of the region of interest is reasonable. The range of the original image refers to the coordinate boundary formed by the total number of rows (upper limit in the vertical direction) and the total number of columns of the original image. The unqualified invalid region refers to a region of interest whose area does not meet the preset requirement or whose boundary exceeds the range of the original image.

[0163] As an optional implementation, the rectangular vertex coordinate pair of the region of interest is obtained, the area of the region is calculated by the area formula, and the area is compared with the preset requirement. If the area is less than the threshold, it is directly determined as an unqualified invalid region. If the area meets the requirement, the upper and lower boundary vertical coordinates of the region are extracted and compared with the total number of rows of the original image, and the left and right boundary horizontal coordinates are extracted and compared with the total number of columns of the original image. If all the boundaries are within the range of the original image, the region is confirmed as a valid region of interest. If any boundary exceeds the range, it is still determined as an invalid region, and finally only the valid region of interest that meets the condition is retained. This method is suitable for scenarios where the area of the region of interest is stable and the boundary of the original image has no special processing requirements, and can quickly filter out the basic qualified regions.

[0164] In step G12, the boundaries of the valid region of interest are projected onto the position of the original image, and the boundary information corresponding to the valid region of interest is converted into a format that can be recognized by the subsequent detection step, and the adapted region of interest parameters are output.

[0165] In this embodiment, the projection onto the position of the original image refers to the operation of aligning the boundary coordinates of the valid region of interest with the pixel coordinate system of the original image to determine the specific pixel position of the boundary in the original image. The boundary information refers to the key data recording the upper, lower, left, and right boundary coordinates of the valid region of interest and the area of the region. The adapted region of interest parameters refer to the set of region parameters that have completed boundary projection alignment and conversion into the format for subsequent detection, which can be directly called by the subsequent steps.

[0166] As an optional implementation, the upper, lower, left and right boundary coordinates of the effective region of interest are extracted, and the coordinates are aligned with the pixel coordinate system of the original image to complete the projection of the boundary on the original image position. Then the fixed data format preset in the subsequent detection step is determined. The area of the effective region of interest is calculated, and the upper, lower, left and right boundary coordinates and the area are filled in the array in a fixed order. It is checked whether the values of each parameter in the array meet the original image coordinate range. If it is correct, the array is directly output as the adapted region of interest parameter. If there is a value anomaly, the boundary coordinates are recalibrated and filled into the array again until the parameter is qualified. This method uses fixed format conversion, does not need to read external configuration files, has simple steps, fast projection and conversion speed, and is suitable for scenes where the format of the subsequent detection step is uniform.

[0167] Step G13, according to the adapted region of interest parameter, marking the range and parameter of the region of interest on the original image to obtain a labeled original image for subsequent detection.

[0168] In this embodiment, the labeled original image refers to an original image on which the range of the region of interest is drawn and the parameter text is added, which can be directly used for subsequent detection.

[0169] As an optional implementation, the upper, lower, left and right boundary coordinates and the area of the region of interest are extracted from the adapted region of interest parameter, and the pixel coordinate system of the original image is determined. In the original image, a rectangle is drawn by a line with a preset color and a fixed thickness according to the boundary coordinates: starting from the intersection of the left boundary and the upper boundary, drawing to the right along the upper boundary to the intersection of the right boundary and the upper boundary, then drawing downward along the right boundary to the intersection of the right boundary and the lower boundary, then drawing leftward along the lower boundary to the intersection of the left boundary and the lower boundary, and finally drawing upward along the left boundary back to the starting point to form a closed range line. Outside the upper left corner of the rectangle range, parameter text is added in a preset font size and color. It is checked whether the line is continuous and closed, and whether the text is clear and unobstructed. After confirming that there is no error, the image is saved to obtain a labeled original image. This method only draws basic range lines and core parameters, has few operation steps, no additional layer processing, fast labeling speed, and the text and lines do not occupy too much space of the original image, and there is almost no risk of obstruction.

[0170] As another optional labeling implementation, in the labeling layer, the range of the region of interest is drawn with double-layer lines, the inner layer is marked with a thin line and a high-contrast color to mark the actual boundary, and the outer layer is surrounded by a thick line and a light color around the inner layer line to enhance visual recognition. Inside the rectangular region, add a low-transparency fill color of the same color. In the blank area at the lower right corner of the original image, create a parameter panel with a light color background, and arrange the text inside according to the parameter type, value, and description format. The text color is set to dark. Check if the lines in the labeling layer are aligned with the original image coordinates, the fill is uniform, and the panel does not block the target subject. After confirmation, the labeling layer and the original image are combined and saved to obtain the labeled original image. This method enhances the recognition of the region by double-layer lines and fill, the parameter panel contains complete information and instructions, and there is no need to check the document additionally. Moreover, the labeling layer is separated from the original image, which is highly flexible.

[0171] As an optional feedback mechanism implementation, the initial boundary and gray mean value of the region of interest corresponding to the original image are obtained first, and the pixel validity ratio threshold is preliminarily dynamically adjusted based on the gray mean value. Then, the vertical and horizontal boundaries are both divided into multiple segments, and the effective pixel ratio of each segment is counted. Threshold feedback verification is introduced synchronously: if the ratio of a certain segment is lower than the preliminary threshold but close to the threshold, extract the color features of all pixels in the segment, compare them with the preset target region color range, and if the color matching degree is greater than or equal to the preset matching degree threshold, the segment is determined to be effective, and the preliminary threshold is adjusted reversely until the ratio of the segment that meets the condition is greater than or equal to the ratio threshold. After completing the threshold feedback adjustment, it is verified whether the area of the region is within the preset range and the boundary is within the original image. If it is confirmed to be qualified, the effective region of interest is obtained. Project the boundary onto the original image, convert it into the subsequent detection format, and label the feedback-adjusted threshold and color matching result. Output the labeled original image.

[0172] For example, refer to Figure 6 , Figure 6The region of interest is identified for the application. In the preprocessing scene of the tennis court image, the region of interest corresponding to the original 1920x1080 tennis court image is taken, and the preset area requirement is 600000-1500000 pixels, the boundary needs to be in 0≤up<down≤1079 (total row number-1), 0≤left<right≤1919 (total column number-1). Check the area of the region, which is 950000 pixels (consistent with the preset), and the boundaries (200, 900, 300, 1600) are within the range of the original image. After excluding invalid regions, the valid region of interest is obtained. Project the boundary of the valid region of interest to the corresponding position of the original image, and convert the boundary information (up 200, down 900, left 300, right 1600, area 950000) to the array format [200, 900, 300, 1600, 950000] recognized by the subsequent edge detection step. Output the adapted region of interest parameters. According to the adaptation parameters, frame the range with red lines on the original image, and label "up: 200 down: 900 left: 300 right: 1600 area: 950000" in the upper right corner of the region. Get the labeled original image for subsequent detection.

[0173] Further, based on the projection statistics and dynamic threshold region precise positioning method, on the preprocessed binary mask, horizontal projection and vertical projection are used to locate the boundary of this specific means. Set "a dynamic threshold (such as a certain percentage of the total number of rows / columns pixels, for example 10%) to determine the effective row and effective column" as the key rule. This method can effectively ensure that the located region is large and continuous, and excludes the interference of small noise, which is the key to improve robustness. The decoupling design of the preprocessing module and the subsequent detection module and its application mode in video stream, the preprocessing method is taken as an independent module, and its output (ROI region) provides services for the subsequent fine detection algorithm (whether it is a classic algorithm or a neural network) This system architecture idea. In the two adaptive working modes in video stream processing: static mode (single calculation + continuous application), for fixed perspective, only in the first frame or key frame complete preprocessing is performed, and the result is reused in subsequent large number of frames. Dynamic mode (preprocessing + visual tracking cooperation): for moving perspective, use the preprocessing result to initialize the tracker, and only when tracking fails will the preprocessing be triggered again.

[0174] Due to the area and boundary check, parameter format conversion, and visual annotation, the problems of invalid region of interest, incompatible parameters for subsequent steps, and ambiguous annotation are solved, and the stability and efficiency of the detection process are improved.

[0175] The application provides a tennis court detection device, which comprises at least one processor and a memory connected with the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the control method for reducing the detection range of the tennis court in the first embodiment.

[0176] Reference will now be made to the following description Figure 7 which shows a structural diagram of a tennis court detection device suitable for implementing the embodiments of the application. The tennis court detection device in the embodiments of the application can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, an image preprocessing device, a personal digital assistant (PDA), a tablet computer (PAD), a portable multimedia player (PMP), an image acquisition device, and the like, and a fixed terminal such as a high-speed camera, a desktop computer, and the like. Figure 7 The tennis court detection device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the application.

[0177] As Figure 7As shown, the tennis court detection device can include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. Various programs and data required for the operation of the tennis court detection device are also stored in the random access memory 1004. The processing device 1001, the read-only memory 1002, and the random access memory 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; the storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the tennis court detection device to communicate wirelessly or wired with other devices to exchange data. Although the tennis court detection device with various systems is shown in the figure, it should be understood that all the shown systems are not required to be implemented or possessed. More or less systems can be alternatively implemented or possessed.

[0178] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication device, or installed from the storage device 1003, or installed from the read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of the embodiments disclosed in the present application are performed.

[0179] The tennis court detection device provided by the present application adopts the control method for reducing the detection range of the tennis court in the above-mentioned embodiments, and can solve the technical problem of poor detection effect of the tennis court. Compared with the prior art, the tennis court detection device provided by the present application has the same beneficial effects as the control method for reducing the detection range of the tennis court provided by the above-mentioned embodiments, and other technical features in the tennis court detection device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.

[0180] It should be understood that various aspects of the disclosure can be implemented in hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any appropriate manner in any one or more embodiments or examples.

[0181] The above description is merely illustrative of the application and is not intended to limit the scope of the application. Any variations and modifications that can be made by any person skilled in the art within the spirit and scope of the application are intended to be encompassed by the application. Therefore, the scope of the application should be determined by the appended claims.

[0182] The application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e., a computer program) for performing the control method for reducing the detection range of a tennis court in the above-described embodiments.

[0183] The computer readable storage medium provided by the application may, for example, be a U disk, but is not limited to an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electric connection having one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present embodiment, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer readable storage medium can be transmitted by any appropriate medium, including but not limited to an electric wire, an optical cable, a radio frequency (RF), and the like, or any appropriate combination thereof.

[0184] The above-described computer readable storage medium can be included in a tennis court detection device; or can exist separately without being assembled into a tennis court detection device.

[0185] The computer readable storage medium described above carries one or more programs, when the one or more programs are executed by the tennis court detection device, the tennis court detection device: the original image of the tennis court is subjected to dimension reduction processing and reshaping processing to obtain image data in the form of a two-dimensional array; cluster the pixel colors in the image data, identify and filter out the main color corresponding to the tennis court; after generating a binary mask according to the main color, regularize the binary mask according to a preset combination operation to obtain a target binary mask; connected domain analysis of the target binary mask, filtering out the largest connected region in the target binary mask, generating a largest connected region mask; multi-directional projection processing of the largest connected region mask, determining the region of interest corresponding to the tennis court.

[0186] The flowcharts and block diagrams in the drawings illustrate the possible implementation architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, program segment, or a portion of code that contains one or more executable instructions for implementing the specified logical function.

[0187] The modules involved in the embodiments described in the present application can be implemented in software or hardware. Among them, the name of the module does not constitute a limitation of the unit itself in some cases.

[0188] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer program) for executing the above-mentioned control method for reducing the detection range of the tennis court. It can solve the technical problem of poor detection effect of the tennis court. Compared with the prior art, the computer readable storage medium provided by the present application has the same beneficial effects as the control method for reducing the detection range of the tennis court provided by the above-mentioned embodiments, which will not be repeated here.

[0189] The above only describes some embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structural transformation made by using the contents of the present application specification and drawings, or direct / indirect application in other related technical fields is included in the patent protection scope of the present application.

Claims

1. A control method for reducing the detection range of a tennis court, characterized by, The method comprises: dividing the original image into a plurality of rectangular pixel blocks of the same size according to a preset ratio, wherein each rectangular pixel block contains a certain number of pixels in the horizontal and vertical directions of the original image; extracting color information of all pixels in each rectangular pixel block, and calculating the comprehensive average value of the color information; taking the color average value corresponding to each rectangular pixel block as the color information of a new pixel, and each rectangular pixel block corresponds to a new pixel in the reduced image; arranging the new pixels in sequence according to the arrangement order of the rectangular pixel blocks in the original image to form a reduced tennis court image; performing denoising processing on the reduced tennis court image, replacing the center pixel with the median value of the local pixel region to generate a processed original image; remodeling the processed original image into a two-dimensional array according to the row and column order, and outputting image data meeting the format requirements; clustering the pixel colors in the image data, identifying and filtering out the main color corresponding to the tennis court; generating a binary mask according to the main color, and normalizing the binary mask according to a preset combination operation to obtain a target binary mask; initializing a region information set to record the pixel range and pixel number of each connected region, and traversing the target binary mask pixel by pixel by row; when a target color pixel is encountered, checking whether the pixels above and to the left of the target color pixel belong to a recorded connected region, if only the top and left sides have recorded regions, the current pixel is attributed to the recorded region, and the pixel number and range of the recorded region are updated; after traversing all pixels, filtering out the region with the largest pixel number from the region information set, and extracting the pixel range of the region with the largest pixel number; traversing the target binary mask according to the pixel range of the region with the largest pixel number, keeping the pixels within the range as target colors, and setting all pixels outside the range as non-target colors to generate a maximum connected region mask; multi-directional projection processing the maximum connected region mask to determine the region of interest corresponding to the tennis court.

2. The control method of claim 1, wherein The step of clustering the pixel colors in the image data, identifying and filtering out the main color corresponding to the tennis court comprises: clustering the pixel colors in the image data according to a clustering algorithm, and outputting a clustering result containing a preset number of pixel color clusters; counting the number of pixels contained in each pixel color cluster, and sorting each pixel color cluster according to the size of the pixel number to obtain a color cluster list; filtering out the target pixel color cluster with the largest pixel number in the color cluster list, and determining the color parameter corresponding to the target pixel color cluster as the main color corresponding to the tennis court.

3. The control method of claim 1, wherein the control method is characterized by: The step of generating a binary mask according to the main color, and normalizing the binary mask according to a preset combination operation to obtain a target binary mask comprises: traversing all pixels in the image data, and distinguishing whether the color corresponding to each pixel belongs to the main color to generate an initial binary mask; The white noise in the initial binary mask is removed by morphological opening operation, and the boundary shape of the main area of the initial binary mask is restored, to output a standard binary mask; Small holes inside the standard binary mask are filled by morphological closing operation, and adjacent fragmented areas are connected, to output a standard binary mask after regularization processing; The standard binary mask after regularization processing is enlarged to the same size as the original image, to obtain the target binary mask with the original size.

4. The control method of claim 1, wherein the control method is characterized by: After the step of generating a binary mask according to the main color, the control method for reducing the detection range of a tennis court further includes: All white pixel regions in the target binary mask that are connected to each other are identified and marked, to obtain a region mask containing marking information of each connected region; Each connected region with an identifier in the region mask is traversed, and the number of white pixels contained in each connected region is counted, to generate an area statistics list recording an identifier of each connected region and an area corresponding to the identifier; The target connected region with the largest area value is selected from the area statistics list, white pixels in the target connected region in the target binary mask are reserved, and pixels in other regions are all marked as black, to generate a mask of the largest connected region.

5. The control method of claim 1, wherein the control method is characterized by: The step of processing the mask of the largest connected region by multi-direction projection and determining a region of interest corresponding to the tennis court includes: The number of white pixels in the mask of the largest connected region is counted row by row horizontally, effective rows are selected according to a preset threshold, continuous segments of the effective rows are separated and indexes are recorded, to obtain row continuous segment information; The longest row continuous segment is selected from the row continuous segment information, a vertical upper and lower boundary is determined according to an index corresponding to the longest row continuous segment, and a vertical boundary parameter is output; The number of white pixels in the mask of the largest connected region is counted column by column vertically, effective columns are selected according to a preset threshold, continuous segments of the effective columns are separated and indexes are recorded, to obtain column continuous segment information; The longest column continuous segment is selected from the column continuous segment information, a horizontal left and right boundary is determined according to an index corresponding to the longest column continuous segment, and a horizontal boundary parameter is output; The region of interest is generated by integrating the vertical boundary parameter and the horizontal boundary parameter.

6. The control method of claim 5, wherein the control method further comprises: determining whether the detected range of the tennis court is a reduced range; and if the detected range of the tennis court is the reduced range, controlling the display device to display the reduced range of the tennis court. The step of generating the region of interest by integrating the vertical boundary parameter and the horizontal boundary parameter includes: The effectiveness of boundary indexes corresponding to the vertical boundary parameter and the horizontal boundary parameter is verified, verified boundary index values are extracted and confirmed, and effective boundary values are obtained; Vertical coordinates and horizontal coordinates in the effective boundary values are analyzed, to determine rectangular vertex coordinates and generate coordinate pairs; A closed rectangular region is framed in the original image according to the coordinate pairs, to obtain the region of interest.

7. The control method of claim 1, wherein the control method further comprises: determining whether the detected range of the tennis court is a reduced range; and if the detected range of the tennis court is the reduced range, displaying a reduced range of the tennis court on the display unit. After the step of processing the mask of the largest connected region by multi-direction projection and determining the region of interest corresponding to the tennis court, the control method further includes: It is checked whether an area of the region of interest meets a preset requirement and whether a boundary is completely within a range of the original image, to exclude an invalid region that does not meet the requirement, and obtain a valid region of interest; Projecting the boundary of the effective region of interest to the position of the original image, and converting the boundary information of the effective region of interest into a format recognizable by the subsequent detection step, outputting the adapted region of interest parameter; According to the adapted region of interest parameter, marking the range and parameter of the region of interest on the original image, obtaining the labeled original image for subsequent detection.

8. A tennis court detection apparatus characterized by comprising: The tennis court detection device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the control method for reducing the detection range of the tennis court as claimed in any one of claims 1 to 7.

9. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the control method for reducing the detection range of the tennis court as claimed in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Miss-planting rate detection method of rice transplanter

    CN111932551A

  • Light self-adaptive green site extraction method

    CN112233050A