Color cast detection method, device, electronic device and storage medium
By automatically detecting whether the color card channel value in the target image exceeds the preset range, it solves the problem of low efficiency of manual detection of image color casts and missed detections, and achieves efficient and accurate image color cast detection.
Patent Information
- Application Number
- CN202210771751.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2042-06-30
AI Technical Summary
In the prior art, the color casting efficiency of manual image detection is low, and large-scale detection cannot be detected, and there are missed or missed detection.
By obtaining the R, G, B, and Y channel values of the color card in the target picture, it automatically detects whether the R channel value/G channel value, B channel value/G channel value, and Y channel value exceed the preset range, and determines whether the picture is biased. color.
It realizes the automation of picture color cast detection, improves detection efficiency, reduces missed detections and false detections, establishes quantitative detection indicators, and reduces subjective judgment errors.
Smart Images

Figure CN115243033B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing, and in particular to a color cast detection method. Background Art
[0002] During the picture shooting process, due to problems with light or angle, the colors in the captured picture may not match the colors of the actual scene, which is called color cast. Existing camera modules mainly rely on manual detection to determine whether the captured pictures have color cast. If you want to detect the color cast of a large number of pictures, you can only use batch detection.
[0003] The inventors have discovered that there are at least the following problems in the related art: manual inspection is inefficient and cannot cover large-scale inspections of projects, and there are cases of missed inspections and false inspections. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a color cast detection method, device, electronic device and storage medium, so that the camera module can realize automatic detection of whether the captured picture has color cast, which can be used in large quantities in projects, making up for the missed detection, low efficiency and false detection existing in manual detection.
[0005] To solve the above technical problems, an embodiment of the present invention provides a color cast detection method, including: obtaining a captured target image; identifying a color card in the target image; when the color card is identified in the target image, obtaining the values of the R channel, G channel, B channel, and Y channel of the color card as the values of the R channel, G channel, B channel, and Y channel of the target image; and determining that the target image has a color cast when at least one of the following is true: the value of the R channel / the value of the G channel is greater than or equal to a first preset range, the value of the B channel / the value of the G channel is greater than or equal to a second preset range, and the value of the Y channel is greater than or equal to a third preset range.
[0006] An embodiment of the present invention further provides a color cast detection device, comprising: a target image acquisition module, used to acquire a captured target image; a color card recognition module, used to identify a color card in the target image; a color cast detection module, used to, when a color card is recognized in the target image, acquire the values of the R channel, G channel, B channel, and Y channel of the color card as the values of the R channel, G channel, B channel, and Y channel of the target image; and determine that the target image has a color cast when at least one of the following is true: the value of the R channel / the value of the G channel is greater than or equal to a first preset range, the value of the B channel / the value of the G channel is greater than or equal to a second preset range, and the value of the Y channel is greater than or equal to a third preset range.
[0007] An embodiment of the present invention also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the color cast detection method as described above.
[0008] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above-mentioned color cast detection method is implemented.
[0009] In an embodiment of the present invention, a target image is first obtained by photographing with a camera, and then a color card is identified from the photographed target image. After the color card in the target image is identified, the values of the R channel, G channel, B channel, and Y channel of the color card are obtained as the values of the R channel, G channel, B channel, and Y channel of the target image; when at least one of the value of the R channel / the value of the G channel is greater than or equal to the first preset range, the value of the B channel / the value of the G channel is greater than or equal to the second preset range, and the value of the Y channel is greater than or equal to the third preset range is established, the color cast of the target image is determined. The embodiment of the present invention realizes the color cast detection of the image by automatically detecting the values of the R channel, the G channel, the B channel, and the Y channel, and detecting whether the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel exceed the corresponding preset range, without manual participation, making up for the problems of missed detection and low efficiency in manual detection, and establishing a set of quantitative detection indicators to reduce errors caused by subjective judgment and reduce false detection.
[0010] In addition, in one example, after identifying the color card from the target image, it also includes: determining whether the face of the person in the target image is blocked; the first preset range corresponding to the value of the R channel / the value of the G channel includes the first preset range when blocked and the first preset range when not blocked; the second preset range corresponding to the value of the B channel / the value of the G channel includes the second preset range when blocked and the second preset range when not blocked; the third preset range corresponding to the value of the Y channel includes the third preset range when blocked and the third preset range when not blocked; when it is determined that the face of the person in the target image is blocked, the first preset range when blocked, the second preset range when blocked, and the third preset range when blocked are used to determine whether the target image is color cast; when it is determined that the face of the person in the target image is not blocked, the first preset range when not blocked, the second preset range when not blocked, and the third preset range when not blocked are used to determine whether the target image is color cast. By adding a function of determining whether a person's face is obscured in the above-mentioned color cast detection method and providing two different preset range standards when the face is obscured and not obscured, the color cast detection method can be applied to more scenarios and the accuracy of the color cast detection method in different scenarios can be improved.
[0011] In addition, in one example, identifying a color card in a target image includes: identifying a color card in a target image through a color card recognition model trained by a model; determining whether a person's face in a target image is occluded includes: detecting whether a person's face in a target image is occluded through a facial occlusion detection model trained by a model; the color card recognition model and the facial occlusion detection model are obtained by machine learning using a darknet machine training model and a yolov4 neural network model. The two models are obtained by machine learning using a darknet machine training model and a yolov4 neural network model, which can further improve the accuracy of the color cast detection method.
[0012] In addition, in one example, obtaining the values of the R channel, G channel, B channel and Y channel of the color card specifically includes: determining the position of the color card after identifying the color card, and determining the position of each color block in the color card; obtaining the values of the R channel, G channel and B channel of the color card according to the position of each color block; obtaining the value of the Y channel according to the values of the R channel, G channel and B channel and the following formula: Y=R*0.299000+G*0.587000+B*0.114000. The values of the R channel, G channel and B channel of the color card are obtained by the position of the color block in the color card in the target image, and the value of the Y channel of the color card is further calculated, which is more efficient than directly extracting the values of the R channel, G channel and B channel of the entire target image and calculating the value of the Y channel of the target image, and can further improve the efficiency of color cast detection.
[0013] In addition, in one example, after identifying the color card of the target image, it also includes: if the color card is not identified in the target image, then the target image is rotated at least once, and the rotation angle is a preset angle; after the rotation is completed, the color card of the target image is identified again; if the color card is not identified, the target image is rotated again by the preset angle, and after the rotation is completed, the color card of the target image is identified again; until the color card in the target image is identified or the target image is rotated to its original position. When the color card in the target image is not identified, the color card is identified multiple times by rotating the target image multiple times, so as to prevent the color cast detection result from being affected by the incorrect position of the color card in the target image, and avoid false detection and missed detection that may occur during the detection process. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0015] Figure 1 It is a flow chart of an artificial color cast detection method in the related art;
[0016] Figure 2 is a flow chart of a color cast detection method according to an embodiment of the present invention;
[0017] Figure 3 is a schematic diagram of an interface in which a color cast detection method is applied on a terminal according to an embodiment of the present invention;
[0018] Figure 4 is a schematic diagram of a color cast detection method system according to an embodiment of the present invention;
[0019] Figure 5 is a schematic diagram of a color cast detection device according to another embodiment of the present invention;
[0020] Figure 6 is a schematic diagram of an electronic device according to another embodiment of the present invention. DETAILED DESCRIPTION
[0021] To make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented. The division of the following embodiments is for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other without contradiction.
[0022] The specific process of the method of manually detecting color cast of an image in the related art is as follows: Figure 1 As shown. In step 101, the inspector first uses a camera apk, i.e., a camera program, to take a photo to obtain the target image for color cast detection; then in step 102, the inspector exports the target image taken by the camera apk from the camera apk to the computer; in step 103, the image is manually analyzed by PhotoShop software; in step 104, the inspector uses PhotoShop tools to obtain the values (brightness) of the R, G, and B channels corresponding to the color card in the Photoshop tool and calculates the Y value of the color card through the values of the R, G, and B channels; in step 105, after calculating the Y value of the color card through the values of the R, G, and B channels, the value of the R channel / the value of the G channel and the value of the B channel / the value of the G channel are calculated; in step 106, it is determined whether the calculated Y value, the value of the R channel / the value of the G channel, and the value of the B channel / the value of the G channel are all within the preset range; finally, the result is output in step 107.
[0023] However, in the related art, the manual detection of whether the image has color cast requires the detection personnel to import the photo into the Photoshop tool and obtain the detection result through manual analysis, which is inefficient and may cause missed detection and false detection. In order to solve the problems that manual detection is inefficient, cannot cover large-scale detection of projects, and may cause missed detection and false detection, the embodiments of the present invention provide a color cast detection method.
[0024] Another embodiment of the present invention relates to a color cast detection method. In this embodiment, a captured target image is first obtained; a color card is identified in the target image; when the color card is identified in the target image, the values of each RGBY channel of the color card are obtained as the values of the R channel, G channel, B channel, and Y channel of the target image; when at least one of the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel exceeds the corresponding preset range, the target image is determined to be color cast, wherein the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel correspond to a preset range respectively. The embodiment of the present invention realizes the color cast detection of the image by automatically detecting the values of the R channel, the G channel, the B channel, and the Y channel, and detecting whether the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel exceed the corresponding preset range, without manual participation, making up for the problems of missed detection and low efficiency in manual detection, and establishing a set of quantitative detection indicators to reduce the errors caused by subjective judgment and reduce the situation of false detection. The implementation details of the data transmission test method of this embodiment are specifically described below. The following content is only provided for the convenience of understanding the implementation details and is not necessary for implementing this solution.
[0025] The specific process of the color cast detection method of this embodiment is as follows Figure 2 As shown, the color cast detection method of this embodiment is implemented by a tool model apk (i.e., a program for testing). In step 201, the test program calls the camera to take pictures and obtains the target picture that needs to be tested for color cast. In step 202, it will be identified whether there is a color card in the target picture. If the color card is not identified, step 208 is entered to rotate the picture. After the rotation is completed, step 209 is used to judge the rotation angle of the target picture to see whether the picture has been rotated more than one circle. If the target picture has not been rotated more than one circle, then step 201 is entered to continue to the next step 202 to identify whether there is a color card in the target picture and enter a loop until the color card is identified in the target picture and step 203 is entered; or if the target picture is rotated for one circle and the color card is not identified, step 210 is entered to prompt that the framing is wrong, and finally step 206 is entered to output the result.
[0026] In one example, step 208 rotates the image, which may be specifically rotating the target image by a preset angle, and then re-identifying the color card of the rotated target image; if the color card is not identified, the target image is rotated by a preset angle again until the color card is identified or the target image is rotated to its original position. In this embodiment, the preset rotation angle may be 90°, and the color card is identified again after the target image is rotated once and differs from the original target image by 90°. If the color card is identified in the rotated target image, step 203 is entered; if the color card is not identified, the target image is rotated by 90° again for further identification. If the color card is still not identified after the target image is rotated 90° four times, that is, the target image is rotated one circle and returns to the original position, then step 210 is entered to prompt that the framing is wrong. In the case where the color card is not identified for the first time, the target image is rotated multiple times for identification again, which can effectively reduce the missed detection and false detection that may occur when identifying the color card in the target image. In actual operation, the rotation angle of the target image each time is not limited to 90°, as long as the target image can return to its original position after a certain number of rotations, such as 30° or 60° each time.
[0027] In one example, before step 204 detects whether the person in the target image is wearing a mask, there is a step 203 to detect whether there is a human eye. When the color card in the target image is identified, step 203 is entered to detect whether there is a human eye. When the human eye is identified, step 204 is entered to detect whether the mask is worn. If the human eye is not identified, it means that there is no person in the target image, and there is no need to detect whether the mask is worn. Step 207 is directly entered to perform color cast detection on the target image without wearing a mask. When detecting whether a mask is worn in step 204, if it is detected that the person is wearing a mask, step 205 is entered to perform color cast detection on the target image under the condition of wearing a mask; if it is detected that the person is not wearing a mask, step 207 is entered to perform color cast detection on the target image under the standard of not wearing a mask. This embodiment needs to perform step 203 to detect whether there is a human eye in order to provide the following mask detection method; in actual operation, step 203 is not necessary for implementing this solution, and step 202 can directly enter step 204 to detect whether a mask is worn using the mask detection method in the relevant technology. It should be noted that in this embodiment, the purpose of detecting whether a mask is worn is to determine whether the face of the person in the target image is blocked, so as to adopt different standards to determine whether the target image is color cast, thereby improving the accuracy of image color cast detection; in actual applications, it is not necessary to only detect whether a mask is worn to determine whether the face of a person is blocked. Whether the face of a person is blocked can be determined in a variety of ways, for example, by detecting whether the person is wearing an eye mask to determine whether the face of the person in the target image is blocked.
[0028] In one example, after the human eyes are detected in step 203, step 204 is a mask check by further detecting the mouth of the person in the target image. If the mouth of the person in the target image is detected, it is determined that the person is wearing a mask. If the mouth of the person in the target image is not detected, it is determined that the person is not wearing a mask.
[0029] In one example, the color cast detection in the case of wearing a mask in step 205 and the color cast detection in the case of not wearing a mask in step 207 are both performed by first obtaining the color card in the target image identified in step 202; then obtaining the values of the RGBY channels of the color card as the values of the R channel, G channel, B channel, and Y channel of the target image; obtaining the values of the R channel, G channel, B channel, and Y channel of the color card can specifically include determining the position of the color card after identifying the color card, and determining the position of each color block in the color card; the calculation of the color block position can use opencv contour detection to first detect the position of the color card, the 24-color color card is cut into 24 areas, and the position of each color block in the color card can be calculated using x and y coordinates. Then, the values of the RGB three-color channels of the color card are obtained according to the positions of each color block; specifically, Gaussian filtering can be used to filter and remove noise, and then grayscale images of each color block are obtained through opencv color conversion, and the values of the RGB channels of the color card can be obtained from the grayscale image. Then, the value of the Y channel is obtained according to the values of the RGB three-color channels through the following formula: Y=R*0.299000+G*0.587000+B*0.114000. When at least one of the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel exceeds the corresponding preset range, the target image is determined to be color cast. This method is used to perform color cast detection. Among them, the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel correspond to a preset range respectively. When detecting color cast in two different situations in step 205 and step 207, the preset ranges corresponding to the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel are also different.
[0030] In this embodiment, the preset range of color cast detection in the case of wearing a mask corresponding to step 205 includes: the range corresponding to the value of the R channel / the value of the G channel (0.85-1.20), the range corresponding to the value of the B channel / the value of the G channel (0.85-1.20), and the range corresponding to the value of the Y channel 105±35; the preset range of color cast detection in the case of not wearing a mask corresponding to step 207 includes: the range corresponding to the value of the R channel / the value of the G channel (0.85-1.20), the range corresponding to the value of the B channel / the value of the G channel (0.85-1.20), and the range corresponding to the value of the Y channel 135±35. In this embodiment, the color cast detection of the image is realized by automatically detecting the values of the R channel, the G channel, the B channel, and the Y channel, and detecting whether the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel exceed the corresponding preset range, without manual participation, making up for the problems of missed detection and low efficiency in manual detection, and establishing a set of quantitative detection indicators to reduce the errors caused by subjective judgment and reduce the situation of false detection. Providing two different preset range standards when wearing a mask or not can make the color cast detection method applicable to more scenarios and improve the accuracy of the color cast detection method in different scenarios.
[0031] After the color cast detection results are obtained in step 205 and step 207, the process proceeds to step 206 to output the results.
[0032] In one example, step 202 identifies whether a color card exists in the target image by using a color card recognition model trained by a model; step 204 detects whether a person in the target image wears a mask by using a mask recognition model trained by a model; the color card recognition model and the mask recognition model are both obtained by machine learning using a darknet machine training model and a yolov4 neural network model. By using the darknet machine training model and the yolov4 neural network model to perform machine learning on these two models, the accuracy of the target image in color cast detection can be effectively improved.
[0033] The step division of the above methods is only for the purpose of clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.
[0034] The above-mentioned embodiment of the present invention corresponds to a schematic diagram of an interface of a color cast detection method applied on a terminal, such as Figure 4As shown. Below the color cast detection interface, there is a color cast detection algorithm for the user to check. If the user checks it, it means that the target image will be subjected to color cast detection. After taking a photo, the result of the color cast detection of the captured target image will be obtained, and the result will be displayed at the bottom of the screen. If the detection result is that the target image has no color cast, the detection result displayed below is as follows Figure 4 The green pass is shown; there is also a button at the bottom of the interface for the user to retest. Figure 4 Only the color cast test is passed is provided. The other two test result interfaces are Figure 4 Roughly the same, if the detection result shows that the target image has color cast, it will be displayed as red fail below; if the color card is not recognized in the step of identifying the color card during the color cast detection process of the target image, it will be displayed as unknown below.
[0035] The above-mentioned embodiment of the present invention corresponds to a color cast detection system. Figure 5 As shown. The system includes an APP layer, a jni layer, a data layer, a data model layer and an algorithm layer. The APP layer may include an APP and a test model apk, etc.; the various parts that can realize the color cast detection function mentioned in the second embodiment are integrated in the APP or apk in the APP layer. The Jni layer is used to call the program in the system or program library to implement the color cast detection function mentioned in the above embodiment. The color block detection algorithm, the mask detection algorithm and the color cast detection algorithm included in the algorithm layer are called by the jni layer to implement the color cast detection function mentioned in the above embodiment. The data layer contains a group of captured pictures, a group of features, a weight file, a data set and a feature result set. The data model layer contains a darknet machine training model and a yolov4 neural network model, and the algorithm in the algorithm layer uses the darknet machine training model and the yolov4 neural network model for machine learning.
[0036] Another embodiment of the present invention relates to a color cast detection device, such as Figure 5 As shown, the target image acquisition module is used to acquire the captured target image; the color card recognition module is used to recognize the color card in the target image; the color cast detection module is used to obtain the values of each RGBY channel of the color card as the values of each RGBY channel of the target image when the color card is recognized in the target image, and when at least one of the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel exceeds the corresponding preset range, it is determined that the target image has a color cast, wherein the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel correspond to a preset range respectively.
[0037] In one example, the color cast detection device further includes a mask recognition module, which is used to determine whether a person in the target image is wearing a mask after identifying a color card from the target image; the preset ranges corresponding to the value of the R channel / the value of the G channel, the value of the B channel / the value of the G channel, and the value of the Y channel respectively include: a wearing range and a non-wearing range; when it is determined that the person in the target image is wearing a mask, the wearing range is used to determine whether the target image is color cast; when it is determined that the person in the target image is not wearing a mask, the non-wearing range is used to determine whether the target image is color cast.
[0038] In one example, the color cast detection module is specifically used to determine the position of the color card and the position of each color block in the color card; obtain the values of the RGB three-color channels of the color card according to the positions of each color block; and obtain the value of the Y channel according to the values of the RGB three-color channels and through the following formula: Y = R*0.299000+G*0.587000+B*0.114000. By obtaining the RGB value of the color card through the position of the color block in the color card in the target image and further calculating the Y value of the color card, it is more efficient than directly extracting the RGB value of the entire target image and calculating the Y value of the target image, which can further improve the efficiency of color cast detection.
[0039] In one example, the color card recognition module is specifically used to rotate the target image at least once if the color card is not recognized in the target image, and the rotation angle is a preset angle; after the rotation is completed, the target image is color card recognized again; if the color card is not recognized, the target image is rotated again by the preset angle, and after the rotation is completed, the target image is color card recognized again; until the color card in the target image is recognized or the target image is rotated to its original position.
[0040] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
[0041] Another embodiment of the present invention relates to an electronic device, such as Figure 6As shown, at least one processor; and, a memory connected to the at least one processor in communication; wherein the memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that at least one processor can execute the color cast detection method as in the above embodiment. Specifically, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits together, which are all well known in the art, and therefore, are not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium through an antenna, and further, the antenna also receives data and transmits the data to the processor. The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. The memory can be used to store data used by the processor when performing operations.
[0042] One embodiment of the present invention relates to a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the above method embodiment is implemented.
[0043] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0044] Those skilled in the art will appreciate that the above-mentioned embodiments are specific examples for implementing the present invention, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present invention.
Claims
1. A color cast detection method, characterized in that: include: Get the captured target image; identifying a color card in the target image; When the color card is identified in the target image, the values of the R channel, the G channel, the B channel, and the Y channel of the color card are obtained as the values of the R channel, the G channel, the B channel, and the Y channel of the target image; wherein the value of the Y channel of the color card is calculated by the values of the R channel, the G channel, and the B channel; When at least one of the value of the R channel / the value of the G channel exceeds a first preset range, the value of the B channel / the value of the G channel exceeds a second preset range, and the value of the Y channel exceeds a third preset range is established, determining that the target image is color cast; After identifying the color card in the target image, the method further includes: Determine whether the face of the person in the target image is blocked; The first preset range corresponding to the value of the R channel / the value of the G channel includes a first preset range when blocked and a first preset range when not blocked; The second preset range corresponding to the value of the B channel / the value of the G channel includes a second preset range when blocked and a second preset range when not blocked; The third preset range corresponding to the value of the Y channel includes a third preset range when blocked and a third preset range when not blocked; In the case where it is determined that the face of the person in the target image is blocked, using the first preset range when blocked, the second preset range when blocked, and the third preset range when blocked to determine whether the target image has color cast; When it is determined that the face of the person in the target image is not obstructed, the first preset range when it is not obstructed, the second preset range when it is not obstructed and the third preset range when it is not obstructed are used to determine whether the target image has color cast.
2. The color cast detection method according to claim 1, characterized in that: The step of identifying the color card in the target image includes: The color card recognition model trained by the model recognizes the color card in the target image; The determining whether the face of the person in the target image is blocked includes: Detecting whether the face of the person in the target image is occluded by using a face occlusion detection model trained by the model; The color card recognition model and the facial occlusion detection model are both obtained by machine learning using the darknet machine training model and the yolov4 neural network model.
3. The color cast detection method according to claim 1, characterized in that: After identifying the color card in the target image, the method further includes: If the color card is not recognized, the target image is rotated at least once until the color card is recognized or the target image is rotated to its original position.
4. The color cast detection method according to claim 3, characterized in that: The step of rotating the target image at least once until the color card is recognized or the target image is rotated to its original position includes: Rotate the target image by a preset angle, and perform color card recognition again on the rotated target image; If the color card is not recognized, the target image is rotated again by the preset angle until the color card is recognized or the target image is rotated to the original position.
5. The color cast detection method according to any one of claims 1 to 4, characterized in that: The obtaining of the values of the R channel, the G channel, the B channel, and the Y channel of the color card includes: After identifying the color card, determining the position of the color card, and determining the position of each color block in the color card; Obtaining values of the R channel, the G channel, and the B channel of the color card according to the positions of the respective color blocks; The value of the Y channel is obtained according to the values of the R channel, the G channel, and the B channel through the following formula: Y = R *0.299000 + G *0.587000 + B *0.114000.
6. A color cast detection device, characterized in that: include: A target image acquisition module is used to acquire the captured target image; A color card recognition module, used to recognize a color card in the target image; a color cast detection module, for obtaining, when the color card is identified in the target image, the values of the R channel, the G channel, the B channel, and the Y channel of the color card as the values of the R channel, the G channel, the B channel, and the Y channel of the target image; and determining the color cast of the target image when at least one of the value of the R channel / the value of the G channel exceeds a first preset range, the value of the B channel / the value of the G channel exceeds a second preset range, and the value of the Y channel exceeds a third preset range; wherein the value of the Y channel of the color card is calculated by the values of the R channel, the G channel, and the B channel; The color card recognition module is also used to determine whether the face of the person in the target image is blocked; the first preset range corresponding to the value of the R channel / the value of the G channel includes a first preset range when blocked and a first preset range when not blocked; the second preset range corresponding to the value of the B channel / the value of the G channel includes a second preset range when blocked and a second preset range when not blocked; the third preset range corresponding to the value of the Y channel includes a third preset range when blocked and a third preset range when not blocked; when it is determined that the face of the person in the target image is blocked, the first preset range when blocked, the second preset range when blocked, and the third preset range when blocked are used to determine whether the target image is color cast; when it is determined that the face of the person in the target image is not blocked, the first preset range when not blocked, the second preset range when not blocked, and the third preset range when not blocked are used to determine whether the target image is color cast.
7. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the color cast detection method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the color cast detection method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Automatic white balance method and device based on target recognition
CN113239756A
Color cast detection method and device, equipment and storage medium
CN113840135A