Vehicle light detection method, device, electronic equipment and storage medium
By sub-region division and image binarization of the grayscale image detected by night lights, and combining the bright spot areas, the problem of failure of the night light detection model is solved, the reliability and applicability of the detection are improved, and applicable to different Camera and perspective.
Patent Information
- Application Number
- CN202111013275.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2025-01-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the dark night light, the headlight detection model is prone to failure, resulting in failure of the headlight detection. The prior art is difficult to adapt to different viewing angle algorithms of different cameras, affecting the reliability and applicability of the detection.
By obtaining the grayscale image to be detected, dividing it into multiple sub-regions, and image binarization is performed on each sub-region, combining the bright spots to obtain the headlight detection results, and replacing the model with night light brightness information, suitable for different Camera and perspective.
It improves the reliability and applicability of headlight detection, avoids detection failure caused by model failure, enhances detection accuracy and applicability, and is suitable for headlight detection of different cameras and viewing angles.
Smart Images

Figure CN113723304B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of vehicle light detection, and in particular to a vehicle light detection method, device, electronic device and storage medium. Background Art
[0002] With the increasing development and wide application of intelligent transportation system technology, vehicle light detection technology has also gradually developed. Among them, in the case of dim natural light such as at night, the vehicle can be determined by detecting the vehicle lights.
[0003] For night scenes, in the prior art, the headlight detection model can be used to detect the headlights. However, in dim light at night, the model may fail due to the influence of the lights of oncoming vehicles, making it impossible to effectively detect the headlights. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a vehicle light detection method, device, electronic device, and computer-readable storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a vehicle light detection method, comprising:
[0006] Obtain a grayscale image to be detected;
[0007] Dividing the grayscale image to be detected into a plurality of sub-regions;
[0008] Performing image binarization processing on the multiple sub-regions respectively to obtain a first bright spot region in each sub-region;
[0009] The multiple first bright spot areas are merged to obtain a headlight detection result; the headlight detection result is used to indicate the headlights belonging to the same target vehicle.
[0010] In the disclosed embodiment, the headlight brightness information at night is used to detect the headlights, replacing the model in the prior art, thereby avoiding the failure of headlight detection due to model failure, and improving the reliability of headlight detection. On the other hand, in the disclosed embodiment, since the grayscale image to be detected is divided into multiple sub-regions, and the multiple sub-regions are respectively subjected to image binarization processing, adaptive binarization processing of each sub-region is achieved, so that the method can be applied to different viewing angle algorithms of different cameras, that is, the adaptation problem of multi-camera multi-viewing angle algorithms is solved, thereby improving the applicability of the headlight detection method.
[0011] According to the first aspect, in a possible implementation manner, the size of the sub-region is positively correlated with the resolution of the grayscale image to be detected.
[0012] In the disclosed embodiment, since the size of the sub-region is positively correlated with the resolution of the grayscale image to be detected, each sub-region can be included in as many pixels as possible, so that after the sub-regions are binarized, each region has light and dark areas, which is beneficial to improving the detection accuracy of the vehicle lights.
[0013] According to the first aspect, in a possible implementation manner, performing image binarization processing on the multiple sub-regions respectively to obtain the first bright spot region in each sub-region includes:
[0014] Determine a brightness threshold corresponding to each sub-region according to the grayscale distribution in each sub-region;
[0015] Comparing the brightness value of the pixel points in each sub-region with the brightness threshold value corresponding to each sub-region to obtain the binarization processing result of each pixel point in each sub-region;
[0016] According to the binarization processing result of the pixel points in each sub-region, the first bright spot region in each sub-region is obtained.
[0017] In the disclosed embodiment, by comparing the brightness value of the pixel points in each of the sub-regions with the brightness threshold value corresponding to the sub-region, the brightness and darkness processing result of each pixel point can be obtained, wherein the area formed by the bright pixel points in each sub-region is the first bright spot area. In this way, the determination of the first bright spot area is achieved, and the method is relatively simple and can improve the efficiency of image processing.
[0018] According to the first aspect, in a possible implementation manner, merging the multiple first bright spot areas to obtain a vehicle light detection result includes:
[0019] Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that the distance between the boundaries of adjacent first bright spot regions is less than a preset threshold;
[0020] When the number of the first bright spot results is consistent with the number of the first bright spot regions, the vehicle light detection result is obtained based on the first bright spot results.
[0021] In the disclosed embodiment, by comparing the number of the first bright spot results with the number of the first bright spot areas, the accuracy of vehicle light detection can be improved.
[0022] According to the first aspect, in a possible implementation manner, merging the multiple first bright spot areas to obtain a vehicle light detection result includes:
[0023] Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that the distance between the boundaries of adjacent first bright spot regions is less than a preset threshold;
[0024] When the number of the first bright spot results is inconsistent with the number of the first bright spot areas, the first bright spot areas are adjusted to obtain new first bright spot areas, and multiple new first bright spot areas are merged according to the first preset condition to obtain new first bright spot results, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and the vehicle light detection result is obtained according to the latest first bright spot result.
[0025] In the embodiment of the present disclosure, when the number of the first bright spot results is inconsistent with the number of the first bright spot areas, the first bright spot results are iteratively optimized by an iterative optimization method, which can further improve the accuracy of vehicle light detection.
[0026] According to the first aspect, in a possible implementation manner, adjusting the first bright spot area to obtain a new first bright spot area includes:
[0027] Determine a first detection frame corresponding to the first bright spot area, wherein the first detection frame corresponding to a first bright spot area is a circumscribed rectangle of the first bright spot area;
[0028] Perform image binarization processing on the area within the first detection frame to obtain the new first bright spot area.
[0029] In the disclosed embodiment, the first bright spot area is binarized by using the first detection frame corresponding to the first bright spot area, so as to improve the processing efficiency.
[0030] According to the first aspect, in a possible implementation manner, the vehicle light detection result is obtained by using the following steps:
[0031] Determine whether the first bright spot result finally obtained satisfies a second preset condition, wherein the second preset condition means that the shape of the first bright spot result finally obtained meets a preset shape and / or the position of the first bright spot result finally obtained meets a preset position range;
[0032] When the first bright spot result finally obtained satisfies the second preset condition, the first bright spot result finally obtained is used as the vehicle light detection result.
[0033] In the disclosed embodiment, by comparing the finally obtained first bright spot result with the second preset condition, the first bright spot result that does not meet the second preset condition can be eliminated, which can further improve the accuracy of the vehicle light detection result.
[0034] According to the first aspect, in a possible implementation manner, the vehicle light detection result is obtained by using the following steps:
[0035] Based on the first bright spot result finally obtained, determining a second detection frame corresponding to the first bright spot result finally obtained; wherein the center point of the second detection frame coincides with the center point of the first bright spot result finally obtained;
[0036] The second detection frames belonging to the same target vehicle are combined to obtain the vehicle light detection result.
[0037] In the disclosed embodiment, based on the finally obtained first bright spot result, the second detection frame corresponding to the first bright spot result is determined, and the vehicle light detection result is annotated and output in the form of a detection frame, which can provide a clear detection result for the subsequent process.
[0038] According to the first aspect, in a possible implementation manner, acquiring the grayscale image to be detected includes:
[0039] Obtaining an original grayscale image corresponding to the acquired original image;
[0040] Performing cropping processing on the original grayscale image to obtain a target image;
[0041] The target image is subjected to noise reduction processing to obtain the grayscale image to be detected.
[0042] The disclosed embodiment can reduce the interference caused by nighttime noise information by graying, cropping and denoising the original image, which is beneficial to improving the accuracy of vehicle light detection.
[0043] According to the first aspect, in a possible implementation manner, after obtaining the vehicle light detection result, the method further includes:
[0044] Based on the vehicle light detection result, the light on state of the currently traveling vehicle equipped with the image acquisition device that acquires the original image is adjusted.
[0045] In the disclosed embodiment, after the vehicle light detection result is obtained, the light of the currently traveling vehicle is controlled based on the result, thereby improving the safety of nighttime driving.
[0046] In a second aspect, an embodiment of the present disclosure provides a vehicle light detection device, comprising:
[0047] An image acquisition module, used for acquiring a grayscale image to be detected;
[0048] A region division module, used for dividing the grayscale image to be detected into a plurality of sub-regions;
[0049] An image processing module, used for performing image binarization processing on the multiple sub-regions respectively to obtain a first bright spot region in each sub-region;
[0050] The vehicle light detection module is used to merge the multiple first bright spot areas to obtain a vehicle light detection result; the vehicle light detection result is used to indicate the vehicle lights belonging to the same target vehicle.
[0051] According to the second aspect, in a possible implementation manner, the size of the sub-region is positively correlated with the resolution of the grayscale image to be detected.
[0052] According to the second aspect, in a possible implementation manner, the image processing module is specifically used to:
[0053] Determine a brightness threshold corresponding to each sub-region according to the grayscale distribution in each sub-region;
[0054] Comparing the brightness value of the pixel points in each sub-region with the brightness threshold value corresponding to each sub-region to obtain the binarization processing result of each pixel point in each sub-region;
[0055] According to the binarization processing result of the pixel points in each sub-region, the first bright spot region in each sub-region is obtained.
[0056] According to the second aspect, in a possible implementation manner, the vehicle light detection module is specifically used to:
[0057] Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that the distance between the boundaries of adjacent first bright spot regions is less than a preset threshold;
[0058] When the number of the first bright spot results is consistent with the number of the first bright spot regions, the vehicle light detection result is obtained based on the first bright spot results.
[0059] According to the second aspect, in a possible implementation manner, the vehicle light detection module is specifically used to:
[0060] Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that the distance between the boundaries of adjacent first bright spot regions is less than a preset threshold;
[0061] When the number of the first bright spot results is inconsistent with the number of the first bright spot areas, the first bright spot areas are adjusted to obtain new first bright spot areas, and multiple new first bright spot areas are merged according to the first preset condition to obtain new first bright spot results, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and the vehicle light detection result is obtained according to the latest first bright spot result.
[0062] According to the second aspect, in a possible implementation manner, the vehicle light detection module is specifically used to:
[0063] Determine a first detection frame corresponding to the first bright spot area, wherein the first detection frame corresponding to a first bright spot area is a circumscribed rectangle of the first bright spot area;
[0064] Perform image binarization processing on the area within the first detection frame to obtain the new first bright spot area.
[0065] According to the second aspect, in a possible implementation manner, the vehicle light detection module is specifically used to:
[0066] Determine whether the first bright spot result finally obtained satisfies a second preset condition, wherein the second preset condition means that the shape of the first bright spot result finally obtained meets a preset shape and / or the position of the first bright spot result finally obtained meets a preset position range;
[0067] When the first bright spot result finally obtained satisfies the second preset condition, the first bright spot result finally obtained is used as the vehicle light detection result.
[0068] According to the second aspect, in a possible implementation manner, the vehicle light detection module is specifically used to:
[0069] Based on the first bright spot result finally obtained, determining a second detection frame corresponding to the first bright spot result finally obtained; wherein the center point of the second detection frame coincides with the center point of the first bright spot result finally obtained;
[0070] The second detection frames belonging to the same target vehicle are combined to obtain the vehicle light detection result.
[0071] According to the second aspect, in a possible implementation manner, the image acquisition module is specifically used to:
[0072] Obtaining an original grayscale image corresponding to the acquired original image;
[0073] Performing cropping processing on the original grayscale image to obtain a target image;
[0074] The target image is subjected to noise reduction processing to obtain the grayscale image to be detected.
[0075] According to the second aspect, in a possible implementation manner, the device further includes:
[0076] The light control module is used to adjust the light-on state of the current moving vehicle equipped with the image acquisition device that acquires the original image based on the vehicle light detection result.
[0077] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the vehicle light detection method as described in the first aspect and any one of the embodiments of the first aspect is performed.
[0078] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the vehicle light detection method as described in the first aspect and any one of the embodiments of the first aspect is executed.
[0079] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0081] Figure 1 A flow chart of a vehicle light detection method provided by an embodiment of the present disclosure is shown;
[0082] Figure 2 A schematic diagram of a currently traveling vehicle and a target vehicle provided by an embodiment of the present disclosure is shown;
[0083] Figure 3 A schematic diagram of dividing a grayscale image to be detected into multiple sub-areas provided by an embodiment of the present disclosure is shown;
[0084] Figure 4A flow chart of a method for performing image binarization processing on multiple sub-regions respectively provided by an embodiment of the present disclosure is shown;
[0085] Figure 5 A schematic diagram showing a sub-region image binarization process provided by an embodiment of the present disclosure is shown;
[0086] Figure 6 A flow chart of a method for merging a plurality of first bright spot areas to obtain a vehicle light detection result provided by an embodiment of the present disclosure is shown;
[0087] Figure 7 A flow chart of another vehicle light detection method provided by an embodiment of the present disclosure is shown;
[0088] Figure 8 A schematic diagram of the structure of a vehicle light detection device provided by an embodiment of the present disclosure is shown;
[0089] Fig. 9 A schematic diagram showing the structure of another vehicle light detection device provided by an embodiment of the present disclosure is shown;
[0090] Fig.10 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0091] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0092] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0093] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0094] With the increasing development and widespread application of intelligent transportation system technology, vehicle automatic detection technology has also gradually developed. Among them, in the case of dim natural light such as night, the vehicle can be determined by detecting the vehicle lights.
[0095] Through research, it is found that for night scenes, the headlight detection model can be used to detect the headlights. However, in the case of dim light at night, the model will fail due to the influence of the lights of oncoming vehicles, resulting in poor reliability of headlight detection. Therefore, how to improve the reliability of headlight detection at night is a technical problem to be solved by the present disclosure.
[0096] Based on the above research, the present disclosure provides a vehicle headlight detection method, which obtains a grayscale image to be detected; divides the grayscale image to be detected into multiple sub-areas; performs image binarization processing on the multiple sub-areas respectively to obtain a first bright spot area in each sub-area; merges the multiple first bright spot areas to obtain a vehicle headlight detection result; the vehicle headlight detection result is used to indicate the vehicle headlights belonging to the same target vehicle.
[0097] In the disclosed embodiment, the headlight brightness information at night is used to detect the headlights, replacing the model in the prior art, thereby avoiding the failure of headlight detection due to model failure, and improving the reliability of headlight detection. On the other hand, in the disclosed embodiment, since the grayscale image to be detected is divided into multiple sub-regions, and the multiple sub-regions are respectively subjected to image binarization processing, adaptive binarization processing of each sub-region is achieved, so that the method can be applied to different viewing angle algorithms of different cameras, that is, the adaptation problem of multi-camera multi-viewing angle algorithms is solved, thereby improving the applicability of the headlight detection method.
[0098] To facilitate understanding of the embodiments of the present application, the present application scheme is described in detail below in conjunction with specific embodiments. The execution subject of the vehicle light detection method provided in the embodiments of the present disclosure is generally an electronic device with certain computing capabilities, and the electronic device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a mobile device, a user terminal, a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the vehicle light detection method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0099] See also Figure 1 FIG. 1 is a flow chart of a vehicle light detection method provided by an embodiment of the present disclosure. The vehicle light detection method includes the following S101 to S104:
[0100] S101, obtaining a grayscale image to be detected.
[0101] For example, see Figure 2 As shown in FIG. 1 , a schematic diagram of a currently traveling vehicle and a target vehicle provided by an embodiment of the present disclosure is shown. Figure 2 As shown, the current vehicle 100 is traveling in lane L1, and an image acquisition device (such as a camera) 110 is installed on the current vehicle 100 to obtain environmental image information around the current vehicle 100. The target vehicle 200 is traveling in the opposite lane L2 of the lane L1, and the target vehicle 200 includes a pair of headlights 210. In this embodiment, the current vehicle 100 and the target vehicle 200 are traveling towards each other. At this time, the image acquisition device 110 can capture image information including the target vehicle 200. By processing and analyzing the image information, the headlights 210 on the target vehicle 200 can be detected, and then the position of the target vehicle 200 can be determined by the headlights 210.
[0102] Exemplarily, the original image captured by the image acquisition device 110 may be acquired, and then the original image may be preprocessed to obtain the grayscale image to be detected. The preprocessing of the original image may specifically include: performing grayscale processing on the original image to obtain an original grayscale image, then cropping the original grayscale image to obtain a target image, and then performing noise reduction processing on the target image to obtain the grayscale image to be detected.
[0103] For example, if the original image captured by the image acquisition device is a color image, the original image can be first gray-scale processed to obtain an original gray-scale image corresponding to the original image, and then the original gray-scale image can be cropped to obtain a target image. For example, the area above the skyline (such as the sky) and the street lamp area in the original gray-scale image can be cropped to obtain a target image, and then the target image is filtered and denoised using a Gaussian filter to reduce the noise information of the target image at night, thereby obtaining a gray-scale image to be detected.
[0104] In some embodiments, in order to improve the processing efficiency of noise reduction, the grayscale image to be detected can be subjected to regional noise reduction, that is, the region of interest (ROI) in the grayscale image to be detected can be determined first, and then the ROI is subjected to noise reduction processing. In this embodiment, the ROI can be a region including the target vehicle.
[0105] It should be noted that the vehicle lights in the embodiments of the present disclosure include but are not limited to lighting lamps, signal indicator lights, etc. on various forms of equipment.
[0106] S102: Divide the grayscale image to be detected into multiple sub-areas.
[0107] Exemplarily, in order to implement adaptive binarization processing, the grayscale image to be detected needs to be divided into a plurality of sub-regions, so that image binarization processing can be performed on each sub-region respectively.
[0108] See also Figure 3 As shown, it is a schematic diagram after dividing the grayscale image to be detected into multiple sub-areas. In some implementations, the grayscale image A to be detected can be divided according to a preset division method to obtain multiple sub-areas A1. The preset division method can be uniformly divided according to the image size, and the uniform division means that the size of each sub-area is the same. The preset division method can also be random division, that is, after random division, the size of each sub-area may be the same or different, which is not limited here.
[0109] It should be noted that, in order to facilitate subsequent calculations, in this embodiment, the shape of each sub-region is rectangular. Of course, in other embodiments, the shape of each sub-region may also be other shapes (such as triangle), which is not limited here.
[0110] In some embodiments, the size of the sub-region is positively correlated with the resolution of the grayscale image to be detected, so that each sub-region can include as many pixels as possible, and after the sub-regions are binarized, each region has light and dark areas, which is beneficial to improving the detection accuracy of the vehicle lights.
[0111] S103, performing image binarization processing on the multiple sub-regions respectively to obtain a first bright spot region in each sub-region.
[0112] Among them, image binarization is the process of setting the grayscale value of the pixel points on the image to 0 or 255, that is, making the entire image present an obvious black and white effect.
[0113] For example, see Figure 4 As shown, with respect to step S103, when performing image binarization processing on the plurality of sub-regions respectively to obtain the first bright spot region in each sub-region, the following steps S1031 to S1034 may be included:
[0114] S1031, determining a brightness threshold corresponding to each sub-region according to the grayscale distribution in each sub-region.
[0115] The brightness threshold may be determined by a bimodal method, a maximum inter-class variance method (such as Otsu's method), a maximum entropy threshold method, an iterative method, and the like, without any specific limitation.
[0116] S1032, comparing the brightness value of the pixel points in each sub-region with the brightness threshold value corresponding to each sub-region to obtain a binarization result of each pixel point in each sub-region.
[0117] S1033: Obtain a first bright spot region in each sub-region according to a binarization processing result of the pixel points in each sub-region.
[0118] For example, see Figure 5 As shown in FIG. 1 , it is a schematic diagram of the sub-region after the image binarization processing is performed on the sub-region, and the brightness value of the pixel point in each of the sub-regions is compared with the brightness threshold value corresponding to the sub-region to obtain the processing result of the bright spot (white point in the figure) or dark spot (black point in the figure) of each pixel point. The bright spot in each sub-region A1 forms the first bright spot region B corresponding to each sub-region, that is, the region formed by the pixel points whose brightness value in each sub-region is greater than the brightness threshold value is determined as the first bright spot region B corresponding to each sub-region.
[0119] S104, merging the multiple first bright spot areas to obtain a vehicle headlight detection result; the vehicle headlight detection result is used to indicate vehicle heads belonging to the same target vehicle.
[0120] It can be understood that since step S102 has divided the grayscale image to be detected into multiple sub-regions, after obtaining the first bright spot regions corresponding to the multiple sub-regions, the first bright spot regions corresponding to the multiple sub-regions need to be merged to obtain the vehicle light detection result.
[0121] In the disclosed embodiment, the headlight brightness information at night is used to detect the headlights, replacing the model in the prior art, thereby avoiding the failure of headlight detection due to model failure, and improving the reliability of headlight detection. On the other hand, in the disclosed embodiment, since the grayscale image to be detected is divided into multiple sub-regions, and the multiple sub-regions are respectively subjected to image binarization processing, adaptive binarization processing of each sub-region is achieved, so that the method can be applied to different viewing angle algorithms of different cameras, that is, the adaptation problem of multi-camera multi-viewing angle algorithms is solved, thereby improving the applicability of the headlight detection method.
[0122] The above S104 will be described in detail below in conjunction with specific embodiments.
[0123] With respect to the above S104, when a plurality of first bright spot regions are merged to obtain a vehicle light detection result, as Figure 6 As shown, it includes the following S1041~S1044:
[0124] S1041, merging a plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that a distance between boundaries of adjacent first bright spot regions is less than a preset threshold.
[0125] Please refer again Figure 5 After obtaining the first bright spot regions B corresponding to the multiple sub-regions respectively, the multiple first bright spot regions B need to be merged. Since when the grayscale image is divided as mentioned above, the region belonging to the same headlight may be divided into multiple sub-regions, and the multiple sub-regions belonging to the same headlight must be adjacent sub-regions, therefore, the adjacent first bright spot regions B whose boundary distance is less than a preset threshold can be merged, wherein the preset threshold can be set according to the actual situation and is not limited here.
[0126] S1042, determining whether the number of the first bright spot results is consistent with the number of the first bright spot regions; if so, executing step S1043; if not, executing step S1044.
[0127] It can be understood that if the number of the merged first bright spot results is the same as the number of the first bright spot regions, it means that the first bright spot regions currently obtained are relatively complete bright spot regions and no further merging is required, and if the number of the merged first bright spot results is different from the number of the first bright spot regions, it means that the first bright spot regions currently obtained are relatively incomplete and still need to be further merged, thereby improving the detection accuracy.
[0128] S1043: Obtain the vehicle light detection result based on the first bright spot result.
[0129] In some implementations, the vehicle light detection result may be determined directly based on the obtained first bright spot result. For example, if two first bright spot results are obtained, the two first bright spot results may be directly used as the vehicle light detection result.
[0130] S1044, adjusting the first bright spot area to obtain a new first bright spot area, and merging multiple new first bright spot areas according to the first preset condition to obtain a new first bright spot result, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and obtaining the vehicle light detection result according to the latest first bright spot result.
[0131] The first bright spot area is adjusted to obtain a new first bright spot area, including the following (1) to (2):
[0132] (1) determining a first detection frame corresponding to the first bright spot area, wherein the first detection frame corresponding to a first bright spot area is a circumscribed rectangle of the first bright spot area;
[0133] (2) Performing image binarization processing on the area within the first detection frame to obtain a new first bright spot area.
[0134] Then, the new first bright spot result is returned as the first bright spot result to execute S1042 and S1043 until the number of the first bright spot results finally obtained is consistent with the number of the first bright spot regions.
[0135] Exemplarily, since a rectangular area is conducive to image binarization processing, in this embodiment, a first detection frame corresponding to the first bright spot area is first determined, and then image binarization processing is performed on the area corresponding to the first detection frame.
[0136] In the embodiment of the present disclosure, when the number of first bright spot results is inconsistent with the number of the first bright spot areas, the first bright spot areas obtained above are iteratively optimized to obtain new first bright spot areas, and multiple new first bright spot areas are merged according to the first preset condition to obtain new first bright spot results, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and the vehicle light detection result is obtained based on the latest first bright spot result, so that the accuracy of the vehicle light detection result can be improved.
[0137] In some implementations, in order to further improve the accuracy of the vehicle light detection result, it is also possible to determine whether the last obtained first bright spot result satisfies a second preset condition, and if the last obtained first bright spot result satisfies the second preset condition, the last obtained first bright spot result is used as the vehicle light detection result. Here, the last obtained first bright spot result is also the latest first bright spot result.
[0138] The second preset condition means that the shape of the first bright spot result finally obtained conforms to the preset shape and / or the position of the first bright spot result finally obtained conforms to the preset position range. For example, the shape of a car light may be circular or an arc of a line, while the shapes of other halos may be irregular. Therefore, by comparing the first bright spot result finally obtained with the preset shape, some first bright spot results that do not conform to the shape can be eliminated.
[0139] In other embodiments, the second detection frame corresponding to the last obtained first bright spot result can also be determined based on the last obtained first bright spot result; wherein the center point of the second detection frame coincides with the center point of the last obtained first bright spot result; and the second detection frames belonging to the same target vehicle are combined to obtain the headlight detection result.
[0140] Exemplarily, the second detection frame can be determined based on the position of the center point of the last obtained first bright spot result on the grayscale image and the preset detection frame ratio. The center point of the second detection frame coincides with the center point of the last obtained first bright spot result. The preset detection frame ratio can be 1:2 or 3:4, which is not limited here. The short side of the second detection frame matches the short side of the inscribed rectangle of the last obtained first bright spot result. After obtaining the second detection frame, the second detection frames belonging to the same target vehicle are combined and merged to obtain the headlight detection result. It can be understood that the two headlights belonging to the same target vehicle are consistent with the height, shape and size of the ground in the grayscale image.
[0141] See also Figure 7 As shown, it is a flowchart of another vehicle light detection method provided by the embodiment of the present disclosure. Figure 1 The method in is different in that after step S104, the following S105 is also included:
[0142] S105, based on the vehicle light detection result, adjusting the light on state of the current moving vehicle equipped with the image acquisition device that acquires the original image.
[0143] The light-on state includes at least one of turning on the high beam, turning on the low beam, or turning on the high beam and the low beam alternately.
[0144] Please refer again Figure 2 After obtaining the vehicle light detection result, the position of the target vehicle 200 relative to the currently traveling vehicle 100 can be determined, and then the lights of the currently traveling vehicle 100 can be adjusted. For example, if the target vehicle 200 is closer to the currently traveling vehicle 100, the low beam should be turned on, and if the target vehicle 200 is farther away from the currently traveling vehicle 100, the high beam can be turned on.
[0145] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0146] Based on the same technical concept, a vehicle headlight detection device corresponding to the vehicle headlight detection method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned vehicle headlight detection method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0147] Reference Figure 8 FIG. 1 is a schematic diagram of a vehicle light detection device 500 provided in an embodiment of the present disclosure, and the vehicle light detection device 500 includes:
[0148] An image acquisition module 501 is used to acquire a grayscale image to be detected;
[0149] A region division module 502, used for dividing the grayscale image to be detected into a plurality of sub-regions;
[0150] An image processing module 503 is used to perform image binarization processing on the multiple sub-regions respectively to obtain a first bright spot region in each sub-region;
[0151] The vehicle light detection module 504 is used to merge the multiple first bright spot areas to obtain a vehicle light detection result; the vehicle light detection result is used to indicate the vehicle lights belonging to the same target vehicle.
[0152] In a possible implementation manner, the size of the sub-region is positively correlated with the resolution of the grayscale image to be detected.
[0153] In a possible implementation manner, the image processing module 503 is specifically configured to:
[0154] Determine a brightness threshold corresponding to each sub-region according to the grayscale distribution in each sub-region;
[0155] Comparing the brightness value of the pixel points in each sub-region with the brightness threshold value corresponding to each sub-region to obtain the binarization processing result of each pixel point in each sub-region;
[0156] According to the binarization processing result of the pixel points in each sub-region, the first bright spot region in each sub-region is obtained.
[0157] In a possible implementation manner, the vehicle light detection module 504 is specifically used for:
[0158] Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that the distance between the boundaries of adjacent first bright spot regions is less than a preset threshold;
[0159] When the number of the first bright spot results is consistent with the number of the first bright spot regions, the vehicle light detection result is obtained based on the first bright spot results.
[0160] In a possible implementation manner, the vehicle light detection module 504 is specifically used for:
[0161] Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; the first preset condition is that the distance between the boundaries of adjacent first bright spot regions is less than a preset threshold;
[0162] When the number of the first bright spot results is inconsistent with the number of the first bright spot areas, the first bright spot areas are adjusted to obtain new first bright spot areas, and multiple new first bright spot areas are merged according to the first preset condition to obtain new first bright spot results, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and the vehicle light detection result is obtained according to the latest first bright spot result.
[0163] In a possible implementation manner, the vehicle light detection module 504 is specifically used for:
[0164] Determine a first detection frame corresponding to the first bright spot area, wherein the first detection frame corresponding to a first bright spot area is a circumscribed rectangle of the first bright spot area;
[0165] Perform image binarization processing on the area within the first detection frame to obtain the new first bright spot area.
[0166] In a possible implementation manner, the vehicle light detection module 504 is specifically used for:
[0167] Determine whether the first bright spot result finally obtained satisfies a second preset condition, wherein the second preset condition means that the shape of the first bright spot result finally obtained meets a preset shape and / or the position of the first bright spot result finally obtained meets a preset position range;
[0168] When the first bright spot result finally obtained satisfies the second preset condition, the first bright spot result finally obtained is used as the vehicle light detection result.
[0169] In a possible implementation manner, the vehicle light detection module 504 is specifically used for:
[0170] Based on the first bright spot result finally obtained, determining a second detection frame corresponding to the first bright spot result finally obtained; wherein the center point of the second detection frame coincides with the center point of the first bright spot result finally obtained;
[0171] The second detection frames belonging to the same target vehicle are combined to obtain the vehicle light detection result.
[0172] In a possible implementation manner, the image acquisition module 501 is specifically used for:
[0173] Obtaining an original grayscale image corresponding to the acquired original image;
[0174] Performing cropping processing on the original grayscale image to obtain a target image;
[0175] The target image is subjected to noise reduction processing to obtain the grayscale image to be detected.
[0176] See also Fig. 9 As shown, in a possible implementation manner, the device further includes:
[0177] The light control module 505 is used to adjust the light on state of the current moving vehicle equipped with the image acquisition device that acquires the original image based on the vehicle light detection result.
[0178] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0179] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Fig.10 , which is a schematic diagram of the structure of an electronic device 700 provided in an embodiment of the present disclosure, including a processor 701, a memory 702, and a bus 703. The memory 702 is used to store execution instructions, including a memory 7021 and an external memory 7022; the memory 7021 is also called an internal memory, which is used to temporarily store the operation data in the processor 701 and the data exchanged with the external memory 7022 such as a hard disk. The processor 701 exchanges data with the external memory 7022 through the memory 7021.
[0180] In the embodiment of the present application, the memory 702 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 701. That is, when the electronic device 700 is running, the processor 701 communicates with the memory 702 through the bus 703, so that the processor 701 executes the application code stored in the memory 702, and then executes the method in any of the aforementioned embodiments.
[0181] The processor 701 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0182] Among them, the memory 702 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0183] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 700. In other embodiments of the present application, the electronic device 700 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0184] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the vehicle light detection method in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0185] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the vehicle light detection method in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0186] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0187] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0188] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0189] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0190] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0191] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A vehicle light detection method, characterized in that: include: Obtain a grayscale image to be detected; Dividing the grayscale image to be detected into a plurality of sub-regions; Performing image binarization processing on the multiple sub-regions respectively to obtain a first bright spot region in each sub-region; Merging the plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; The first preset condition means that the distance between the boundaries of adjacent first bright spot areas is less than a preset threshold; When the number of the first bright spot results is inconsistent with the number of the first bright spot regions, determining a first detection frame corresponding to the first bright spot region, wherein a first detection frame corresponding to the first bright spot region is a circumscribed rectangle of the first bright spot region; Performing image binarization processing on the area within the first detection frame to obtain a new first bright spot area; Merge multiple new first bright spot areas according to the first preset condition to obtain new first bright spot results, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and obtain a headlight detection result based on the latest first bright spot result; the headlight detection result is used to indicate the headlights belonging to the same target vehicle.
2. The method according to claim 1, characterized in that The size of the sub-region is positively correlated with the resolution of the grayscale image to be detected.
3. The method according to claim 1 or 2, characterized in that: The performing image binarization processing on the multiple sub-regions respectively to obtain the first bright spot region in each sub-region comprises: Determine a brightness threshold corresponding to each sub-region according to the grayscale distribution in each sub-region; Comparing the brightness value of the pixel points in each sub-region with the brightness threshold value corresponding to each sub-region to obtain the binarization processing result of each pixel point in each sub-region; According to the binarization processing result of the pixel points in each sub-region, the first bright spot region in each sub-region is obtained.
4. The method according to claim 1, characterized in that: The method further comprises: When the number of the first bright spot results is consistent with the number of the first bright spot regions, the vehicle light detection result is obtained based on the first bright spot results.
5. The method according to claim 1, characterized in that The vehicle light detection result is obtained by adopting the following steps: Determine whether the first bright spot result finally obtained satisfies a second preset condition, wherein the second preset condition means that the shape of the first bright spot result finally obtained meets a preset shape and / or the position of the first bright spot result finally obtained meets a preset position range; When the first bright spot result finally obtained satisfies the second preset condition, the first bright spot result finally obtained is used as the vehicle light detection result.
6. The method according to claim 1, characterized in that The vehicle light detection result is obtained by adopting the following steps: Based on the first bright spot result finally obtained, determining a second detection frame corresponding to the first bright spot result finally obtained; wherein the center point of the second detection frame coincides with the center point of the first bright spot result finally obtained; The second detection frames belonging to the same target vehicle are combined to obtain the vehicle light detection result.
7. The method according to claim 1, characterized in that The step of obtaining a grayscale image to be detected comprises: Obtaining an original grayscale image corresponding to the acquired original image; Performing cropping processing on the original grayscale image to obtain a target image; The target image is subjected to noise reduction processing to obtain the grayscale image to be detected.
8. The method according to claim 1, characterized in that After obtaining the vehicle light detection result, the method further includes: Based on the vehicle light detection result, the light on state of the currently traveling vehicle equipped with the image acquisition device for acquiring the original image is adjusted.
9. A vehicle light detection device, characterized in that: include: An image acquisition module, used for acquiring a grayscale image to be detected; A region division module, used for dividing the grayscale image to be detected into a plurality of sub-regions; An image processing module, used for performing image binarization processing on the multiple sub-regions respectively to obtain a first bright spot region in each sub-region; A vehicle light detection module, configured to merge a plurality of first bright spot regions according to a first preset condition to obtain a first bright spot result; The first preset condition means that the distance between the boundaries of adjacent first bright spot areas is less than a preset threshold; When the number of the first bright spot results is inconsistent with the number of the first bright spot regions, determining a first detection frame corresponding to the first bright spot region, wherein the first detection frame corresponding to a first bright spot region is a circumscribed rectangle of the first bright spot region; Performing image binarization processing on the area within the first detection frame to obtain a new first bright spot area; Merge multiple new first bright spot areas according to the first preset condition to obtain new first bright spot results, until the number of the new first bright spot results is consistent with the number of the new first bright spot areas, and obtain a headlight detection result based on the latest first bright spot result; the headlight detection result is used to indicate the headlights belonging to the same target vehicle.
10. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, the processor and the memory communicate via the bus, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the vehicle light detection method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the vehicle light detection method according to any one of claims 1 to 8 are executed.