Picture detection method and device, computer device and storage medium
By detecting the test color of color bars in video frames, generating a color-filtered image and merging regions, and determining the main region based on the size of the region outline, the problem of insufficient adaptability in traditional methods is solved, realizing color bar signal detection without template library and improving the effectiveness of detection.
Patent Information
- Application Number
- CN202211570876.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-12-08
Smart Images

Figure CN116095306B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image detection method, apparatus, computer equipment, and storage medium. Background Technology
[0002] Color bars are a type of test signal in video media, used in the production and broadcasting of television programs and equipment maintenance to verify the transmission quality of video channels. Color bars typically appear before or after video playback; to avoid their presence in video, it is necessary to detect them.
[0003] Traditional techniques rely on existing color bar signal template libraries to calculate the similarity between video frames and color bar images in the library. The presence of color bars in a video frame is detected by determining if the similarity reaches a certain threshold. However, this approach is limited by the template library. Summary of the Invention
[0004] Therefore, it is necessary to provide a screen detection method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve adaptability in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for detecting an image. The method includes:
[0006] A color-filtered image is obtained by detecting the test colors of the color bars in the video frame; the color-filtered image includes the image area corresponding to each of the test colors of the color bars.
[0007] Adjacent image regions in the color-filtered image are merged to obtain at least one merged region;
[0008] The main region is determined from the at least one merged region based on the size of the region outline of the at least one merged region;
[0009] Based on the image area corresponding to the color bar test color in the main area, color bar signal detection is performed on the video frame to obtain the color bar detection result.
[0010] Secondly, this application also provides an image detection device. The device includes:
[0011] The filtering module is used to obtain a color-filtered image by detecting the test colors of the color bars in the video frame; the color-filtered image includes the image area corresponding to each of the test colors of the color bars;
[0012] The region merging module is used to merge adjacent image regions in the color-filtered image to obtain at least one merged region.
[0013] A determining module is configured to determine a main region from the at least one merged region based on the size of the region outline of the at least one merged region;
[0014] The detection module is used to perform color bar signal detection on the video frame based on the image area corresponding to the color bar test color in the main area, and obtain the color bar detection result.
[0015] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the various embodiments of the method described in this application.
[0016] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the methods described in the embodiments of this application.
[0017] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the methods described in the various embodiments of this application.
[0018] The aforementioned image detection method, apparatus, computer equipment, storage medium, and computer program product obtain a color-filtered image by detecting the test colors of color bars in a video frame. The color-filtered image includes the image regions corresponding to each test color of the color bars. Adjacent image regions in the color-filtered image are merged to obtain at least one merged region. Based on the size of the region outline of the at least one merged region, a main region is determined from the at least one merged region. Based on the image region corresponding to the test color of the color bar in the main region, color bar signal detection is performed on the video frame to obtain a color bar detection result. By obtaining a color-filtered image from the test colors of the color bars in the video frame, merging adjacent image regions in the color-filtered image to obtain a merged region, determining the main region based on the region outline size of the merged region, and then performing color bar signal detection based on the image region corresponding to the test color of the color bar in the main region, color bar signal detection can be achieved without establishing a template library, thus improving adaptability. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating an image detection method in one embodiment;
[0020] Figure 2 This is a schematic diagram of a video frame, a color-filtered image, and a main area in one embodiment.
[0021] Figure 3This is a schematic diagram of a video frame, a color-filtered image, and a main area in another embodiment;
[0022] Figure 4 This is a structural block diagram of the image detection device in one embodiment;
[0023] Figure 5 This is an internal structural diagram of a computer device in one embodiment;
[0024] Figure 6 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0026] In some embodiments, such as Figure 1 As shown, a screen detection method is provided, with an example of its application to a computer device. It is understood that the computer device may include at least one of a terminal or a server. This method can be implemented independently by the server or the terminal, or through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0027] S102, obtains a color-filtered image by detecting the test colors of the color bars in the video frame.
[0028] The color-filtered image includes the image region corresponding to each color bar test color. The image region refers to the area within the video frame containing the color bar test color. In other words, the image region corresponding to a color bar test color includes the pixels within that region of the video frame. The color bar test color refers to the test color in the color bar signal.
[0029] It should be noted that color bar signals are needed to verify the transmission quality of the video channel during video production, broadcasting, and equipment maintenance. To avoid color bar images appearing during normal video playback, it is necessary to check whether each video frame displays a color bar image.
[0030] For example, a computer device can determine the color feature range set for a color bar test color. Based on the color feature range of each color bar test color and the color feature information of pixels in the video frame, it determines the image region corresponding to each color bar test color from the video frame, thus obtaining a color-filtered image. Each image region corresponds to one color bar test color, and when the video frame is a color bar signal image, one color bar test color corresponds to at least one image region. It is understood that detecting video frames using color feature ranges avoids color omissions compared to direct signal chromaticity matching, and is more robust to detecting distorted colors.
[0031] In some embodiments, multiple adjacent color bar test colors exist in the color bar signal. A computer device can use these multiple adjacent color bar test colors as the color bar test colors to be detected. It can be understood that the computer device can detect the image area corresponding to the color bar test color to be detected from the video frame to obtain a color-filtered image. For example, in multiple color bar signals, the six colors red, green, blue, yellow, magenta, and cyan are adjacent; the computer device can detect the image area corresponding to these six color bar test colors.
[0032] In some embodiments, the computer device may include a terminal. The terminal may be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices may include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, etc. Portable wearable devices may include smartwatches, smart bracelets, head-mounted devices, etc.
[0033] In some embodiments, the computer device may include a server. The server may be implemented using a standalone server or a server cluster consisting of multiple servers.
[0034] S104, merge adjacent image regions in the color-filtered image to obtain at least one merged region.
[0035] The merged area includes at least one image region. It is understood that the image content within the merged area can indicate at least one color bar test color.
[0036] For example, a computer device can determine the template kernel corresponding to the color-filtered image based on a preset template kernel size, and determine the binarized image of the color-filtered image. The computer device can then merge adjacent image regions in the color-filtered image based on the template kernel and the binarized image to obtain a region merging mask. It can be understood that the region merging mask is actually a mask used to locate at least one merged region. The computer device can extract the image of at least one merged region from the color-filtered image based on the region merging mask. It should be noted that adjacent image regions in the color-filtered image refer to image regions that are geographically adjacent.
[0037] S106, determine the main region from at least one merged region based on the size of the region outline of at least one merged region.
[0038] The main area indicates the image area included in the main body of the color bar signal. Compared to other parts, the main body of the color bar signal contains a more comprehensive range of color bar test colors. For example, the main body of the color bar signal can include color bar test colors other than white and black.
[0039] For example, a computer device can determine the size of the region outline of each merged region from a region merging mask. The computer device can determine a main region from at least one merged region based on the size of the region outline corresponding to each merged region.
[0040] S108, based on the image area corresponding to the color bar test color in the main area, perform color bar signal detection on the video frame image to obtain the color bar detection result.
[0041] Among them, the color bar detection result is used to indicate whether there is a color bar signal in the video frame.
[0042] For example, a computer device can perform color bar signal detection on a video frame based on the differences between the image areas corresponding to the test colors of each color bar in the main area, and obtain the color bar detection result.
[0043] In some embodiments, the computer device can determine the size difference between the areas of the screen corresponding to each color bar test color in the main area, and obtain the color bar detection result based on the size difference of the area.
[0044] In some embodiments, if the size difference in the main area does not meet the criteria for determining a color bar signal, the computer device can determine a color bar detection result indicating that a color bar signal does not exist in the video frame. The color bar signal determination criteria are used to indicate the size difference in the main area when a color bar signal is present in the video frame.
[0045] In the above-described image detection method, a color filter image is obtained by detecting the test colors of the color bars in the video frame. The color filter image includes the image regions corresponding to each test color of the color bars. Adjacent image regions in the color filter image are merged to obtain at least one merged region. Based on the size of the region outline of the at least one merged region, a main region is determined from the at least one merged region. Based on the image region corresponding to the test color of the color bar in the main region, color bar signal detection is performed on the video frame to obtain the color bar detection result. By obtaining the color filter image from the test colors of the color bars in the video frame, merging adjacent image regions in the color filter image to obtain the merged region, determining the main region based on the region outline size of the merged region, and then performing color bar signal detection based on the image region corresponding to the test color of the color bar in the main region, color bar signal detection can be achieved without establishing a template library, thus improving adaptability.
[0046] In some embodiments, obtaining a color-filtered image by detecting the test colors of color bars in a video frame includes: determining the color feature information of each pixel in the video frame; for each test color, filtering out pixels corresponding to the test color from the video frame based on the color feature information to obtain a region image corresponding to each test color; and merging the region images corresponding to each test color to obtain a color-filtered image.
[0047] Color feature information is used to indicate the color characteristics of a pixel. This includes information on hue, saturation, and brightness—three dimensions of color features. The image region refers to the area within a video frame where the color bar test color is located. Each color bar test color corresponds to at least one image region.
[0048] For example, the color model of a video frame is a three-primary-color model. A computer device can convert the pixel values in the video frame under the three-primary-color model into pixel values under the hexagonal pyramid model to obtain the color feature information of each pixel in the video frame. The color feature information may include hue information, saturation information, and brightness information.
[0049] The computer device can, for each color bar test color, compare its color feature information with the color feature range corresponding to that color bar test color, and filter out the pixels corresponding to that color bar test color from the video frame to obtain a region image corresponding to that color bar test color. Each region image corresponding to a color bar test color includes at least one image region corresponding to that color bar test color. This can be understood as the region image containing the pixels corresponding to that color bar test color, i.e., the pixels within the image region corresponding to that color bar test color. The computer device can obtain a color-filtered image by superimposing the region images corresponding to each color bar test color.
[0050] In some embodiments, a computer device can use a video frame in the three-primary-color model as input to a color model conversion function to obtain a video frame in the hexagonal pyramid model as output. For example, the computer device can use the formula "hsv = cvtColor(img, RGB2HSV)" to convert the pixel values in the video frame (img) in the three-primary-color model into pixel values in the hexagonal pyramid model.
[0051] The `cvtcolor()` function is a color model conversion function that can convert the three-primary-color model to a hexagonal pyramid model or other color models, and can also convert it to a grayscale image. RGB2HSV represents the conversion from the three-primary-color model to the hexagonal pyramid model. You can understand it this way: `img` represents a video frame in the three-primary-color model, and `hsv` represents a video frame in the hexagonal pyramid model.
[0052] In some embodiments, the computer device can perform a bitwise OR operation on the area image corresponding to each color test color to obtain a color-filtered image.
[0053] In some embodiments, the computer device can use the region images corresponding to each color bar test color as input to a bit OR function to obtain a color-filtered image output by the bit OR function.
[0054] In some embodiments, the computer device can filter the pixels corresponding to each color bar test color from a video frame to obtain a set of region images. The set of region images includes the region image corresponding to each color bar test color. The computer device can use the set of region images as input to a bitwise OR function to obtain a color-filtered image.
[0055] For example, a set of region images can be a list of region images. A computer device can perform a bitwise OR operation using the formula "img_filter = bitwise_or(img_list)" to obtain a color-filtered image. Here, `bitwise_or()` is used to perform a bitwise OR operation on pixels in multiple region images. `img_list` represents a list of region images, including the region images corresponding to each color bar test color. `img_filter` represents the color-filtered image.
[0056] In this embodiment, for each color bar test color, pixels corresponding to the color bar test color are filtered from the video frame based on color feature information to obtain the region image corresponding to each color bar test color. The region images corresponding to each color bar test color are merged to obtain a color-filtered image. Subsequently, the main region is determined based on the image region in the color-filtered image, and the color bar signal is detected in the video frame through the main region. This eliminates the need to build a template library or train a model based on a deep learning algorithm, making it more adaptable.
[0057] In some embodiments, for each color bar test color, filtering pixels corresponding to the color bar test color from the video frame based on color feature information to obtain a region image corresponding to each color bar test color includes: for each color bar test color, determining the color feature range corresponding to the color bar test color, and filtering pixels whose color feature information matches the color feature range from the video frame to obtain a region image corresponding to each color test color; the color feature range is used to indicate the value range of the color feature information under each color feature dimension.
[0058] For example, the computer device can set minimum and maximum thresholds for each color bar test color in terms of hue, saturation, and brightness, thus obtaining the color feature range corresponding to each color bar test color. It is understood that the color feature ranges corresponding to each color bar test color do not overlap. It should be noted that the color feature range is wider than the color feature information range of the color bar test color itself. Compared to filtering directly using the color feature information of the color bar test color itself, this method is more robust to detecting colors distorted by operations such as transmission, editing, and transcoding, and can minimize the problem of missed color detection.
[0059] Computer equipment can test the color of each color bar, retain the pixels in the video frame whose color feature information falls within the color feature range, and obtain the area image corresponding to the tested color of that color bar. It can be understood that color feature information falling within the color feature range means that hue information is not less than the minimum threshold and not greater than the maximum threshold in the hue dimension; saturation information is not less than the minimum threshold and not greater than the maximum threshold in the saturation dimension; and brightness information is not less than the minimum threshold and not greater than the maximum threshold in the brightness dimension.
[0060] In some embodiments, the computer device can, for each color bar test color, retain the region pixels in the video frame whose color feature information falls within the color feature range, and set all other pixels in the video frame except for the region pixels to zero, thus obtaining the region image corresponding to that color bar test color. It can be understood that the region image has the same size as the video frame, and the non-zero pixels in the region image are the region pixels. The computer device merges the region images corresponding to each color bar test color using a bitwise OR operation, and the resulting color-filtered image includes the region pixels from each region image.
[0061] In some embodiments, a computer device can use the formula "img_list=inRange(hsv,lower,upper)for i in enumerate([lower_list,upper_list])" to filter out pixels whose color feature information matches the color feature range from the video frame, and obtain the region image corresponding to each color test color.
[0062] Here, `img_list` is a list of region images. The `enumerate()` function is used to combine an iterable data object into an index sequence, listing both the data and its index; it's typically used within a `for` loop. `inRange(hsv,lower,upper)` indicates that if the color feature information of a pixel in a video frame under the hexagonal pyramid model is less than `lower` or greater than `upper`, the pixel value is set to zero. `lower_list` is a list of minimum thresholds, including the minimum threshold for each color feature dimension. `upper_list` is a list of maximum thresholds, including the maximum threshold for each color feature dimension.
[0063] In this embodiment, for each color bar test color, the color feature range corresponding to the color bar test color is determined, and pixels whose color feature information matches the color feature range are selected from the video frame to obtain the region image corresponding to each color test color. By filtering the video frame through the color feature range, the color bar test color can avoid the color omission problem caused by direct matching of color bar signal chromaticity, and the detection of distorted colors can be more robust.
[0064] In some embodiments, merging adjacent image regions in a color-filtered image to obtain at least one merged region includes: binarizing the color-filtered image to obtain a binarized image; performing a closing operation on the binarized image according to the template kernel corresponding to the color-filtered image to obtain a region merging mask; and generating an image including at least one merged region based on the region merging mask and the color-filtered image.
[0065] For example, a computer device can binarize a color-filtered image to obtain a binarized image. In this binarized image, the region containing each color bar's test color is the foreground, and the portion outside this region is the background. The computer device can use a template kernel corresponding to the color-filtered image to perform a dilation operation on the binarized image, obtaining a dilated binarized image. The computer device can then use the template kernel to perform an erosion operation on the dilated binarized image, obtaining a region merging mask. The computer device can extract each merging region indicated by the region merging mask from the color-filtered image, obtaining an image including at least one merging region. It is understood that gaps exist between adjacent image regions after color feature range filtering; performing a closing operation on the binarized image can eliminate these gaps, thereby achieving connectivity between adjacent image regions while maintaining the original region outline size.
[0066] In some embodiments, a computer device can generate a binary matrix based on a set template kernel size to obtain the template kernel corresponding to the color-filtered image.
[0067] In some embodiments, the computer device can use the template kernel size as input to the all-one matrix generating function to obtain the template kernel output by the all-one matrix generating function.
[0068] In some embodiments, a computer device can obtain a template kernel using the formula "kernel = ones(kernel_size)". Here, kernel represents the template kernel, kernel_size represents the size of the template kernel, and ones() is a function that generates a matrix of all ones. For example, if the template kernel size is 7x7, then the template kernel is a 7x7 matrix of all ones.
[0069] In some embodiments, a computer device can use a binarized image and a template kernel as input to a dilation function to obtain an output dilated binarized image. For example, the computer device can obtain the dilated binarized image using the formula "dilate(binary(img_filter),kernel)". Here, binary() is the binarization function, binary(img_filter) is the binarized image, kernel is the template kernel, img_filter is the color-filtered image, and dilate() is the dilation function.
[0070] In some embodiments, the computer device can use the dilated binarized image and the template kernel as input to the erosion function to obtain a region merging mask output by the erosion function. For example, the computer device can obtain the region merging mask using the formula "mask_merge = erode(mask_dilate, kernel)". Here, mask_merge represents the region merging mask, erode() is the erosion function, mask_dilate is the dilated binarized image, and kernel is the template kernel.
[0071] In some embodiments, a computer device can obtain an image including at least one merged region by performing a matrix-by-matrix multiplication operation on a region merging mask and a color-filtered image. For example, the computer device can obtain an image including at least one merged region using the formula "img_merge = mul(mask_merge, img_filter)". Here, img_merge represents the image including at least one merged region, mask_merge represents the region merging mask, img_filter is the color-filtered image, and mul() is the matrix-by-matrix multiplication function.
[0072] In this embodiment, the color-filtered image is binarized to obtain a binarized image; based on the template kernel corresponding to the color-filtered image, the binarized image is closed to obtain a region merging mask; based on the region merging mask and the color-filtered image, an image including at least one merged region is generated; subsequently, the main region is determined through the region merging mask to realize the color bar signal detection of the video frame based on the main region, which is more adaptable.
[0073] In some embodiments, determining a subject region from at least one merged region based on the size of the region contour of at least one merged region includes: performing contour detection on a region merging mask to obtain the region contour of each merged region; determining a subject region contour from the region contour of at least one merged region based on the area size of each region contour; filling the subject region contour to obtain a subject region mask; and extracting the subject region from an image including at least one merged region based on the subject region mask.
[0074] For example, a computer device can detect the outer contour in a region merging mask to obtain the region contour of each merged region. The computer device can determine the area size of each region contour and select the region contour with the largest area from at least one merged region to obtain the main region contour. The computer device can use the main region contour as input to a polygon fill function to obtain a main region mask output by the polygon fill function. The computer device can extract the main region indicated by the main region mask from an image including at least one merged region. The main region includes at least one image area.
[0075] In some embodiments, a computer device may extract the subject region from a color-filtered image based on a subject region mask.
[0076] In some embodiments, a computer device can use a region merging mask as input to a contour detection function to obtain a set of region contours output by the contour detection function. The set of region contours includes the region contours of each merged region. For example, the computer device can obtain the individual region contours using the formula "contours = findContours(mask_merge, EXTERNAL)". Here, contours represents the set of region contours including the individual region contours. findContours() is the contour detection function, mask_merge is the region merging mask, and EXTERNAL indicates the outer contour detection function of the contour detection function.
[0077] In some embodiments, the computer device can use the region contours of each merged region as input to an area function to obtain the area size of each region contour output by the area calculation function. For example, the computer device can determine the size of each region contour using the formula "areas = contourArea(contours)". Here, areas represents the area size of each region contour, contourArea() represents the area function, and contours represents the region contours of each merged region.
[0078] In some embodiments, the computer device can use the area size of each region contour as input to a function that maximizes the independent variable, to obtain the region contour indication information with the largest area output by the function. The region contour indication information is used to indicate the main region contour. The computer device can filter the main region contour indicated by the region contour indication information from at least one region contour. For example, the computer device can obtain the main region contour using the formula "ind_maxarea = argmax(areas)". Here, ind_maxarea represents the region contour indication information, argmax() is the function that maximizes the independent variable, and areas is the area size of each region contour.
[0079] In some embodiments, the region contour indication information may be the identifier of the main region contour in a set of region contours. The computer device can filter the main region contours from the set of region contours that match the region contour indication information. For example, the region contour indication information may be the identifier number of the main region contour in the set of region contours.
[0080] In some embodiments, a computer device can obtain a main region mask using the formula “mask_maxarea = fillPoly(contours[ind_maxarea])”. Here, mask_maxarea represents the main region mask, fillPoly() is the polygon filling function, contours[ind_maxarea] represents the main region outline, and ind_maxarea represents the region outline indication information.
[0081] In one embodiment, a computer device can perform a matrix-by-matrix multiplication operation on a subject region mask and an image including at least one merged region to obtain the subject region. For example, the computer device can obtain the subject region using the formula "img_maxarea = mul(mask_maxarea, img_merge)". Here, img_maxarea represents the subject region, mask_maxarea represents the subject region mask, img_merge represents the image including at least one merged region, and mul() is the matrix-by-matrix multiplication function.
[0082] In this embodiment, contour detection is performed on the region merging mask to obtain the region contour of each merged region; based on the area size of each region contour, the main region contour is determined from at least one merged region; the main region contour is filled to obtain the main region mask; the main region is extracted from the image including at least one merged region based on the main region mask; subsequently, color bar signal detection is performed on the video frame based on the image area in the main region, which is more adaptive.
[0083] In some embodiments, color bar signal detection is performed on the video frame based on the image area corresponding to the color bar test color in the main area to obtain the color bar detection result. This includes: sorting the image areas corresponding to each color bar test color in the main area according to the area size; and performing color bar signal detection on the video frame based on the difference between two adjacent sorted image areas in the main area to obtain the color bar detection result.
[0084] For example, the main area includes the screen area corresponding to each color bar test color. The computer device can obtain the screen area corresponding to each color bar test color in the main area by detecting the color bar test colors. The computer device can sort the screen areas corresponding to each color bar test color in the main area according to their size. The computer device can perform color bar signal detection on the video frame based on the difference between two adjacent sorted screen areas in the main area and the color bar signal determination conditions, thus obtaining the color bar detection result.
[0085] In some embodiments, the computer device can sort the screen areas corresponding to each color bar test color in the main area in ascending or descending order according to the area size.
[0086] In some embodiments, the computer device can convert pixel values in the main region under the three primary color model into pixel values under the hexagonal pyramid model to obtain color feature information of pixels in the main region. For each color bar test color, the computer device can filter out pixels in the main region whose color feature information falls within the color feature range corresponding to that color bar test color, to obtain a detection region image corresponding to each color bar test color.
[0087] In some embodiments, a computer device can use a main region as input to a color model conversion function to obtain the color feature information of the pixels output by the color model conversion function. For example, a computer device can obtain the color feature information of a pixel using the formula "hsv = cvtColor(img_maxarea, RGB2HSV)". Here, the cvtcolor() function is the color model conversion function. RGB2HSV represents the conversion from a three-primary-color model to a hexagonal pyramid model. It can be understood that img_maxarea can be the main region under the three-primary-color model. hsv is the main region under the hexagonal pyramid model, including the color feature information of the pixels within the main region.
[0088] In some embodiments, a computer device can obtain a list of detection region images corresponding to each color bar test color in the main region using the formula "img_list = inRange(hsv,l,u) for (l,u) in enumerate([lower_list,upper_list])". The list of detection region images includes the detection region images corresponding to each color bar test color in the main region. Here, img_list is the list of detection region images. The enumerate() function is used to combine an iterable data object into an index sequence. inRange(hsv,l,u) indicates that when the color feature information of a pixel in the main region under the hexagonal pyramid model is less than l or greater than u, the pixel value is set to zero. lower_list is a list of minimum thresholds, including the minimum threshold for each color feature dimension. upper_list is a list of maximum thresholds, including the maximum threshold for each color feature dimension.
[0089] In some embodiments, the computer device can use the detection area image corresponding to each color bar test area as input to the area acquisition function to obtain the area of the image region in the detection area image output by the area acquisition function.
[0090] In some embodiments, the computer device can use a list of detected regions as input to an area acquisition function to obtain a list of areas of the screen regions output by the area acquisition function. The area list includes the area of each screen region within the main subject area. For example, the computer device can obtain the area list using the formula "area_list = getArea(img_list)". Here, area_list represents the area list, and getArea() represents the area acquisition function.
[0091] In some embodiments, such as Figure 2 The diagram illustrates a video frame, a color-filtered image, and a main subject region. The color bar test signals to be detected include six colors: red, green, blue, yellow, magenta, and cyan. There are a total of nine image regions corresponding to each color bar test color in the video frame. The computer device obtains a color-filtered image comprising these nine image regions by detecting the color bar test colors in the video frame. After merging adjacent frames, the computer device obtains two merged regions. The upper merged region is larger than the lower merged region; therefore, the upper merged region is the main subject region. The computer device can then determine the main subject region.
[0092] In some embodiments, such as Figure 3 The diagram illustrates another video frame, a color-filtered image, and the main subject area. The color bar test signal to be detected includes six colors: red, green, blue, yellow, magenta, and cyan. There are a total of 10 image areas corresponding to each color bar test color in the video frame. The computer device obtains a color-filtered image comprising these 10 image areas by detecting the color bar test colors in the video frame. After merging adjacent frames, the computer device obtains three merged areas. The middle merged area is larger than the left and right merged areas; therefore, the middle merged area is the main subject area. The computer device can then determine the main subject area.
[0093] It should be noted that the video frame may include the area of the image corresponding to each color of the test bars, such as... Figure 3 The rectangular areas representing yellow, cyan, green, magenta, red, and blue in a mid-range video frame. The difference between a color-filtered image and a video frame is that in the color-filtered image, all pixel values except those corresponding to the test colors of each color bar are 0. That is, the color-filtered image is blank except for the rectangular areas corresponding to yellow, cyan, green, magenta, red, and blue.
[0094] It is understandable that the image region is different from the region image. In the region image corresponding to the color bar test color, everything except the image region corresponding to that color bar test color is blank. The region image has the same size as the video frame. The region image is equivalent to extracting the pixels in the region where the color bar test color is located from the video frame and setting other pixels to zero. The difference between the region image and the color filter image is that the difference image only includes the image region corresponding to one color bar test color, while the color filter image includes the image regions corresponding to multiple color bar test colors. In this embodiment, the image regions corresponding to each color bar test color in the main area are sorted according to their size. Based on the difference between two adjacent sorted image regions in the main area, color bar signal detection is performed on the video frame to obtain the color bar detection result. It is not limited by the established template library and can perform color bar signal detection on any video frame, improving adaptability.
[0095] In some embodiments, color bar signal detection is performed on the video frame based on the difference between two adjacent frame regions in the main body region, and the color bar detection result is obtained by: determining the area difference between two adjacent frame regions in the main body region; determining whether there is a color bar signal in the video frame by comparing the area difference with a preset difference, and obtaining the color bar detection result.
[0096] For example, a computer device can determine the area difference between two adjacent frame regions in the main area. If a preset number of area differences are all less than a preset difference, the computer device can determine the color bar detection result, representing the presence of a color bar signal in the video frame. It is understood that sorting by area size aims to place the frame regions with the closest areas next to each other, making it easier to determine whether they are symmetrical. A difference less than the preset difference indicates that the two frame regions are of the same size, which can remove the influence of noise, such as the loss of a small number of pixels in the frame region corresponding to the color of the color bar test. Furthermore, compared to directly comparing frame region sizes without sorting, this method is not limited to color bar shapes where all frame regions are of the same size, and can adapt to various axially symmetrical color bar shape designs.
[0097] In some embodiments, a computer device can use a list of areas as input to a sorting function to obtain a sorted set of areas as the output of the sorting function. For example, the computer device can obtain a sorted set of areas using the formula "area_sorted = sort(area_list)". Here, area_sorted is the sorted set of areas, sort() is the sorting function, and area_list is the list of areas.
[0098] In some embodiments, the computer device can determine the area differences between adjacent sorted picture areas through the formula "area_diffs = [area_sorted[i] - area_sorted[i - 1] for i in range(1, len(area_sorted))]". Here, area_sorted[i] represents the i-th sorted area in the area set, and area_sorted[i - 1] represents the (i - 1)-th sorted area in the area set. area_diffs represents the area differences between two adjacent sorted picture areas. for i in range(1, len(area_sorted)) represents that the range of i is from 1 to the number of areas in the area set.
[0099] In some embodiments, the computer device can screen out a set of judgment results with area differences less than a preset difference from multiple area differences. The set of judgment results includes the results of comparing each area difference with the preset difference. When the area difference is less than the preset difference, the judgment result is 1, otherwise it is 0. For example, the computer device can obtain the set of judgment results through the formula "isselect_list = [diff < thr for diff in area_diffs]". Here, isselect_list represents the set of judgment results, and diff represents the area difference. for diff in area_diffs represents that the area differences are taken from the area set.
[0100] In some embodiments, the computer device can use the set of judgment results as the input of a quantity determination function to obtain the determined quantity output by the quantity determination function. When the determined quantity is not less than a preset quantity, the computer device can determine a color bar detection result indicating the presence of a color bar signal in the video frame picture. For example, the computer device can obtain the color bar detection result through the formula "iscolorstrip = numTrue(isselect_list) >= numThr". Here, iscolorstrip represents the color bar test result, iscolorstrip is 1 when there is a color bar signal, and iscolorstrip is 0 when there is no color bar signal. numTrue() is the quantity determination function. isselect_list represents the set of judgment results. numThr represents the preset quantity.
[0101] In some embodiments, the computer device can perform a matrix对位 multiplication operation on the main area mask and the area image corresponding to each color bar test color to obtain the detection area image corresponding to each color bar test color.
[0102] It should be noted that there is a misspelling in the original text where "对位" should probably be "对位相乘" or a more appropriate term. I translated it as "对位 multiplication operation" based on the context. If this is not what you intended, please correct the original text for a more accurate translation.In this embodiment, the area difference between two adjacent sorted image areas in the main area is determined; by comparing the area difference with a preset difference, it is determined whether there is a color bar signal in the video frame, and the color bar detection result is obtained. This method can adapt to the detection of various color bar shapes, thus improving adaptability.
[0103] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0104] Based on the same inventive concept, this application also provides a screen detection apparatus for implementing the screen detection method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more screen detection apparatus embodiments provided below can be found in the limitations of the screen detection method described above, and will not be repeated here.
[0105] In some embodiments, such as Figure 4 As shown, an image detection device 400 is provided, including: a filtering module 402, a region merging module 404, a determination module 406, and a detection module 408, wherein:
[0106] The filtering module 402 is used to obtain a color-filtered image by detecting the test colors of the color bars in the video frame; the color-filtered image includes the screen area corresponding to each test color of the color bars.
[0107] The region merging module 404 is used to merge adjacent image regions in the color-filtered image to obtain at least one merged region.
[0108] The determination module 406 is used to determine the main region from at least one merged region based on the size of the region outline of at least one merged region.
[0109] The detection module 408 is used to detect color bar signals in the video frame based on the image area corresponding to the color bar test color in the main area, and obtain the color bar detection result.
[0110] In some embodiments, the filtering module 402 is used to determine the color feature information of each pixel in the video frame; for each color bar test color, the pixels corresponding to the color bar test color are filtered out from the video frame according to the color feature information to obtain the region image corresponding to each color bar test color; the region image corresponding to the color bar test color includes the screen area corresponding to the color bar test color; the region images corresponding to each color bar test color are merged to obtain a color filtered image.
[0111] In some embodiments, the filtering module 402 is used to determine the color feature range corresponding to each color bar test color, and to filter out pixels whose color feature information matches the color feature range from the video frame to obtain the region image corresponding to each color test color; the color feature range is used to indicate the value range of color feature information under each color feature dimension.
[0112] In some embodiments, the region merging module 404 is used to perform binarization processing on the color-filtered image to obtain a binarized image; perform a closing operation on the binarized image according to the template kernel corresponding to the color-filtered image to obtain a region merging mask; and generate an image including at least one merged region according to the region merging mask and the color-filtered image.
[0113] In some embodiments, the determining module 406 is configured to perform contour detection on the region merging mask to obtain the region contour of each merged region; determine the main region contour from at least one merged region based on the area size of each region contour; fill the main region contour to obtain a main region mask; and extract the main region from the image including at least one merged region based on the main region mask.
[0114] In some embodiments, the detection module 408 is used to sort the image areas corresponding to each color bar test color in the main area according to the area size; based on the difference between two adjacent sorted image areas in the main area, the video frame image is subjected to color bar signal detection to obtain the color bar detection result.
[0115] In some embodiments, the detection module 408 is used to determine the area difference between two adjacent sorted image areas in the main area; by comparing the area difference with a preset difference, it is determined whether there is a color bar signal in the video frame, and a color bar detection result is obtained.
[0116] Each module in the aforementioned image detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0117] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores video frames. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network. When executed by the processor, the computer program implements a screen detection method.
[0118] In some embodiments, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a screen detection method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0119] Those skilled in the art will understand that Figure 5 or Figure 6The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0120] In some embodiments, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0121] In some embodiments, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0122] In some embodiments, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0123] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0124] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0125] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0126] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for detecting images, characterized in that, The method includes: A color-filtered image is obtained by detecting the test colors of the color bars in the video frame; the color-filtered image includes the image area corresponding to each of the test colors of the color bars. Adjacent image regions in the color-filtered image are merged to obtain at least one merged region; The main region is determined from the at least one merged region based on the size of the region outline of the at least one merged region; The image areas corresponding to each of the color bar test colors in the main area are sorted according to their size; Determine the area difference between two adjacent sorted image regions within the main body region; The presence of color bar signals in the video frame is determined by comparing the area difference with a preset difference, thus obtaining the color bar detection result.
2. The method according to claim 1, characterized in that, The step of obtaining the color-filtered image by detecting the color bars in the video frame includes: Determine the color feature information of each pixel in the video frame; For each color bar test color, pixels corresponding to the color bar test color are filtered from the video frame based on the color feature information to obtain a region image corresponding to each color bar test color; the region image corresponding to the color bar test color includes the screen area corresponding to the color bar test color. The regions corresponding to each of the test colors of the color bars are merged to obtain a color-filtered image.
3. The method according to claim 2, characterized in that, The step of selecting pixels corresponding to each color bar test color from the video frame based on the color feature information to obtain the region image corresponding to each color bar test color includes: For each color bar test color, the color feature range corresponding to the color bar test color is determined, and pixels whose color feature information matches the color feature range are filtered from the video frame to obtain the region image corresponding to each color test color; the color feature range is used to indicate the value range of color feature information under each color feature dimension.
4. The method according to claim 1, characterized in that, The process of merging adjacent image regions in the color-filtered image to obtain at least one merged region includes: The color-filtered image is binarized to obtain a binarized image; Based on the template kernel corresponding to the color-filtered image, a closing operation is performed on the binarized image to obtain a region merging mask; Based on the region merging mask and the color-filtered image, an image including at least one merged region is generated.
5. The method according to claim 4, characterized in that, Determining the main region from the at least one merged region based on the size of the region outline of the at least one merged region includes: Perform contour detection on the region merging mask to obtain the region contour of each merged region; Based on the area size of each of the region contours, the main region contour is determined from the region contours of the at least one merged region; The main region contour is filled to obtain the main region mask; Extract the main region from the image including at least one merged region based on the main region mask.
6. The method according to claim 1, characterized in that, The method includes: Perform a bitwise OR operation on the regions corresponding to each color bar test color to obtain a color-filtered image; and / or The regions corresponding to the test colors of each color bar are used as inputs to a bitwise OR function to obtain the color-filtered image output by the bitwise OR function.
7. The method according to claim 1, characterized in that, The method includes: performing a matrix-positional multiplication operation on the main region mask and the region image corresponding to each color bar test color to obtain the detection region image corresponding to each color bar test color.
8. An image detection device, characterized in that, The device includes: The filtering module is used to obtain a color-filtered image by detecting the test colors of the color bars in the video frame; the color-filtered image includes the image area corresponding to each of the test colors of the color bars; The region merging module is used to merge adjacent image regions in the color-filtered image to obtain at least one merged region. A determining module is configured to determine a main region from the at least one merged region based on the size of the region outline of the at least one merged region; The detection module is used to sort the image areas corresponding to each of the test colors of the color bars in the main area according to the area size; determine the area difference between two adjacent sorted image areas in the main area; and determine whether there is a color bar signal in the video frame by comparing the area difference with a preset difference, thereby obtaining the color bar detection result.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
License plate positioning method and apparatus based on multiple characteristics
CN102226907A
Ultra-high-definition video color bar abnormal state real-time detection method based on filtering
CN112261406A
Method for removing color fringe in digital image
US20110158514A1