Methods, systems, and computer-readable storage mediums for detecting a state of a signal light
Some embodiments of the present disclosure provide methods, devices, computer-readable storage mediums for detecting a signal light. The method may include obtaining a first image and a second image previous to the first image in time sequence, wherein both the first image and the second image include a same target signal light; determining, based on the first image, a first state of the target signal light in the first image; determining, based on the second image and the first image, a second state of the target signal light in the first image; and determining, based on the first state and the second state, a target state of the target signal light at a time point when the first image is captured.
1 . A method for detecting a signal light, comprising:
obtaining a first image and a second image previous to the first image in time sequence, wherein both the first image and the second image include a same target signal light;
determining, based on the first image, a first state of the target signal light in the first image;
determining, based on the second image and the first image, a second state of the target signal light in the first image;
wherein the determining, based on the second image and the first image, a second state of the target signal light in the first image includes:
determining the second state by processing, based on a trained second machine learning model, the second image and the first image, wherein the trained second machine learning model determines the second state based on information in a time domain of the target signal light in the first image and in the second image;
wherein the determining the second state by processing, based on the trained second machine learning model, the second image and the first image includes:
determining a state change of the target signal light from a time point when the second image is captured to a time point when the first image is captured by processing the second image and the first image based on the trained second machine learning model; and
determining, based on a target state of the target signal light at the time point when the second image is captured and the state change, the second state of the target signal light in the first image, including;
obtaining a first confidence level of the first state;
obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level; wherein the obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level includes:
in response to determining the state change is that a color of the target signal light does not change from the time point when the second image is captured to the time point when the first image is captured, determining a product of a confidence level of the target state corresponding to the target signal light at the time point when the second image is captured, the confidence level corresponding to the state change, and a preset second factor as the adjusted second confidence level; and
in response to determining the state change is that a color of the target signal light changes from the time point when the second image is captured to the time point when the first image is captured, determining an average value of the confidence level corresponding to the state change and the confidence level of the target state corresponding to the target signal light at the time point when the second image is captured as the adjusted second confidence level; and
determining, based on the first confidence level and one of the second confidence level and the adjusted second confidence level, the target state; and
determining, based on the first state and the second state, the target state of the target signal light at the time point when the first image is captured.
2 . The method of claim 1 , wherein the determining, based on the first image, a first state of the target signal light in the first image includes:
determining, based on a trained first machine learning model, the first state by processing the first image, wherein the first machine learning model determines the first state based on position information and color information of the target signal light in the first image.
3 . The method of claim 1 , wherein the determining, based on the first confidence level and one of the second confidence level and the adjusted second confidence level, the target state includes:
obtaining an adjusted first confidence level corresponding to the first state by adjusting the first confidence level; and
determining, based on the adjusted first confidence level and one of the second confidence level and the adjusted second confidence level, one of the first state and the second state as the target state of the target signal light at a time point when the first image is captured.
4 . The method of claim 3 , wherein the obtaining an adjusted first confidence level corresponding to the first state by adjusting the first confidence level includes:
determining a product of the first confidence level and a preset first factor as the adjusted first confidence level.
5 . The method of claim 1 , wherein the obtaining, based on a confidence level corresponding to the state change, one of a second confidence level of the second state and an adjusted second confidence level includes:
determining, based on the state change, a determination mode corresponding to one of the second confidence level and the adjusted second confidence level; and
determining, based on a confidence level of a target state corresponding to the target signal light at a time point when the second image is captured, the confidence level corresponding to the state change, and the determination mode, the second confidence level or the adjusted second confidence level.
6 . The method of claim 1 , wherein the determining, based on the first confidence level and one of the second confidence level and the adjusted second confidence level, the target state includes:
obtaining a first position of the target signal light in the first image through a trained first machine learning model;
determining a first comparison result by comparing the first position and a reference position; the reference position including reference coordinates or a reference box of the target signal light in the first image and the second image;
determining, based on the first comparison result, whether the first confidence level needs to be corrected;
in response to determining that the first confidence needs to be corrected, correcting the first confidence level to determine an adjusted first confidence level; and
determining, based on the adjusted first confidence level and one of the second confidence level and the adjusted second confidence level, the target state.
7 . The method of claim 1 , wherein the determining, based on the first confidence level and one of the second confidence level and the adjusted second confidence level, the target state includes:
obtaining a second position of the target signal light in the first image through the trained second machine learning model;
determining a second comparison result by comparing the second position and a reference position; the reference position including reference coordinates or a reference box of the target signal light in the first image and the second image;
determining, based on the second comparison result, whether the second confidence level needs to be corrected;
in response to determining that the second confidence needs to be corrected, correcting the second confidence level to determine a corrected second confidence level; and
determining, based on the first confidence level and the corrected second confidence level, the target state.
8 . The method of claim 6 , further comprising:
in response to a determination that the first confidence level needs to be corrected, correcting the first confidence level based on an intersection-over-union between the first position and the reference position; or
in response to a determination that the second confidence level needs to be corrected, correcting the second confidence level based on an intersection-over-union between the second position and the reference position.
9 . The method of claim 6 , wherein the reference position is determined by operations including:
obtaining a sample set including positions of the target signal light in a plurality of sample images captured within a preset time period, the preset time period being before a time point when the second image is captured;
obtaining, based on a clustering algorithm, a clustering result by clustering the positions of the target signal light in the plurality of sample images in the sample set; and
determining, based on the clustering result, the reference position.
10 . The method of claim 9 , wherein the obtaining, based on a clustering algorithm, a clustering result by clustering the positions of the target signal light in the plurality of sample images in the sample set includes:
determining, based on the sample set, an initialization reference position set and a radius, the initialization reference position set including one or more initialization reference positions;
determining, based on the initialization reference position set and the radius, an updated reference position set through a means clustering algorithm;
determining whether a termination condition is satisfied; and
in response to a determination that the termination condition is satisfied, obtaining the clustering result, wherein the clustering result includes the updated reference position set.
11 . The method of claim 9 , further comprising:
updating, based on a position of the target signal light in the first image and/or the second image, the sample set and the reference position.
12 . The method of claim 1 , further comprising:
performing a preprocessing operation on at least one of the first image or the second image, wherein the preprocessing operation includes at least one of:
performing color conversion on at least one of the first image or the second image; or
performing region of interest (ROI) extraction on at least one of the first image or the second image, wherein the region of interest includes a light panel region where the target signal light is located.
13 . The method of claim 12 , wherein the region of interest is larger than the light panel region.
14 . A device for detecting a signal light comprising a processor, a storage, and a communication circuit, wherein the processor is respectively coupled to the storage and the communication circuit, program data is stored in the storage, and the processor implements the method for detecting a signal light, the method including:
obtaining a first image and a second image previous to the first image in time sequence, wherein both the first image and the second image include a same target signal light;
determining, based on the first image, a first state of the target signal light in the first image;
determining, based on the second image and the first image, a second state of the target signal light in the first image;
wherein the determining, based on the second image and the first image, a second state of the target signal light in the first image includes:
determining the second state by processing, based on a trained second machine learning model, the second image and the first image, wherein the trained second machine learning model determines the second state based on information in a time domain of the target signal light in the first image and in the second image;
wherein the determining the second state by processing, based on the trained second machine learning model, the second image and the first image includes:
determining a state change of the target signal light from a time point when the second image is captured to a time point when the first image is captured by processing the second image and the first image based on the trained second machine learning model; and
determining, based on a target state of the target signal light at the time point when the second image is captured and the state change, the second state of the target signal light in the first image, including;
obtaining a first confidence level of the first state;
obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level; wherein the obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level includes: in response to determining the state change is that a color of the target signal light does not change from the time point when the second image is captured to the time point when the first image is captured, determining a product of a confidence level of the target state corresponding to the target signal light at the time point when the second image is captured, the confidence level corresponding to the state change, and a preset second factor as the adjusted second confidence level; and in response to determining the state change is that a color of the target signal light changes from the time point when the second image is captured to the time point when the first image is captured, determining an average value of the confidence level corresponding to the state change and the confidence level of the target state corresponding to the target signal light at the time point when the second image is captured as the adjusted second confidence level; and determining, based on the first confidence level and one of the second confidence level and the adjusted second confidence level, the target state; and
determining, based on the first state and the second state, the target state of the target signal light at the time point when the first image is captured.
15 . A computer-readable storage medium storing computer programs, wherein the computer programs are executed by a processor to implement the method for detecting a signal light, the method including:
obtaining a first image and a second image previous to the first image in time sequence, wherein both the first image and the second image include a same target signal light;
determining, based on the first image, a first state of the target signal light in the first image;
determining, based on the second image and the first image, a second state of the target signal light in the first image;
wherein the determining, based on the second image and the first image, a second state of the target signal light in the first image includes:
determining the second state by processing, based on a trained second machine learning model, the second image and the first image, wherein the trained second machine learning model determines the second state based on information in a time domain of the target signal light in the first image and in the second image;
wherein the determining the second state by processing, based on the trained second machine learning model, the second image and the first image includes:
determining a state change of the target signal light from a time point when the second image is captured to a time point when the first image is captured by processing the second image and the first image based on the trained second machine learning model; and
determining, based on a target state of the target signal light at the time point when the second image is captured and the state change, the second state of the target signal light in the first image, including;
obtaining a first confidence level of the first state;
obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level; wherein the obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level includes: in response to determining the state change is that a color of the target signal light does not change from the time point when the second image is captured to the time point when the first image is captured, determining a product of a confidence level of the target state corresponding to the target signal light at the time point when the second image is captured, the confidence level corresponding to the state change, and a preset second factor as the adjusted second confidence level; and in response to determining the state change is that a color of the target signal light changes from the time point when the second image is captured to the time point when the first image is captured, determining an average value of the confidence level corresponding to the state change and the confidence level of the target state corresponding to the target signal light at the time point when the second image is captured as the adjusted second confidence level; and
determining, based on the first confidence level and one of the second confidence level and the adjusted second confidence level, the target state; and
determining, based on the first state and the second state, the target state of the target signal light at the time point when the first image is captured.
16 . The method of claim 1 , wherein the obtaining, based on a confidence level corresponding to the state change, a second confidence level of the second state or an adjusted second confidence level includes:
determining a product of a confidence level of the target state corresponding to the target signal light at the time point when the second image is captured and the confidence level corresponding to the state change as the second confidence level of the second state; and
obtaining the adjusted second confidence level by adjusting the second confidence level based on a preset second factor.
17 . The method of claim 1 , wherein the obtaining, based on a confidence level corresponding to the result of state change, a second confidence level of the second state or an adjusted second confidence level includes:
in response to determining that the target signal light is on or when the target signal light is off, determining the confidence level corresponding to the state change as the adjusted second confidence level or the second confidence level.
18 . The method of claim 1 , wherein the trained second machine learning model includes a plurality of structural layers, a convolutional layer, an activation layer, a pooling layer, an upsampling layer, and a cascade operation.