Video dominant hue extraction method and device, electronic equipment and storage medium
By combining the preset black edge removal algorithm and dynamic partitioning algorithm in the video main color extraction method, and using technologies such as color histogram and edge detection, the real-time and accuracy problems of invalid black edge identification and intelligent color adjustment in videos are solved. Achieving stable and reliable main color extraction in a variety of scenes.
Patent Information
- Application Number
- CN202410667466.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-10
AI Technical Summary
Existing video main color extraction methods have shortcomings in real-time performance and accuracy in automatically identifying and removing invalid black edges and achieving intelligent color adjustment.
Adopting a video main tone extraction method based on preset black edge removal algorithm and dynamic division algorithm, through color histogram, edge detection and non-maximum suppression (NMS) technology, the image area is accurately cut and the main tone is extracted, combined with color space conversion and cluster analysis to achieve intelligent image segmentation and adaptive adjustment.
It improves the recognition accuracy and differentiation ability of the main colors in the video, ensuring stable and reliable extraction of the main colors of the video partitions under different scenes and lighting conditions, and is suitable for a variety of application scenarios.
Smart Images

Figure CN118631977A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of automobile application technology, and in particular to a method, device, electronic device and storage medium for extracting main color tone of a video. Background Art
[0002] In the current multimedia technology and computer vision field, with the widespread dissemination of high-definition video content and the growing demand for intelligent monitoring and streaming media services, the requirements for video processing technology are getting higher and higher. In terms of image content analysis and enhancement, the extraction and optimization of color features is a crucial link, especially for the generation of high-quality video content and the needs of adapting to different display terminals, accurate and efficient color management technology is indispensable.
[0003] The video main color extraction method in the related art has deficiencies in real-time and accuracy in automatically identifying and removing invalid black edges and realizing intelligent color adjustment. Summary of the invention
[0004] The embodiments of the present application provide a method, device, system, electronic device and computer-readable storage medium for extracting the main color tone of a video to solve the problems in the related art in terms of automatic identification and removal of invalid black edges and realization of intelligent color adjustment, which are insufficient in real time and accuracy.
[0005] In a first aspect, an embodiment of the present application provides a method for extracting a main color tone of a video, the method comprising:
[0006] Generate a target image frame sequence according to the video stream to be processed;
[0007] Cutting the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence;
[0008] Comparing the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region;
[0009] The main tones corresponding to the divided regions of the image are extracted.
[0010] Optionally, the cutting of the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence includes:
[0011] Obtaining a color histogram corresponding to each target image frame in the target image frame sequence;
[0012] Determine whether there is a border in each target image frame according to the standard deviation of the color histogram;
[0013] If so, convert each target image frame into a grayscale image;
[0014] Calculating the image edge strength in the vertical direction and the horizontal direction for the grayscale image to generate a vertical edge image and a horizontal edge image;
[0015] Respectively obtaining the number of pixels of the vertical edge image and the horizontal edge image;
[0016] Obtaining a ratio of vertical edge length in the vertical direction according to the number of pixels of the vertical edge image, and obtaining a ratio of horizontal edge length in the horizontal direction according to the number of pixels of the horizontal edge image;
[0017] Obtaining the mean values of all pixels corresponding to the vertical edge image and the horizontal edge image;
[0018] Folding the vertical edge image and the horizontal edge image along a center line, and determining whether an edge length corresponding to the folded target frame is greater than a preset threshold;
[0019] If not, determining whether the mean value of the pixel belongs to an extreme black and white value;
[0020] If not, the target frame is determined to be the frame to be cut;
[0021] Eliminating redundant border information corresponding to multiple borders corresponding to each target image frame in the target image frame sequence by NMS, and obtaining a continuous border track corresponding to the target image frame sequence;
[0022] The target image frame sequence is cut according to the continuous border trajectory to obtain an image region in the target image frame sequence.
[0023] Optionally, comparing the image regions corresponding to target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region comprises:
[0024] Comparing the image regions corresponding to a preset number of consecutive target image frames based on the order corresponding to the target image frame sequence, and determining at least one object in the image region whose motion variation range exceeds a preset range;
[0025] A center point corresponding to the object is selected, the image area is divided according to a preset perimeter, and at least one image division area corresponding to the image area is determined, wherein the shape corresponding to the image division area includes a rectangle.
[0026] Optionally, extracting the main color tone corresponding to the divided areas of the image includes:
[0027] The color feature value of the main color tone corresponding to each of the image division areas is extracted by a preset color tone extraction algorithm; wherein the preset color tone extraction algorithm includes at least one of color space conversion, cluster analysis or histogram statistics.
[0028] Optionally, after the step of extracting the main tones corresponding to the divided image regions, the method includes:
[0029] The target vehicle atmosphere light display corresponding to each image division area is controlled according to the playback order of the video stream to be processed and the main color tone corresponding to each image division area in the video stream to be processed.
[0030] Optionally, generating a target image frame sequence according to the video stream data to be processed includes:
[0031] Receive the video stream to be processed sent by the cloud;
[0032] Decoding the video stream to be processed into an image frame sequence in real time;
[0033] A preprocessing operation is performed on the image frame sequence to obtain a target image frame sequence.
[0034] Optionally, performing a preprocessing operation on the image frame sequence to obtain a target image frame sequence includes:
[0035] A preprocessing operation is performed on each image frame in the image frame sequence to obtain a target image frame sequence, wherein the preprocessing operation includes at least one of a denoising process, an equalization process, and a scaling process.
[0036] In a second aspect, an embodiment of the present application provides a video main color extraction device, the device comprising:
[0037] A generation module, used for generating a target image frame sequence according to a video stream to be processed;
[0038] A cutting module, used for cutting the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image area in the target image frame sequence;
[0039] A division module, configured to compare the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determine at least one image division region corresponding to the image region;
[0040] The extraction module is used to extract the main color tone corresponding to the divided areas of the image.
[0041] Optionally, the cutting module comprises:
[0042] A first cutting submodule is used to obtain a color histogram corresponding to each target image frame in the target image frame sequence;
[0043] A second cutting submodule is used to determine whether there is a border in each target image frame according to the standard deviation of the color histogram;
[0044] A third cutting submodule is used for converting each target image frame into a grayscale image if yes;
[0045] A fourth cutting submodule is used to calculate the image edge strength in the vertical direction and the horizontal direction for the grayscale image, and generate a vertical edge image and a horizontal edge image;
[0046] A fifth cutting submodule, used for respectively obtaining the number of pixels of the vertical edge image and the horizontal edge image;
[0047] a sixth cutting submodule, configured to obtain a ratio of vertical edge lengths in the vertical direction according to the number of pixels of the vertical edge image, and to obtain a ratio of horizontal edge lengths in the horizontal direction according to the number of pixels of the horizontal edge image;
[0048] A seventh cutting submodule, used to obtain the average values of all pixels corresponding to the vertical edge image and the horizontal edge image;
[0049] an eighth cutting submodule, configured to fold the vertical edge image and the horizontal edge image along a center line, and determine whether an edge length corresponding to the folded target frame is greater than a preset threshold;
[0050] a ninth cutting submodule, for determining whether the mean value of the pixels belongs to an extreme black and white value;
[0051] a tenth cutting submodule, for determining, if not, that the target frame is a frame to be cut;
[0052] an eleventh cutting submodule, configured to eliminate redundant border information corresponding to a plurality of borders corresponding to each target image frame in the target image frame sequence through NMS, and obtain a continuous border track corresponding to the target image frame sequence;
[0053] The twelfth cutting submodule is used to cut the target image frame sequence according to the continuous border trajectory to obtain the image area in the target image frame sequence.
[0054] Optionally, the division module includes:
[0055] A first division submodule is used to compare the image regions corresponding to a preset number of consecutive target image frames based on the order corresponding to the target image frame sequence, and determine at least one object in the image region whose motion change range exceeds a preset range;
[0056] The second division submodule is used to select a center point corresponding to the object, divide the image area according to a preset perimeter, and determine at least one image division area corresponding to the image area, wherein the shape corresponding to the image division area includes a rectangle.
[0057] Optionally, the extraction module includes:
[0058] The extraction submodule is used to extract the color feature value of the main color tone corresponding to each of the image division areas through a preset color tone extraction algorithm; wherein the preset color tone extraction algorithm includes at least one of color space conversion, cluster analysis or histogram statistics.
[0059] Optionally, the device further comprises:
[0060] The display module is used to control the target vehicle atmosphere light display corresponding to each image division area according to the playback order of the video stream to be processed and the main color tone corresponding to each image division area in the video stream to be processed.
[0061] Optionally, the generating module includes:
[0062] The first generation submodule is used to receive the video stream to be processed sent by the cloud;
[0063] The second generating submodule is used to decode the to-be-processed video stream into an image frame sequence in real time;
[0064] The third generating submodule is used to perform a preprocessing operation on the image frame sequence to obtain a target image frame sequence.
[0065] Optionally, the third generation submodule includes:
[0066] The preprocessing unit is used to perform a preprocessing operation on each image frame in the image frame sequence to obtain a target image frame sequence, wherein the preprocessing operation includes at least one of a denoising process, an equalization process, and a scaling process.
[0067] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor, wherein the processor is configured to execute the instructions to implement any of the video main color extraction methods described above.
[0068] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the above-described methods for extracting the main color tone of a video.
[0069] In a fifth aspect, an embodiment of the present application further provides a vehicle, comprising the video main color tone extraction device as described above.
[0070] In an embodiment of the present application, a target image frame sequence is generated according to a video stream to be processed; the border of the target image frame sequence is cut based on a preset black edge removal algorithm to obtain an image area in the target image frame sequence; the image areas corresponding to the target image frame sequences of a preset number of consecutive frames are compared based on the order corresponding to the target image frame sequence to determine at least one image division area corresponding to the image area; and the main color tone corresponding to the image division area is extracted. That is, the embodiment of the present application can more accurately identify and distinguish the main colors of different areas in the video by cutting based on a preset black edge removal algorithm combined with a dynamic division algorithm, that is, introducing a more accurate color model, intelligent image segmentation technology and machine learning algorithm; for dynamically changing video content, an adaptive adjustment analysis strategy can be implemented to ensure that the main color tone information can still be effectively extracted under different scene switching or lighting conditions, and by processing the video stream, it is not affected by factors such as video format, encoding standard or ambient lighting, and can stably and reliably extract the main color tone of the video partition in a variety of application scenarios.
[0071] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0073] Figure 1 This is a flowchart of the steps of a method for extracting the main color tone of a video provided in an embodiment of the present application;
[0074] Figure 2 is a flowchart of another method for extracting main color tone of a video provided by an embodiment of the present application;
[0075] Figure 3 It is a logic block diagram of a video main color tone extraction device provided by the present application;
[0076] Figure 4 is a structural diagram of an electronic device provided in an embodiment of the present application;
[0077] Figure 5 This is a schematic diagram of a video main color extraction process provided by an embodiment of the present application;
[0078] Figure 6 This is a schematic diagram of a preset black edge removal algorithm flow provided in an embodiment of the present application;
[0079] Figure 7 It is a schematic diagram of an application scenario of video main color extraction provided in an embodiment of the present application. DETAILED DESCRIPTION
[0080] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0081] Figure 1 is a flowchart of a method for extracting the main color tone of a video provided by an embodiment of the present application. Figure 1 As shown, the method may include:
[0082] Step 101, generating a target image frame sequence according to a video stream to be processed;
[0083] Furthermore, generating a target image frame sequence according to the video stream data to be processed includes:
[0084] Receive the video stream to be processed sent by the cloud;
[0085] Decoding the video stream to be processed into an image frame sequence in real time;
[0086] A preprocessing operation is performed on the image frame sequence to obtain a target image frame sequence.
[0087] Further, the performing a preprocessing operation on the image frame sequence to obtain a target image frame sequence includes:
[0088] A preprocessing operation is performed on each image frame in the image frame sequence to obtain a target image frame sequence, wherein the preprocessing operation includes at least one of a denoising process, an equalization process, and a scaling process.
[0089] It should be noted that in the embodiment of the present application, after receiving the video stream sent by the cloud or other end, the video stream is first decoded in real time. Real-time decoding of the video stream can ensure that the original video signal is accurately converted into a processable image frame sequence.
[0090] Furthermore, a preprocessing operation is performed on each image frame in the received image frame sequence, for example, denoising, equalization, and scaling, etc. The quality and efficiency of subsequent color feature extraction can be improved through preprocessing.
[0091] Step 102, cutting the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence;
[0092] It should be noted that after processing the image frame sequence, a target image frame sequence is generated. For the target image frame sequence, the black or white border of the video must first be cut and removed based on a preset black border removal algorithm.
[0093] Cutting and removing the black or white borders of a video by using a preset black border removal algorithm can essentially be regarded as a precise image segmentation.
[0094] For details, please refer to the following discussion.
[0095] Furthermore, the border of the target image frame sequence is cut based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence, including:
[0096] Obtaining a color histogram corresponding to each target image frame in the target image frame sequence;
[0097] Determining whether there is a border in each target image frame according to the standard deviation of the color histogram;
[0098] If so, convert each target image frame into a grayscale image;
[0099] Calculating the image edge strength in the vertical direction and the horizontal direction for the grayscale image to generate a vertical edge image and a horizontal edge image;
[0100] Obtaining the mean values of all pixels corresponding to the vertical edge image and the horizontal edge image;
[0101] Folding the vertical edge image and the horizontal edge image along a center line, and determining whether an edge length corresponding to the folded target frame is greater than a preset threshold;
[0102] If not, determining whether the mean value of the pixel belongs to an extreme black and white value;
[0103] If not, the target frame is determined to be the frame to be cut;
[0104] Eliminating redundant border information corresponding to multiple borders corresponding to each target image frame in the target image frame sequence by NMS, and obtaining a continuous border track corresponding to the target image frame sequence;
[0105] The target image frame sequence is cut according to the continuous border trajectory to obtain an image region in the target image frame sequence.
[0106] It should be noted that in the embodiments of the present application, reference is made to Figure 6 , Figure 6 : is a schematic diagram of a preset black edge removal algorithm provided in an embodiment of the present application. It can be seen that the preset black edge removal algorithm includes the following steps:
[0107] First, perform image color histogram feature extraction. Specifically, calculate the color histogram of each frame of the input video. Calculate the standard deviation σ of the histogram. If σ is less than a preset threshold (e.g., 1024), it is considered that the frame image does not contain an obvious pure color border.
[0108] Second, image binarization processing, specifically, converting each frame of the image into a grayscale image.
[0109] The OTSU algorithm can be used to determine the optimal binary segmentation threshold for converting each image frame into a grayscale image, thereby converting the image into a grayscale image while maintaining a clear foreground image and background area image.
[0110] Among them, the OTSU algorithm divides the image into two parts, background and foreground, according to the grayscale characteristics of the image. Because variance is a measure of the uniformity of grayscale distribution, the larger the inter-class variance between the background and foreground, the greater the difference between the two parts of the image. When part of the foreground is mistakenly classified as the background or part of the background is mistakenly classified as the foreground, the difference between the two parts will become smaller.
[0111] The OTSU algorithm can achieve fast segmentation without being affected by the brightness of the image during the image segmentation process.
[0112] Third, edge detection and calculation. Specifically, the Sobel operator is used to calculate the image edge strength in the vertical and horizontal directions respectively to generate corresponding vertical and horizontal edge images.
[0113] Fourth, edge attribute statistics and evaluation. Specifically, the number of pixels in the vertical and horizontal edge images is counted to obtain the edge length ratio in each direction.
[0114] It should be noted that in the embodiment of the present application, when calculating the edge length, the edge length ratio is used, which can be specifically calculated separately in the vertical direction and the horizontal direction. Therefore, first, the number of pixels of the vertical edge image and the horizontal edge image are obtained respectively; then, the ratio of the vertical edge length in the vertical direction is obtained according to the number of pixels of the vertical edge image, and the ratio of the horizontal edge length in the horizontal direction is obtained according to the number of pixels of the horizontal edge image.
[0115] In the embodiment of the present application, the number of pixels in the vertical and horizontal edge images is counted to analyze the edge information in the image and understand the structure of the image.
[0116] In the embodiment of the present application, by calculating the edge ratio, that is, calculating the ratio of the vertical and horizontal edge lengths, it can be used to evaluate the edge distribution of the image and determine the texture direction and edge characteristics of the image.
[0117] Calculate the mean of all pixels in the area to determine whether they are distributed at extreme black and white values.
[0118] Fifth, border recognition and screening. Specifically, fold the image along the center line and compare whether the length of the longest side after folding exceeds the set threshold, and confirm that its color mean is not extreme black and white. If the conditions are met, the side is identified as a potential border edge.
[0119] It should be noted that the vertical edge image and the horizontal edge image are folded along the center line, and the edge length ratio of the folded image is calculated. The edge length of the target frame is determined based on these ratios, and it is determined whether it exceeds a preset threshold. If it exceeds, the edge is identified as the target frame.
[0120] Sixth, non-maximum suppression (NMS) and unified processing. Specifically, the above processing is performed on all frames of the entire video, and the redundant or conflicting border information is eliminated through the NMS method to obtain a unique and continuous border track.
[0121] It should be noted that the entire video includes multiple video frames. Therefore, when the above steps are performed on all video frames or on video frames at a certain interval, there will be redundant border information. Therefore, it is necessary to eliminate redundant or conflicting border information through non-maximum suppression (NMS) to obtain a unique and continuous border track.
[0122] It should be noted that, in the embodiment of the present application, all frames of the video are accurately cut using the obtained stable border information to ensure the consistency and accuracy of the final screenshot result.
[0123] Step 103, comparing the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region;
[0124] Further, step 103, that is, comparing the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region includes:
[0125] Comparing the image regions corresponding to a preset number of consecutive target image frames based on the order corresponding to the target image frame sequence, and determining at least one object in the image region whose motion variation range exceeds a preset range;
[0126] A center point corresponding to the object is selected, the image area is divided according to a preset perimeter, and at least one image division area corresponding to the image area is determined, wherein the shape corresponding to the image division area includes a rectangle.
[0127] It should be noted that, in the embodiment of the present application, after the black edges of the video stream are removed, it is necessary to perform partition extraction on the color tone. Specifically, for example, it can be a group of video frames, and a group of video frames includes 10 frames to determine the degree of change of the object motion picture in the video frames between the consecutive multiple groups. A center point is selected from the part with the largest degree of change of the object motion picture, and a preset perimeter is determined to draw a rectangular frame, and then the image areas corresponding to the target image frame sequence are divided according to the rectangular frame, and divided into multiple image division areas. Specifically, reference can be made to Figure 7 , Figure 7 The image is divided into four regions.
[0128] Specifically, the optical flow algorithm can be used to capture and analyze the degree of change in the object's motion picture.
[0129] It should be noted that in the embodiment of the present application, the division of the image area is dynamic, and the area boundaries are dynamically adjusted using an adaptive algorithm based on changes in the video content, thereby ensuring that the color features of different areas can be effectively tracked and captured even in rapidly changing or complex scenes.
[0130] Step 104: extract the main color tone corresponding to the divided areas of the image.
[0131] Furthermore, step 104, namely, extracting the main color tone corresponding to the divided regions of the image includes:
[0132] The color feature value of the main color tone corresponding to each of the image division areas is extracted by a preset color tone extraction algorithm; wherein the preset color tone extraction algorithm includes at least one of color space conversion, cluster analysis or histogram statistics.
[0133] It should be noted that in the embodiments of the present application, the overall method flow framework can refer to Figure 5 ,In each segmented area, color space conversion, cluster analysis or histogram statistics are used to determine and extract the color feature values representing the main color tone of the area.
[0134] In an embodiment of the present application, a target image frame sequence is generated according to a video stream to be processed; the border of the target image frame sequence is cut based on a preset black edge removal algorithm to obtain an image area in the target image frame sequence; the image areas corresponding to the target image frame sequences of a preset number of consecutive frames are compared based on the order corresponding to the target image frame sequence to determine at least one image division area corresponding to the image area; and the main color tone corresponding to the image division area is extracted. That is, the embodiment of the present application can more accurately identify and distinguish the main colors of different areas in the video by cutting based on a preset black edge removal algorithm combined with a dynamic division algorithm, that is, introducing a more accurate color model, intelligent image segmentation technology and machine learning algorithm; for dynamically changing video content, an adaptive adjustment analysis strategy can be implemented to ensure that the main color tone information can still be effectively extracted under different scene switching or lighting conditions, and by processing the video stream, it is not affected by factors such as video format, encoding standard or ambient lighting, and can stably and reliably extract the main color tone of the video partition in a variety of application scenarios.
[0135] Figure 2 is a flowchart of a method for extracting the main color tone of a video provided by an embodiment of the present application. Figure 2 As shown, the method includes:
[0136] Step 201, generating a target image frame sequence according to a video stream to be processed;
[0137] Step 202, cutting the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence;
[0138] Step 203, comparing the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region;
[0139] Step 204, extracting the main color tone corresponding to the divided areas of the image;
[0140] It should be noted that, in the embodiment of the present application, the above steps 201-204 refer to the previous discussion and will not be repeated here.
[0141] Step 205 , controlling the display of the target vehicle atmosphere light corresponding to each of the image division areas according to the playback order of the video stream to be processed and the main color tone corresponding to each of the image division areas in the video stream to be processed.
[0142] It should be noted that, in the embodiment of the present application, when the video stream is a video played on the vehicle media of the target vehicle, it can be referred to Figure 7 , Figure 7 In an exemplary target vehicle, after the video main color zoning extraction in this application, the video stream area is divided into 4 rectangles. The corresponding color of the ambient light display closest to the first divided area can be controlled according to the first main color corresponding to the first divided area. Similarly, the ambient light display of the remaining divided areas can also be adjusted in this way.
[0143] The embodiment of the present application combines cutting based on a preset black edge removal algorithm with a dynamic partitioning algorithm, that is, introducing a more accurate color model, intelligent image segmentation technology and machine learning algorithm, which can more accurately identify and distinguish the main colors of different areas in the video; for dynamically changing video content, an adaptive adjustment analysis strategy can be implemented to ensure that the main color information can still be effectively extracted under different scene switching or lighting conditions. By processing the video stream, it is not affected by factors such as video format, encoding standard or ambient lighting, and can stably and reliably extract the main color of the video partition in a variety of application scenarios.
[0144] In addition, in the embodiments of the present application, by extracting the main color tone of the video, it can be applied to the intelligent optimization scenario of the target vehicle. After the video is played through the vehicle media in real time based on the video stream segmentation and division of the area, it can be achieved that the corresponding ambient lights around the different areas are controlled to display the same or similar colors, thereby creating a feeling of combination of video and vehicle interior space for the user.
[0145] Corresponding to the method provided in the above-mentioned video main color extraction method embodiment of the present application, see Figure 3 The present application also provides a logic block diagram of a video main color extraction device. In this embodiment, the device 300 includes:
[0146] A generating module 301 is used to generate a target image frame sequence according to a video stream to be processed;
[0147] A cutting module 302 is used to cut the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence;
[0148] A division module 303 is used to compare the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determine at least one image division region corresponding to the image region;
[0149] The extraction module 304 is used to extract the main color tone corresponding to the divided areas of the image.
[0150] Optionally, the cutting module comprises:
[0151] A first cutting submodule is used to obtain a color histogram corresponding to each target image frame in the target image frame sequence;
[0152] A second cutting submodule is used to determine whether there is a border in each target image frame according to the standard deviation of the color histogram;
[0153] A third cutting submodule is used for converting each target image frame into a grayscale image if yes;
[0154] A fourth cutting submodule is used to calculate the image edge strength in the vertical direction and the horizontal direction for the grayscale image, and generate a vertical edge image and a horizontal edge image;
[0155] A fifth cutting submodule, used for respectively obtaining the number of pixels of the vertical edge image and the horizontal edge image;
[0156] a sixth cutting submodule, configured to obtain a ratio of vertical edge lengths in the vertical direction according to the number of pixels of the vertical edge image, and to obtain a ratio of horizontal edge lengths in the horizontal direction according to the number of pixels of the horizontal edge image;
[0157] A seventh cutting submodule, used to obtain the average values of all pixels corresponding to the vertical edge image and the horizontal edge image;
[0158] an eighth cutting submodule, configured to fold the vertical edge image and the horizontal edge image along a center line, and determine whether an edge length corresponding to the folded target frame is greater than a preset threshold;
[0159] a ninth cutting submodule, for determining whether the mean value of the pixels belongs to an extreme black and white value;
[0160] a tenth cutting submodule, for determining, if not, that the target frame is a frame to be cut;
[0161] an eleventh cutting submodule, configured to eliminate redundant border information corresponding to a plurality of borders corresponding to each target image frame in the target image frame sequence through NMS, and obtain a continuous border track corresponding to the target image frame sequence;
[0162] The twelfth cutting submodule is used to cut the target image frame sequence according to the continuous border trajectory to obtain the image area in the target image frame sequence.
[0163] Optionally, the division module includes:
[0164] A first division submodule is used to compare the image regions corresponding to a preset number of consecutive target image frames based on the order corresponding to the target image frame sequence, and determine at least one object in the image region whose motion change range exceeds a preset range;
[0165] The second division submodule is used to select a center point corresponding to the object, divide the image area according to a preset perimeter, and determine at least one image division area corresponding to the image area, wherein the shape corresponding to the image division area includes a rectangle.
[0166] Optionally, the extraction module includes:
[0167] The extraction submodule is used to extract the color feature value of the main color tone corresponding to each of the image division areas through a preset color tone extraction algorithm; wherein the preset color tone extraction algorithm includes at least one of color space conversion, cluster analysis or histogram statistics.
[0168] Optionally, the device further comprises:
[0169] The display module is used to control the target vehicle atmosphere light display corresponding to each image division area according to the playback order of the video stream to be processed and the main color tone corresponding to each image division area in the video stream to be processed.
[0170] Optionally, the generating module includes:
[0171] The first generation submodule is used to receive the video stream to be processed sent by the cloud;
[0172] The second generating submodule is used to decode the to-be-processed video stream into an image frame sequence in real time;
[0173] The third generating submodule is used to perform a preprocessing operation on the image frame sequence to obtain a target image frame sequence.
[0174] Optionally, the third generation submodule includes:
[0175] The preprocessing unit is used to perform a preprocessing operation on each image frame in the image frame sequence to obtain a target image frame sequence, wherein the preprocessing operation includes at least one of a denoising process, an equalization process, and a scaling process.
[0176] In summary, the embodiment of the present application provides a video main color tone extraction device. The embodiment of the present application introduces a more accurate color model, intelligent image segmentation technology and machine learning algorithm by cutting based on a preset black edge removal algorithm, so as to more accurately identify and distinguish the main colors of different areas in the video; for dynamically changing video content, an adaptive adjustment analysis strategy can be implemented to ensure that the main color tone information can still be effectively extracted under different scene switching or lighting conditions; by processing the video stream, it is not affected by factors such as video format, encoding standard or ambient lighting, and can stably and reliably extract the main color tone of the video partition in a variety of application scenarios.
[0177] Figure 4 This is a structural diagram of an electronic device M00 provided in an embodiment of the present application. In the figure, the electronic device M00 includes a processor M01 and a memory M02. The memory M02 stores programs or instructions that can be run on the processor M01. When the program or instructions are executed by the processor M01, the various steps of the above-mentioned video main color tone extraction method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not repeated here.
[0178] In an embodiment of the present application, the memory M02 can be used to store software programs and various data. The memory M02 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instruction required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory M02 may include a volatile memory or a non-volatile memory, or the memory x09 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be random access memory (Random Access Memory, RAM), static random access memory (Static RAM, SRAM), dynamic random access memory (Dynamic RAM, DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (EnhancedSDRAM, ESDRAM), synchronous link dynamic random access memory (Synch link DRAM, SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DRRAM). The memory M02 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0179] The processor M01 may include one or more processing units; optionally, the processor M01 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor M01.
[0180] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned video main color tone extraction method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0181] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0182] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned video main color tone extraction method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0183] It should be understood that the chip involved in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0184] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned video main color tone extraction method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0185] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0186] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0187] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for extracting main color tone of a video, characterized in that: The method comprises: Generate a target image frame sequence according to the video stream to be processed; Cutting the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence; Comparing the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region; The main tones corresponding to the divided regions of the image are extracted.
2. The method according to claim 1, characterized in that The border of the target image frame sequence is cut based on a preset black edge removal algorithm to obtain an image region in the target image frame sequence, including: Obtaining a color histogram corresponding to each target image frame in the target image frame sequence; Determining whether there is a border in each target image frame according to the standard deviation of the color histogram; If so, convert each target image frame into a grayscale image; Calculating the image edge strength in the vertical direction and the horizontal direction for the grayscale image to generate a vertical edge image and a horizontal edge image; Obtaining the mean values of all pixels corresponding to the vertical edge image and the horizontal edge image; Folding the vertical edge image and the horizontal edge image along a center line, and determining whether an edge length corresponding to the folded target frame is greater than a preset threshold; If not, determining whether the mean value of the pixel belongs to an extreme black and white value; If not, the target frame is determined to be the frame to be cut; Eliminating redundant border information corresponding to multiple borders corresponding to each target image frame in the target image frame sequence by NMS, and obtaining a continuous border track corresponding to the target image frame sequence; The target image frame sequence is cut according to the continuous border trajectory to obtain an image region in the target image frame sequence.
3. The method according to claim 1, characterized in that The step of comparing the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determining at least one image division region corresponding to the image region comprises: Comparing the image regions corresponding to a preset number of consecutive target image frames based on the order corresponding to the target image frame sequence, and determining at least one object in the image region whose motion variation range exceeds a preset range; A center point corresponding to the object is selected, the image area is divided according to a preset perimeter, and at least one image division area corresponding to the image area is determined, wherein the shape corresponding to the image division area includes a rectangle.
4. The method according to claim 1, characterized in that: The extracting the main color tone corresponding to the divided area of the image comprises: The color feature value of the main color tone corresponding to each of the image division areas is extracted by a preset color tone extraction algorithm; wherein the preset color tone extraction algorithm includes at least one of color space conversion, cluster analysis or histogram statistics.
5. The method according to claim 1, characterized in that After the step of extracting the main tones corresponding to the divided areas of the image, the method comprises: The target vehicle atmosphere light display corresponding to each image division area is controlled according to the playback order of the video stream to be processed and the main color tone corresponding to each image division area in the video stream to be processed.
6. The method according to claim 1, characterized in that Generating a target image frame sequence according to the video stream data to be processed comprises: Receive the video stream to be processed sent by the cloud; Decoding the video stream to be processed into an image frame sequence in real time; A preprocessing operation is performed on the image frame sequence to obtain a target image frame sequence.
7. The method according to claim 2, characterized in that The performing a preprocessing operation on the image frame sequence to obtain a target image frame sequence comprises: A preprocessing operation is performed on each image frame in the image frame sequence to obtain a target image frame sequence, wherein the preprocessing operation includes at least one of a denoising process, an equalization process, and a scaling process.
8. A video main color extraction device, characterized in that: The device comprises: A generation module, used for generating a target image frame sequence according to a video stream to be processed; A cutting module, used for cutting the border of the target image frame sequence based on a preset black edge removal algorithm to obtain an image area in the target image frame sequence; A division module, configured to compare the image regions corresponding to the target image frame sequences of a preset number of consecutive frames based on the order corresponding to the target image frame sequences, and determine at least one image division region corresponding to the image region; The extraction module is used to extract the main color tone corresponding to the divided areas of the image.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video main color tone extraction method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the video main color tone extraction method according to any one of claims 1 to 7.
