Street lamp on-off detection method and device
By combining target detection models and grayscale statistical parameters, the problems of high cost and low accuracy in street light on/off detection are solved, achieving efficient and accurate detection in diverse scenarios and perspectives, reducing labor costs and improving the versatility and convenience of detection.
Patent Information
- Application Number
- CN202410558882.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-07
- Publication Date
- 2025-11-11
AI Technical Summary
Existing methods for detecting streetlight illumination have drawbacks such as high labor costs, low accuracy, poor versatility and convenience, and are particularly ineffective in diverse scenarios and under different camera perspectives.
A pre-set target detection model is used to identify streetlights, and the on/off state is determined by grayscale statistical parameters. The system uses a large visual model and descriptive words to detect streetlights, and combines grayscale statistical parameter thresholds to determine whether the streetlights are on or off, thereby reducing labor costs and improving detection accuracy and versatility.
It enables efficient and accurate detection of street light on/off status under different scenarios and camera perspectives, reducing labor costs and eliminating the need for prior manual ROI calibration, thus exhibiting good generalization ability and convenience.
Smart Images

Figure CN120932164A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of street light detection technology, and in particular to a method and apparatus for detecting whether a street light is on or off. Background Technology
[0002] The main purpose of street light night scene analysis is to monitor street lights at night to detect their on / off status. One existing method for street light night scene analysis is based on training a small deep learning model. Training this model requires developers to annotate image materials from different nighttime scenes as a training set, resulting in high manpower costs. Since the uploaded images are mostly from sunny days, this small model is relatively accurate in judging the on / off status of street lights in sunny conditions. However, in rainy conditions, or when the scene changes slightly, such as with bent tree branches (which may be misidentified as street lights or obstruct their view), the accuracy drops significantly. Furthermore, collecting diverse scene materials is difficult, causing the model to only have good recognition performance for a few specific scenes. Moreover, the varying styles of streetlights and the different shooting distances and angles make the small model unromantic to changes in viewing angle and streetlight shape. If the number of cameras needs to be increased, a large amount of new material needs to be collected.
[0003] Another method for analyzing streetlight night scenes uses traditional computer vision algorithms. This requires setting preset positions for the cameras to lock onto a pre-selected region of interest (ROI) containing the streetlights in the image, thus determining the streetlights' on / off status. If the client changes the monitoring view, they need to restore the ROI by recalling the preset positions, which is complex and limited by the accuracy of preset position restoration. If the camera is far from the streetlight target, the ROI may drift due to vibration or other factors. Furthermore, the ROI at a fixed streetlight location in the monitoring image lacks universality; adding new cameras requires modifying the configuration file and reconfiguring the ROI.
[0004] In summary, solutions based on self-trained small models require a large number of manually labeled training samples, resulting in very high labor costs. Furthermore, their detection accuracy for scenes not present in the training set is low, and their generalization ability is not guaranteed. While methods based on traditional visual algorithms do not require training or labeling, the process of setting preset positions, manually specifying the Region of Interest (ROI), and reconstructing the ROI image using these preset positions is complex and lacks versatility and convenience. Therefore, developing a street light on / off detection method that boasts high accuracy, low labor costs, and good versatility and convenience is a pressing technical challenge. Summary of the Invention
[0005] This invention provides a method and apparatus for detecting the on / off state of streetlights, in order to solve the aforementioned technical problems existing in the prior art.
[0006] This invention provides a method for detecting the on / off state of streetlights, comprising:
[0007] The image to be detected is input into a preset target detection model to obtain a street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset prompts describing street lights and output the street light detection box.
[0008] Calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame;
[0009] Based on the grayscale statistical parameters, the on / off state of the streetlight corresponding to the streetlight detection frame is determined.
[0010] According to the street light on / off detection method provided by the present invention, determining the on / off state of the street light corresponding to the street light detection frame based on the grayscale statistical parameters includes:
[0011] The grayscale statistical parameters are compared with the grayscale statistical parameter threshold. If the grayscale statistical parameters are less than the grayscale statistical parameter threshold, it is determined that the street light corresponding to the street light detection box is off. The grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the target area within the street light detection box in the sample image of the street light being lit.
[0012] According to the street light on / off detection method provided by the present invention, for the detection scene corresponding to the image to be detected, the gray-scale statistical parameter threshold is set based on the gray-scale statistical parameters of the pixels in the target area within the street light detection box in the sample image of the street light being lit in the detection scene.
[0013] According to the street light on / off detection method provided by the present invention, in the detection scene corresponding to the image to be detected, each street light detection box in the image to be detected corresponds to a grayscale statistical parameter threshold. For each street light detection box, the corresponding grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the target area within the corresponding street light detection box in the sample image where the street light is lit in the detection scene.
[0014] The comparison of the grayscale statistical parameter with a grayscale statistical parameter threshold, and the determination that the streetlight corresponding to the streetlight detection frame is off when the grayscale statistical parameter is less than the grayscale statistical parameter threshold, includes:
[0015] For any street light detection box in the image to be detected, obtain the grayscale statistical parameter threshold corresponding to any street light detection box;
[0016] The grayscale statistical parameter corresponding to any street light detection frame is compared with the corresponding grayscale statistical parameter threshold. If the corresponding grayscale statistical parameter is less than the corresponding grayscale statistical parameter threshold, it is determined that the street light corresponding to any street light detection frame is off.
[0017] According to the street light on / off detection method provided by the present invention, the threshold of the grayscale statistical parameter is determined according to the following formula:
[0018] Th = a × G
[0019] Where Th represents the gray-level statistical parameter threshold, G represents the gray-level statistical parameter of the target region pixels within the street light detection box in the sample image based on the street light being lit, and a represents the weighting coefficient, with a value of 0.7 to 0.9.
[0020] According to the street light on / off detection method provided by the present invention, the step of calculating the grayscale statistical parameters of the pixels in the target area within the street light detection frame includes:
[0021] The pixels in the upper region of the street light detection frame are extracted as the target region pixels, where the upper region refers to the region including the street light head;
[0022] Calculate the grayscale statistical parameters of the pixels in the target region.
[0023] According to the street light on / off detection method provided by the present invention, the calculation of grayscale statistical parameters of the pixels in the target area includes:
[0024] The grayscale of the target region pixel is compared with a preset second grayscale statistical parameter threshold, and the pixel whose grayscale is greater than the second grayscale statistical parameter threshold is the target pixel. The second grayscale statistical parameter threshold is set based on the grayscale difference between the street lamp body pixel and the background pixel in the street lamp detection frame.
[0025] Calculate the grayscale statistical parameters of the target pixel.
[0026] According to the street light on / off detection method provided by the present invention, the threshold value of the second grayscale statistical parameter is 170 to 210 in the grayscale level specification of 0 to 255.
[0027] According to the street light on / off detection method provided by the present invention, the step of calculating the grayscale statistical parameters of the pixels in the target area within the street light detection frame includes:
[0028] The image to be detected is input into a preset target segmentation model to obtain a street lamp mask output by the target segmentation model. The target segmentation model is used to segment street lamps from the image to be detected based on the prompts describing street lamps and output the street lamp mask.
[0029] The upper region within the street light detection frame is selected, and the upper region refers to the area including the street light head;
[0030] The grayscale statistical parameters are calculated using the pixels within the streetlight mask area in the upper region as the target region pixels.
[0031] According to the street light on / off detection method provided by the present invention, the step of inputting the image to be detected into a preset target detection model includes:
[0032] If the image to be detected is an image taken during a set nighttime period, the image to be detected is input into a preset target detection model.
[0033] According to the street light on / off detection method provided by the present invention, after determining the on / off state of the street light corresponding to the street light detection frame based on the grayscale statistical parameters, the method further includes:
[0034] Based on the preset correspondence between street light detection frame ID and street light ID, determine the street light ID of the extinguished street light corresponding to the street light detection frame of the extinguished street light;
[0035] Output the street light ID that is turned off and the street light information corresponding to the street light ID.
[0036] According to the street light on / off detection method provided by the present invention, the target detection model includes a large visual model.
[0037] The present invention also provides a street light on / off detection device, comprising:
[0038] The street light recognition module is used to input the image to be detected into a preset target detection model to obtain the street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected according to preset prompts describing street lights, and output the street light detection box.
[0039] The grayscale calculation module is used to calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame;
[0040] The street light status determination module is used to determine the on / off status of the street light corresponding to the street light detection frame based on the grayscale statistical parameters.
[0041] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the street light on / off detection method as described above.
[0042] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the street light on / off detection method as described in any of the preceding claims.
[0043] The present invention provides a street light on / off detection method and apparatus. By inputting the image to be detected into a preset target detection model, a street light detection box is obtained output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset descriptive words describing the street lights, and outputs the street light detection box. The grayscale statistical parameters of the pixels in the target area within the street light detection box are calculated. Based on the grayscale statistical parameters, the on / off state of the street light corresponding to the street light detection box is determined. Because a preset target detection model and descriptive words describing the street lights are used, street lights can be accurately identified from the image to be detected, and a street light detection box can be obtained. Training the target detection model is not required, reducing labor costs. Furthermore, the on / off state of the street light is determined based on the grayscale statistical parameters of the pixels in the target area within the accurately identified street light detection box. While ensuring accurate determination of the on / off state of the street light, it does not require prior manual calibration of the ROI, exhibiting good versatility and convenience, and demonstrating good generalization ability for various street light shapes and distances from the camera. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0045] Figure 1 This is one of the flowcharts of the street light on / off detection method provided by the present invention;
[0046] Figure 2 This is the second flowchart of the street light on / off detection method provided by the present invention;
[0047] Figure 3 This is the third flowchart of the street light on / off detection method provided by the present invention;
[0048] Figure 4 This is the fourth flowchart of the street light on / off detection method provided by the present invention;
[0049] Figure 5 This is a schematic diagram of the street light on / off detection device provided by the present invention;
[0050] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0052] The street light on / off detection method of this invention, as described in the embodiments, is as follows: Figure 1 As shown, it includes the following steps:
[0053] Step S110: Input the image to be detected into a preset target detection model to obtain the street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset prompts describing street lights, and output the street light detection box. The image to be detected can be a video frame of a nighttime street light video captured by a camera. In practical applications, the camera captures night scene video, and the field of view of the night scene video contains at least one street light. Video frames can be periodically acquired from the video stream, and each video frame is an image to be detected. The target detection model outputs the target detection box of the target, i.e., a rectangular box that encloses the target. It also outputs the center coordinates, width, and height of the target detection box. In this embodiment, street lights are detected, so the output rectangular box is the street light detection box, which corresponds to a local image region in the image to be detected that includes the street light.
[0054] The object detection model can be a large-scale visual model, such as Grounding Dino. Object detection models based on large-scale visual models can detect all streetlights in a single frame of video using only descriptive words for streetlights (e.g., street lamp, road lamp, road light), thus outputting the corresponding bounding boxes for each streetlight with high detection accuracy. Moreover, compared to traditional small models, it eliminates the need for training the object detection model, meaning it doesn't require labeled images of different nighttime scenes as a training set, thereby reducing labor costs. Using a large-scale visual model combined with descriptive words for streetlights can detect bounding boxes for streetlights in any nighttime image, demonstrating good generalization ability for various streetlight shapes and distances from the camera. The descriptive words for streetlights can be pre-imported into the object detection model as a configuration file. In addition to the word "streetlight," adjectives can be added before the word, such as adjectives describing the shape of the streetlight, thereby improving the detection accuracy for streetlights with specific shapes. The specific descriptive words can be set according to actual needs.
[0055] Step S120: Calculate the grayscale statistical parameters of the pixels in the target area within the streetlight detection frame. These grayscale statistical parameters include the average grayscale value, median grayscale value, or sum of grayscale values of the pixels in the target area. Specifically, the grayscale values of the pixels in the target area within the streetlight detection frame are obtained. The average grayscale value is obtained by averaging the grayscale values of all pixels within the streetlight detection frame. The sum of grayscale values of the pixels in the target area is obtained by summing the grayscale values. The median grayscale value can be obtained based on the grayscale histogram of the pixels within the streetlight detection frame. The pixels in the target area can be the pixels of the entire area within the streetlight detection frame or pixels of a portion of the area within the streetlight detection frame.
[0056] Step S130: Based on the grayscale statistical parameters, determine the on / off state of the streetlight corresponding to the streetlight detection frame. Within the streetlight detection frame, there is a significant difference in the grayscale values of pixels for lit and off streetlights. Therefore, the on / off state of the streetlight can be determined by the grayscale statistical parameters of the pixels in the target area within the streetlight detection frame.
[0057] In this embodiment of the street light on / off detection method, by using a preset target detection model and descriptive words for street lights, the street lights can be accurately identified from the image to be detected, and a street light detection box can be obtained. There is no need to train the target detection model, which reduces labor costs. Then, the on / off state of the street light is determined based on the gray-scale statistical parameters of the pixels in the target area within the accurately identified street light detection box. While ensuring that the on / off state of the street light can be accurately determined, there is no need to manually calibrate the ROI in advance, which has good versatility and convenience. Moreover, it has good generalization ability for various shapes of street lights and distances from the camera. That is, thanks to the generalization ability of the large visual model trained on massive amounts of data, it has good recognition ability for street lights with different shooting distances, angles and shapes.
[0058] In some embodiments, step S130 specifically includes: comparing the grayscale statistical parameter with a grayscale statistical parameter threshold; if the grayscale statistical parameter is less than the grayscale statistical parameter threshold, determining that the streetlight corresponding to the streetlight detection box is off. The grayscale statistical parameter threshold is set based on the grayscale statistical parameter of the pixels in the target area within the streetlight detection box in the sample image where the streetlight is lit. Specifically, streetlight detection boxes and target areas are marked in a small number of sample images where streetlights are lit (much smaller than the number of samples during model training), and the grayscale statistical parameter of the pixels in the target area within the marked streetlight detection box is used as the grayscale statistical parameter threshold. Since the grayscale values of pixels within the streetlight detection box differ significantly between lit and off streetlights, by comparing the grayscale statistical parameter of the pixels in the target area within the streetlight detection box in the image to be detected with the grayscale statistical parameter threshold, the on / off status of the streetlight can be accurately determined, and an alarm message can be issued for the off streetlight to prompt relevant personnel to carry out maintenance.
[0059] In this embodiment, a uniform threshold can be used for the grayscale statistical parameter threshold, applying it to all images under different detection scenarios (night scene scenarios). However, in practical applications, the brightness and warm / cool tones of lights vary across different detection scenarios. Using a uniform grayscale statistical parameter threshold may lead to inaccurate detection of streetlights being on or off. To further improve the accuracy of streetlight detection, for the detection scenario corresponding to the image to be detected, the grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the target area within the streetlight detection box in the sample image where the streetlight is lit under that detection scenario. That is, each detection scenario corresponds to a grayscale statistical parameter threshold, thereby making the detection of streetlights on or off more accurate.
[0060] In practical applications, the image within the field of view of each camera capturing night scene video constitutes a detection scene. The camera ID is obtained simultaneously with the night scene video frame acquired from the front-end camera (the camera ID information is usually also contained in the video frame). Each camera ID corresponds to a detection scene. A mapping table between the camera ID and the grayscale statistical parameter threshold of the corresponding detection scene is preset in the back-end. Thus, based on the image to be detected in different detection scenes, the corresponding grayscale statistical parameter threshold is selected and compared with the grayscale statistical parameters of the pixels in the target area within the street light detection box in the image to be detected.
[0061] Since the brightness and warm / cool tones of multiple streetlights in the same night scene may vary, in some embodiments, in the detection scene corresponding to the image to be detected, each streetlight detection box in the image to be detected corresponds to a grayscale statistical parameter threshold. For each streetlight detection box, the corresponding grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the target area pixels in the corresponding streetlight detection box in the sample image of the streetlight being lit in the detection scene. That is, each streetlight detection box corresponds to a grayscale statistical parameter threshold, thereby making the detection of streetlights on and off more accurate.
[0062] In practical applications, the image within the field of view of each camera capturing night scene video constitutes a detection scene. While acquiring night scene video frames from the front-end camera, the camera ID is also obtained (usually the video frame also contains camera ID information). Each camera ID corresponds to a detection scene. A mapping table between streetlight detection boxes and grayscale statistical parameter thresholds is preset in the back-end. This mapping table includes the camera ID, the ID of each streetlight detection box in the corresponding detection scene (the center coordinates of the streetlight detection box can be used as the streetlight detection box ID), and the grayscale statistical parameter threshold corresponding to each streetlight detection box (as shown in Table 1 below). Therefore, based on different streetlight detection boxes in the image to be detected under different detection scenes, the corresponding grayscale statistical parameter threshold is selected and compared with the grayscale statistical parameters of the target region pixels within that streetlight detection box.
[0063] Table 1. Mapping Relationship between Streetlight Detection Frame and Gray-Scale Statistical Parameter Threshold
[0064]
[0065] Based on this, in step S130, the grayscale statistical parameter is compared with the grayscale statistical parameter threshold. If the grayscale statistical parameter is less than the grayscale statistical parameter threshold, it is determined that the streetlight corresponding to the streetlight detection frame is off, including:
[0066] For any street light detection box in the image to be detected, obtain the grayscale statistical parameter threshold corresponding to any street light detection box. Specifically, obtain the grayscale statistical parameter threshold corresponding to any street light detection box according to Table 1 above.
[0067] The grayscale statistical parameter corresponding to any street light detection frame is compared with the corresponding grayscale statistical parameter threshold. If the corresponding grayscale statistical parameter is less than the corresponding grayscale statistical parameter threshold, it is determined that the street light corresponding to any street light detection frame is off.
[0068] In some embodiments, the threshold of the grayscale statistical parameter is determined according to the following formula:
[0069] Th = a × G
[0070] Where Th represents the grayscale statistical parameter threshold, G represents the grayscale statistical parameter of the pixels in the target area within the streetlight detection box in the sample image of the streetlight being lit, and a represents the weighting coefficient, with a value ranging from 0.7 to 0.9. In practical applications, since the pixel grayscale values of different streetlights (e.g., cold light sources and warm light sources, or affected by weather) have certain differences when lit, in order to make the final judgment of whether the streetlight is on or off more accurate, the above value of G is multiplied by a weighting coefficient when setting the grayscale statistical parameter threshold. This is equivalent to setting a certain tolerance, avoiding missing some streetlights that are inherently dim and incorrectly judging them as off.
[0071] In some embodiments, the specific process of step S120 is as follows: Figure 2 As shown, it includes the following steps:
[0072] Step S210: Extract the pixels of the upper region within the streetlight detection frame as the target region pixels. The upper region refers to the area including the streetlight head. The streetlight detection frame is usually a rectangle. The target region can be obtained by measuring the size of the rectangle and cropping its upper region, for example, the upper half region.
[0073] Step S220: Calculate the grayscale statistical parameters of the pixels in the target region.
[0074] The area enclosed by the streetlight detection frame includes the lamp post and the upper light-emitting portion of the lamp head. Since the difference in pixel grayscale between the on and off states of the streetlight primarily stems from the grayscale differences of the pixels in the upper part of the detection frame, this embodiment extracts the pixels in the upper region of the detection frame as the target region pixels and calculates the grayscale statistical parameters of these target region pixels. Correspondingly, the grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the upper region of the streetlight detection frame in the sample image of the streetlight being on. This allows for more accurate detection of streetlight on / off states, improving the accuracy of streetlight on / off detection, while also reducing the computational load of pixel grayscale statistical parameters and increasing detection speed.
[0075] Furthermore, the specific process of step S220 is as follows: Figure 3 As shown, it includes the following steps:
[0076] Step S310: Compare the grayscale of the target region pixels with a preset grayscale threshold, and select pixels with a grayscale greater than the grayscale threshold as target pixels. The grayscale threshold is set based on the grayscale difference between the streetlight body pixels and the background pixels within the streetlight detection frame. Since the streetlight detection frame is typically the outer rectangular frame of the streetlight, it includes a significant portion of the background image in addition to the streetlight itself. Furthermore, there is a substantial difference in grayscale between the streetlight body pixels (the lamp post and lamp head at the top of the streetlight) and the background pixels in the image to be detected. To ensure that the extracted pixels better reflect the difference between the streetlight's on / off state, background pixels in the target region are removed by comparing with the grayscale threshold, and only the streetlight body pixels are extracted as target pixels.
[0077] Step S320: Calculate the grayscale statistical parameters of the target pixel.
[0078] Accordingly, the grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the target pixels within the streetlight detection box in the sample image of the streetlight being lit. This further improves the accuracy of streetlight on / off detection and further reduces the computational load of pixel grayscale statistical parameters.
[0079] In this embodiment, the grayscale threshold can be set according to the actual weather conditions. Preferably, the grayscale level of the grayscale threshold is in the range of 170 to 210. For example, on sunny days, the grayscale threshold can be 190 to 210; on rainy days, the grayscale threshold can be 170 to 190; and on cloudy days, the grayscale threshold can be 180 to 200.
[0080] It should be noted that the pixel grayscale value, grayscale threshold, and grayscale statistical parameter threshold in the above embodiments can be based on the grayscale level of the RGB format image, with a grayscale level range of 0 to 255, where white is 255 and black is 0.
[0081] In some embodiments, step S220 can also be implemented in another way, the specific process of which is as follows: Figure 4 As shown, it includes the following steps:
[0082] Step S410: Input the image to be detected into a preset target segmentation model to obtain a street lamp mask output by the target segmentation model. The target segmentation model is used to segment street lamps from the image to be detected based on the descriptive words for street lamps and output the street lamp mask. The target segmentation model is also a large visual model, such as "grounded segment anything". Based on this large visual model, the target segmentation model can segment all street lamps in a single frame of video using only descriptive words for street lamps (e.g., "street lamp", "road lamp", "road light"), thus outputting the street lamp mask for each street lamp, and achieving high accuracy in street lamp segmentation. Furthermore, compared to traditional small models, it does not require training of the target detection model, i.e., it does not require labeled image materials of different night scene scenarios as a training set, thereby reducing labor costs. The street lamp mask is the region containing only the street lamp itself.
[0083] Step S420: Capture the upper region within the street light detection frame, where the upper region refers to the area including the street light head.
[0084] Step S430: Using the pixels within the streetlight mask area in the upper region as the target region pixels, calculate the grayscale statistical parameters.
[0085] Accordingly, the grayscale statistical parameter threshold is set based on the pixel grayscale statistical parameters within the streetlight mask area in the upper region of the streetlight detection frame in the sample image of the streetlight being lit.
[0086] By combining the street light detection frame and the street light mask, grayscale statistical parameters are calculated only for the pixels within the mask, filtering out background pixels and eliminating their interference, thus making the judgment of whether the street light is on or off more accurate.
[0087] It should be noted that in practical applications, steps S410 and S110 can be executed in parallel, and their order is not restricted.
[0088] Since streetlights are typically turned on at night, the image to be detected for detecting whether streetlights are on or off must also be a night scene image. Therefore, in some embodiments, when the image to be detected is an image captured during a predetermined nighttime period, the image to be detected is input into a preset target detection model. Specifically, video frames captured by a camera are acquired, and it is determined whether the current time corresponding to the video frame is nighttime. For example, if the video frame captured during the nighttime period is defined as 7 PM on the first day to 6 AM on the second day, then this night scene video frame is used as the image to be detected and input into the preset target detection model.
[0089] Of course, in practical applications, the program that performs the above steps S110 to S130 can also be set to be executed during the nighttime period. In this way, the video frames obtained from the camera will naturally be night scene video frames, and there is no need to determine whether the image to be detected by the preset target detection model is a night scene image.
[0090] In some embodiments, after step S130, the method further includes:
[0091] Based on a pre-defined correspondence between street light detection box IDs and street light IDs, the street light ID corresponding to the extinguished street light detection box is determined. Specifically, a correspondence table can be established based on the street light detection box IDs and street light IDs in sample images of street lights in the detection scenario.
[0092] The system outputs the streetlight ID of the extinguished streetlight and the corresponding streetlight information. The streetlight information, including its geographical location and the model of its LED chips, can be linked to the streetlight ID. This streetlight information is then output to the user terminal, enabling maintenance personnel to perform timely repairs based on this information.
[0093] In some embodiments, after step S130, the method further includes: recording the on / off state of the street light in a log file and uploading the log file to a backend server for subsequent query by staff.
[0094] The street light on / off detection device provided by the present invention is described below. The street light on / off detection device described below can be referred to in correspondence with the street light on / off detection method described above.
[0095] The present invention also provides a street light on / off detection device, such as... Figure 5 As shown, it includes:
[0096] The street light recognition module 510 is used to input the image to be detected into a preset target detection model to obtain a street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected according to preset prompts describing street lights, and output the street light detection box.
[0097] The grayscale calculation module 520 is used to calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame.
[0098] The street light status determination module 530 is used to determine the on / off status of the street light corresponding to the street light detection frame based on the grayscale statistical parameters.
[0099] In the street light on / off detection device of the present invention, since a preset target detection model and prompts describing the street light are used, the street light can be accurately identified from the image to be detected, and a street light detection box can be obtained. There is no need to train the target detection model, which reduces labor costs. Then, the on / off state of the street light is determined based on the gray-scale statistical parameters of the pixels in the target area within the accurately identified street light detection box. While ensuring that the on / off state of the street light can be accurately determined, there is no need to manually calibrate the ROI in advance, which has good versatility and convenience, and has good generalization ability for various shapes of street lights and distances from the camera.
[0100] Optionally, the street light status determination module 530 is specifically used to compare the grayscale statistical parameters with the grayscale statistical parameter threshold, and if the grayscale statistical parameters are less than the grayscale statistical parameter threshold, determine that the street light corresponding to the street light detection box is off. The grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the target area within the street light detection box in the sample image of the street light being lit.
[0101] Optionally, for the detection scene corresponding to the image to be detected, the grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the target region pixels within the streetlight detection box in the sample image of the streetlight being lit in the detection scene.
[0102] Optionally, in the detection scenario corresponding to the image to be detected, each street light detection box in the image to be detected corresponds to a grayscale statistical parameter threshold. For each street light detection box, the corresponding grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the target region pixels in the corresponding street light detection box in the sample image of the street light being lit in the detection scenario.
[0103] The street light status determination module 530 is specifically used to obtain the grayscale statistical parameter threshold corresponding to any street light detection box in the image to be detected; compare the grayscale statistical parameter corresponding to any street light detection box with the corresponding grayscale statistical parameter threshold; and determine that the street light corresponding to any street light detection box is off if the corresponding grayscale statistical parameter is less than the corresponding grayscale statistical parameter threshold.
[0104] Optionally, the threshold value of the grayscale statistical parameter is determined according to the following formula:
[0105] Th = a × G
[0106] Where Th represents the gray-level statistical parameter threshold, G represents the gray-level statistical parameter of the target region pixels within the street light detection box in the sample image based on the street light being lit, and a represents the weighting coefficient, with a value of 0.7 to 0.9.
[0107] Optionally, the grayscale calculation module 520 specifically includes:
[0108] The target region pixel extraction module is used to extract the pixels in the upper region of the street light detection frame as the target region pixels, where the upper region refers to the region including the street light head.
[0109] The first calculation module is used to calculate the grayscale statistical parameters of the pixels in the target area.
[0110] Optionally, the first calculation module is specifically used to compare the grayscale of the target region pixels with a preset grayscale threshold, and obtain the pixels with grayscale greater than the grayscale threshold as target pixels, wherein the grayscale threshold is set based on the grayscale difference between the street lamp body pixels and the background pixels within the street lamp detection frame; and to calculate the grayscale statistical parameters of the target pixels.
[0111] Optionally, the grayscale threshold value ranges from 170 to 210 under the grayscale level specification of 0 to 255.
[0112] Optionally, the grayscale calculation module 520 specifically includes:
[0113] The street light segmentation module is used to input the image to be detected into a preset target segmentation model to obtain a street light mask output by the target segmentation model. The target segmentation model is used to segment street lights from the image to be detected based on the prompts describing the street lights and output the street light mask.
[0114] The region capture module is used to capture the upper region within the street light detection frame, where the upper region refers to the area including the street light head.
[0115] The second calculation module is used to calculate the grayscale statistical parameters using the pixels within the street lamp mask range in the upper region as the target region pixels.
[0116] Optionally, the street light recognition module 510 is specifically used to input the image to be detected into a preset target detection model when the image to be detected is an image taken during a set nighttime period.
[0117] Optionally, the street light on / off detection device further includes:
[0118] The street light ID determination module is used to determine the street light ID of the extinguished street light corresponding to the street light detection frame ID and the street light ID based on the preset correspondence between the street light detection frame ID and the street light ID.
[0119] The street light information output module is used to output the street light ID of the street light that is turned off and the street light information corresponding to the street light ID.
[0120] Optionally, the target detection model includes a large visual model.
[0121] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a street light on / off detection method, which includes:
[0122] The image to be detected is input into a preset target detection model to obtain a street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset prompts describing street lights, and output the street light detection box.
[0123] Calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame.
[0124] Based on the grayscale statistical parameters, the on / off state of the streetlight corresponding to the streetlight detection frame is determined.
[0125] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0126] On the other hand, the present invention also provides a computer program product, which may be on a non-transitory computer-readable medium or a downloaded app, etc. The computer program product includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the street light on / off detection method provided by the above methods, the method including:
[0127] The image to be detected is input into a preset target detection model to obtain a street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset prompts describing street lights, and output the street light detection box.
[0128] Calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame.
[0129] Based on the grayscale statistical parameters, the on / off state of the streetlight corresponding to the streetlight detection frame is determined.
[0130] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the street light on / off detection method provided by the above methods, the method comprising:
[0131] The image to be detected is input into a preset target detection model to obtain a street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset prompts describing street lights, and output the street light detection box.
[0132] Calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame.
[0133] Based on the grayscale statistical parameters, the on / off state of the streetlight corresponding to the streetlight detection frame is determined.
[0134] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0135] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting the on / off state of streetlights, characterized in that, include: The image to be detected is input into a preset target detection model to obtain a street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected based on preset prompts describing street lights and output the street light detection box. Calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame; Based on the grayscale statistical parameters, the on / off state of the streetlight corresponding to the streetlight detection frame is determined.
2. The street light on / off detection method according to claim 1, characterized in that, Determining the on / off state of the streetlight corresponding to the streetlight detection frame based on the grayscale statistical parameters includes: The grayscale statistical parameters are compared with the grayscale statistical parameter threshold. If the grayscale statistical parameters are less than the grayscale statistical parameter threshold, it is determined that the street light corresponding to the street light detection box is off. The grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the target area within the street light detection box in the sample image of the street light being lit.
3. The street light on / off detection method according to claim 2, characterized in that, For the detection scene corresponding to the image to be detected, the gray-scale statistical parameter threshold is set based on the gray-scale statistical parameters of the target area pixels within the street light detection box in the sample image of the street light being lit in the detection scene.
4. The street light on / off detection method according to claim 2, characterized in that, In the detection scenario corresponding to the image to be detected, each street light detection box in the image to be detected corresponds to a grayscale statistical parameter threshold. For each street light detection box, the corresponding grayscale statistical parameter threshold is set based on the grayscale statistical parameters of the pixels in the target area within the corresponding street light detection box in the sample image where the street lights are lit in the detection scenario. The comparison of the grayscale statistical parameter with a grayscale statistical parameter threshold, and the determination that the streetlight corresponding to the streetlight detection frame is off when the grayscale statistical parameter is less than the grayscale statistical parameter threshold, includes: For any street light detection box in the image to be detected, obtain the grayscale statistical parameter threshold corresponding to any street light detection box; The grayscale statistical parameter corresponding to any street light detection frame is compared with the corresponding grayscale statistical parameter threshold. If the corresponding grayscale statistical parameter is less than the corresponding grayscale statistical parameter threshold, it is determined that the street light corresponding to any street light detection frame is off.
5. The street light on / off detection method according to claim 2, characterized in that, The threshold value for the grayscale statistical parameter is determined according to the following formula: Th = a × G Where Th represents the gray-level statistical parameter threshold, G represents the gray-level statistical parameter of the target region pixels within the street light detection box in the sample image based on the street light being lit, and a represents the weighting coefficient, with a value of 0.7 to 0.
9.
6. The street light on / off detection method according to claim 1, characterized in that, The calculation of grayscale statistical parameters of the pixels in the target area within the streetlight detection frame includes: The pixels in the upper region of the street light detection frame are extracted as the target region pixels, where the upper region refers to the region including the street light head; Calculate the grayscale statistical parameters of the pixels in the target region.
7. The street light on / off detection method according to claim 6, characterized in that, The calculation of the grayscale statistical parameters of the pixels in the target region includes: The grayscale of the target region pixels is compared with a preset grayscale threshold, and the pixels with a grayscale greater than the grayscale threshold are identified as target pixels. The grayscale threshold is set based on the grayscale difference between the street lamp body pixels and the background pixels within the street lamp detection frame. Calculate the grayscale statistical parameters of the target pixel.
8. The street light on / off detection method according to claim 7, characterized in that, The grayscale threshold value ranges from 170 to 210 within the grayscale level specification of 0 to 255.
9. The street light on / off detection method according to claim 1, characterized in that, The calculation of grayscale statistical parameters of the pixels in the target area within the streetlight detection frame includes: The image to be detected is input into a preset target segmentation model to obtain a street lamp mask output by the target segmentation model. The target segmentation model is used to segment street lamps from the image to be detected based on the prompts describing street lamps and output the street lamp mask. The upper region within the street light detection frame is selected, and the upper region refers to the area including the street light head; The grayscale statistical parameters are calculated using the pixels within the streetlight mask area in the upper region as the target region pixels.
10. The street light on / off detection method according to any one of claims 1 to 9, characterized in that, The step of inputting the image to be detected into a preset target detection model includes: If the image to be detected is an image taken during a set nighttime period, the image to be detected is input into a preset target detection model.
11. The street light on / off detection method according to any one of claims 1 to 9, characterized in that, After determining the on / off state of the streetlight corresponding to the streetlight detection frame based on the grayscale statistical parameters, the method further includes: Based on the preset correspondence between street light detection frame ID and street light ID, determine the street light ID of the extinguished street light corresponding to the street light detection frame of the extinguished street light; Output the street light ID that is turned off and the street light information corresponding to the street light ID.
12. The street light on / off detection method according to any one of claims 1 to 9, characterized in that, The target detection model includes a large visual model.
13. A street light on / off detection device, characterized in that, include: The street light recognition module is used to input the image to be detected into a preset target detection model to obtain the street light detection box output by the target detection model. The target detection model is used to identify street lights from the image to be detected according to preset prompts describing street lights, and output the street light detection box. The grayscale calculation module is used to calculate the grayscale statistical parameters of the pixels in the target area within the street light detection frame; The street light status determination module is used to determine the on / off status of the street light corresponding to the street light detection frame based on the grayscale statistical parameters.
14. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, when the processor executes the computer program, it implements the street light on / off detection method as described in any one of claims 1 to 12.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the street light on / off detection method as described in any one of claims 1 to 12.