Traffic light detection method and apparatus, electronic device, and computer-readable storage medium
Through the automatic switching of multiple cameras with different focal lengths and closed-loop control of visual inspection results, the problems of wide traffic light detection range and errors are solved, and low-consumption, high-precision real-time traffic light detection is achieved.
Patent Information
- Application Number
- CN202210626012.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-06-02
AI Technical Summary
In existing technologies, traffic light detection has a relatively wide range, resulting in high resource consumption and poor real-time detection. Errors in vehicle positioning and high-precision maps also lead to low detection accuracy.
Traffic light detection is performed using multiple cameras with different focal lengths. Cameras are automatically switched based on preset camera switching conditions. Detection is performed using a preset traffic light detection model. Closed-loop control is performed in combination with visual detection results to avoid the influence of vehicle positioning and high-precision map errors.
It reduces resource consumption, ensures the real-time and precision of detection, and improves the accuracy of traffic light detection.
Smart Images

Figure CN115019284B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of automatic driving, in particular to a traffic light detection method and device, electronic equipment and a computer readable storage medium. BACKGROUND
[0002] In the field of visual perception of automatic driving, traffic light detection is of great significance to the automatic driving capability. In real scenarios, the sizes of traffic intersections vary, the distances from stop lines to traffic lights are as small as tens of meters and as large as more than one hundred meters, and the automatic driving vehicle needs to lock the traffic light state when it is about one hundred meters away from the stop line. Therefore, the actual detection distance range of the traffic light is generally about 15-220 meters.
[0003] Because the detection range of the traffic light is relatively wide, it is impossible to ensure that the traffic light is located in the image field of view by using the same camera for shooting. Therefore, multiple cameras with different focal lengths are often used for traffic light detection. However, the simultaneous execution of detection tasks by multiple cameras with different focal lengths consumes a lot of computing resources of the controller, and the time cost is doubled, which leads to poor real-time performance of traffic light detection. In addition, the controller also needs to perform other tasks such as lane line segmentation, laser point cloud detection and recognition, sensor fusion, path planning, and the like. Excessive resource occupation will also affect the execution of these tasks.
[0004] A solution is provided in the prior art, which calculates the distance from the vehicle to the next traffic light intersection according to the self-positioning and high-precision map, and selects a specified camera or multiple cameras with different focal lengths to perform traffic light detection according to the distance.
[0005] However, the above solution at least has the following problems: 1) the self-positioning has errors, which include errors of the sensor itself and errors caused by weak base station signals in complex places; 2) the high-precision map has errors, which include errors caused by map making due to positioning of map data collection vehicles and errors caused by the high-precision map based on traffic light position information sent by the self-positioning. Therefore, the distance from the vehicle to the next traffic light intersection calculated based on the self-positioning and the high-precision map also has errors, which may lead to improper use of the camera and problems such as missed detection or classification errors. SUMMARY
[0006] The embodiments of the present application provide a traffic light detection method, device, electronic equipment and computer readable storage medium to realize low-consumption, wide-range and real-time high-precision detection of traffic lights.
[0007] The embodiments of the present application adopt the following technical solutions:
[0008] In a first aspect, the embodiments of the present application provide a traffic light detection method, which comprises:
[0009] Acquire an image to be detected captured by a target camera, wherein the target camera is any one of a plurality of cameras with different focal lengths;
[0010] Detecting the image to be detected using a preset traffic light detection model to obtain a traffic light detection result;
[0011] Determining whether the traffic light detection result satisfies a preset camera switching condition, wherein the preset camera switching condition includes a traffic light detection frame size switching condition and a detection time interval switching condition;
[0012] When the traffic light detection result satisfies the preset camera switching condition, switching the target camera and outputting the traffic light detection result corresponding to the switched camera;
[0013] When the traffic light detection result does not meet the preset camera switching condition, the traffic light detection result corresponding to the target camera is directly output.
[0014] Optionally, the traffic light detection result includes a plurality of traffic light detection frames, and determining whether the traffic light detection result satisfies a preset camera switching condition includes:
[0015] Filtering the multiple traffic light detection frames using a preset traffic light detection frame filtering strategy to obtain filtered traffic light detection frames;
[0016] It is determined whether the filtered traffic light detection frame meets a size switching condition of the traffic light detection frame.
[0017] Optionally, filtering the multiple traffic light detection frames using a preset traffic light detection frame filtering strategy to obtain filtered traffic light detection frames includes:
[0018] Determining an effective detection area of the image to be detected;
[0019] filtering the plurality of traffic light detection frames according to the effective detection area and the position of each traffic light detection frame to obtain a first filtering result;
[0020] determining a maximum area of the traffic light detection frame according to the first filtering result;
[0021] The first filtering result is filtered according to the maximum area of the traffic light detection frame to obtain a second filtering result as the filtered traffic light detection frame.
[0022] Optionally, the multiple cameras with different focal lengths include a telephoto camera, a medium focal length camera, and a short focal length camera, and determining whether the traffic light detection result meets a preset camera switching condition includes:
[0023] determining whether the traffic light detection result contains a traffic light bounding box;
[0024] in a case where the traffic light detection result contains a traffic light bounding box, determining whether the traffic light detection result meets a size switching condition of the traffic light bounding box;
[0025] in a case where the traffic light detection result does not contain a traffic light bounding box and the target camera is a long-focus camera, repeatedly performing the step of detecting the to-be-detected image to obtain a traffic light detection result by using a preset traffic light detection model;
[0026] in a case where the traffic light detection result does not contain a traffic light bounding box and the target camera is a medium-focus camera or a short-focus camera, determining a time interval between a current detection time and a previous detection time, and determining whether the traffic light detection result meets a detection time interval switching condition according to the time interval.
[0027] Optionally, the target camera is a long-focus camera, and the determining whether the traffic light detection result meets a preset camera switching condition comprises:
[0028] determining whether a shortest side of the traffic light bounding box is greater than a first preset size threshold;
[0029] in a case where the shortest side of the traffic light bounding box is greater than the first preset size threshold, determining that the traffic light detection result meets the size switching condition of the traffic light bounding box;
[0030] in a case where the shortest side of the traffic light bounding box is not greater than the first preset size threshold, determining that the traffic light detection result does not meet the size switching condition of the traffic light bounding box.
[0031] Optionally, the target camera is a medium-focus camera or a short-focus camera, and the determining whether the traffic light detection result meets a preset camera switching condition comprises:
[0032] determining whether a shortest side of the traffic light bounding box is greater than a second preset size threshold;
[0033] in a case where the shortest side of the traffic light bounding box is greater than the second preset size threshold, determining that the traffic light detection result meets the size switching condition of the traffic light bounding box;
[0034] in a case where the shortest side of the traffic light bounding box is not greater than the second preset size threshold, determining that the traffic light detection result does not meet the size switching condition of the traffic light bounding box.
[0035] Optionally, the switching the target camera in the case where the traffic light detection result meets the preset camera switching condition comprises:
[0036] In a case where the traffic light detection result meets the size switching condition of the traffic light detection frame and the target camera is a long-focus camera, switching the target camera from the long-focus camera to a medium-focus camera;
[0037] In a case where the traffic light detection result meets the size switching condition of the traffic light detection frame and the target camera is a medium-focus camera, switching the target camera from the medium-focus camera to a short-focus camera;
[0038] In a case where the traffic light detection result meets the size switching condition of the traffic light detection frame and the target camera is a short-focus camera, switching the target camera from the short-focus camera to a long-focus camera.
[0039] Optionally, the previous detection time is a previous detection time corresponding to a case where the traffic light detection result contains a traffic light detection frame, and the determining whether the traffic light detection result meets the detection time interval switching condition according to the time interval includes:
[0040] In a case where the time interval between the current detection time and the previous detection time is greater than a preset time interval threshold, determining that the traffic light detection result meets the detection time interval switching condition;
[0041] In a case where the time interval between the current detection time and the previous detection time is not greater than the preset time interval threshold, determining that the traffic light detection result does not meet the detection time interval switching condition.
[0042] Optionally, the switching the target camera in the case where the traffic light detection result meets the preset camera switching condition includes:
[0043] In a case where the traffic light detection result meets the detection time interval switching condition and the target camera is a medium-focus camera or a short-focus camera, switching the target camera from the medium-focus camera or the short-focus camera to a long-focus camera.
[0044] In a second aspect, an embodiment of the present application further provides a traffic light detection device, and the device includes:
[0045] An acquisition unit is configured to acquire a to-be-detected image collected by a target camera, the target camera being any one of a plurality of cameras with different focal lengths;
[0046] A detection unit is configured to detect the to-be-detected image by using a preset traffic light detection model to obtain a traffic light detection result;
[0047] a determining unit, configured to determine whether the traffic light detection result satisfies a preset camera switching condition, wherein the preset camera switching condition includes a traffic light detection frame size switching condition and a detection time interval switching condition;
[0048] a switching unit, configured to switch the target camera if the traffic light detection result satisfies the preset camera switching condition, and output the traffic light detection result corresponding to the switched camera;
[0049] The output unit is configured to directly output the traffic light detection result corresponding to the target camera when the traffic light detection result does not meet the preset camera switching condition.
[0050] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0051] processor; and
[0052] A memory arranged to store computer executable instructions, which when executed cause the processor to perform any of the methods described above.
[0053] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple applications, the electronic device executes any of the aforementioned methods.
[0054] At least one of the above-mentioned technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: The traffic light detection method of the embodiments of the present application first obtains an image to be detected captured by a target camera, where the target camera is any one of multiple cameras with different focal lengths; then, a preset traffic light detection model is used to detect the image to be detected, obtaining a traffic light detection result; then, a determination is made as to whether the traffic light detection result meets preset camera switching conditions, which include conditions for switching the size of the traffic light detection frame and conditions for switching the detection time interval; finally, if the traffic light detection result meets the preset camera switching conditions, the target camera is switched and the traffic light detection result corresponding to the switched camera is output; if the traffic light detection result does not meet the preset camera switching conditions, the traffic light detection result corresponding to the target camera is directly output. The traffic light detection method of the embodiments of the present application utilizes multiple cameras with different focal lengths to capture images, solving the problem of wide traffic light detection distances. Based on the visual detection results, the multiple cameras with different focal lengths are automatically switched, with only one camera active at a time, reducing resource consumption and ensuring real-time detection. Furthermore, the overall process adopts a closed-loop control strategy based on the visual detection results, avoiding the adverse effects caused by vehicle positioning errors and high-precision map errors, thereby improving detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:
[0056] Figure 1 A flowchart of a traffic light detection method in an embodiment of the application is shown in FIG. 1.
[0057] Figure 2 A flowchart of a traffic light detection method in an embodiment of the application is shown in FIG. 1.
[0058] Figure 3 A structural diagram of a traffic light detection device in an embodiment of the application is shown in FIG. 2.
[0059] Figure 4 A structural diagram of an electronic device in an embodiment of the application is shown in FIG. 3. DETAILED DESCRIPTION
[0060] To make the objects, technical solutions and advantages of the application clearer, the technical solutions of the application will be described below in detail with reference to the embodiments of the application and the accompanying drawings. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the application.
[0061] The technical solutions provided by the embodiments of the application will be described below in detail with reference to the accompanying drawings.
[0062] An embodiment of the application provides a traffic light detection method, as shown in FIG. 1, a flowchart of a traffic light detection method in an embodiment of the application is provided, and the method at least includes the following steps S110 to S150: Figure 1
[0063] In step S110, a to-be-detected image collected by a target camera is acquired, and the target camera is any one of a plurality of cameras with different focal lengths.
[0064] The traffic light detection method of the embodiment of the application is executed by an autonomous vehicle. In order to realize wide-range traffic light detection, a plurality of cameras with different focal lengths are installed on the autonomous vehicle in advance in the embodiment of the application to cover a larger detection range, thereby providing strong support for subsequent real-time detection of traffic lights and timely driving decision-making of the autonomous vehicle.
[0065] When performing traffic light detection, it is necessary to first obtain the image to be detected captured by the target camera. The target camera here refers to the currently enabled camera, which may be any one of the multiple cameras with different focal lengths mentioned above. That is, only one camera is enabled to capture images at the same time, thereby reducing the resource consumption of the controller.
[0066] Step S120 , detecting the image to be detected using a preset traffic light detection model to obtain a traffic light detection result.
[0067] After obtaining the image to be detected captured by the target camera, a pre-trained traffic light detection model such as YOLO V5 can be used to detect the image to be detected captured by the target camera to obtain a traffic light detection result. The traffic light detection result here may be a detection result including the traffic light or a detection result excluding the traffic light. If the detection result includes the traffic light, it may specifically include the center position coordinates of the traffic light detection frame, the width and height of the traffic light detection frame, and the traffic light color corresponding to the traffic light detection frame, such as red light / green light / yellow light and other information.
[0068] Step S130 , determining whether the traffic light detection result satisfies a preset camera switching condition, wherein the preset camera switching condition includes a traffic light detection frame size switching condition and a detection time interval switching condition.
[0069] Based on the traffic light detection results obtained in the preceding steps, it is necessary to further determine whether the traffic light detection results meet the preset camera switching conditions. The preset camera switching conditions are used to determine whether the image to be detected captured by the target camera currently in use can continue to be trusted. Specifically, the preset camera switching conditions may include the size switching conditions of the traffic light detection frame and the detection time interval switching conditions.
[0070] The traffic light detection frame size switching condition primarily targets situations where the traffic light detection frame can be detected in the image to be detected. It specifically measures whether the size of the traffic light detection frame in the image to be detected triggers the traffic light detection frame size switching condition. This switching condition can avoid issues with incomplete traffic lights in the image to be detected. The detection time interval switching condition primarily targets situations where the traffic light detection frame cannot be detected in the image to be detected. It specifically determines the reason for this failure. This could be due to a brief missed detection by the target camera or the proximity of the target camera to the traffic light. This can determine whether the detection time interval switching condition is triggered.
[0071] Step S140 , when the traffic light detection result satisfies the preset camera switching condition, the target camera is switched, and the traffic light detection result corresponding to the switched camera is output.
[0072] When the traffic light detection result meets the preset camera switching condition in any one dimension, it is indicated that if the image is continuously collected by using the currently used target camera, the traffic light in the collected image to be detected can be incomplete, thereby affecting the detection accuracy of the traffic light. Therefore, the switching operation of the target camera can be triggered at this time, the camera after switching is used to collect the image to be detected and perform detection, and the detection process is the same as that before switching, which will not be repeated here.
[0073] In step S150, in a case where the traffic light detection result does not meet the preset camera switching condition, the traffic light detection result corresponding to the target camera is directly output.
[0074] If the traffic light detection result does not meet the preset camera switching condition in the above two dimensions, it is indicated that the currently used target camera can still be used without switching, and therefore the traffic light detection result corresponding to the target camera can be directly output.
[0075] The traffic light detection method of the embodiment of the application uses multiple cameras with different focal lengths to collect images, solves the problem of wide detection distance of traffic lights, automatically switches multiple cameras with different focal lengths based on the visual detection result, and only enables one camera at the same time, thereby reducing resource consumption and ensuring detection real-time performance. In addition, the overall process adopts a closed-loop control strategy based on the visual detection result, avoids adverse effects caused by self-positioning errors and high-precision map errors, and improves detection accuracy.
[0076] In an embodiment of the application, the traffic light detection result includes multiple traffic light detection boxes, and the determination of whether the traffic light detection result meets the preset camera switching condition includes: filtering the multiple traffic light detection boxes by using a preset traffic light detection box filtering strategy to obtain filtered traffic light detection boxes; and determining whether the filtered traffic light detection boxes meet the size switching condition of the traffic light detection box.
[0077] In actual application, the image to be detected can include not only the traffic light that needs to be concerned by the autonomous vehicle before driving to the next intersection, but also the traffic light of a farther intersection, the traffic light of a left or right intersection, or a non-motor vehicle traffic light such as a pedestrian traffic light and a bicycle traffic light. Therefore, there can be multiple traffic light detection boxes.
[0078] In order to avoid the interference of these irrelevant traffic light detection boxes on the subsequent judgment process, the multiple traffic light detection boxes can be filtered by using a preset traffic light detection box filtering strategy, for example, the traffic light detection boxes of left and right intersections and farther intersections, non-motor vehicle traffic lights and the like are filtered out, so that the remaining traffic light detection boxes after filtering are used as the final traffic light detection result, and whether the traffic light detection box meets the size switching condition is determined.
[0079] In an embodiment of the present application, the filtering of the plurality of traffic light bounding boxes by using the preset traffic light bounding box filtering strategy includes: determining an effective detection region of the image to be detected; filtering the plurality of traffic light bounding boxes according to the effective detection region and the position of each traffic light bounding box to obtain a first filtering result; determining the maximum area of the traffic light bounding box according to the first filtering result; and filtering the first filtering result according to the maximum area of the traffic light bounding box to obtain a second filtering result as the filtered traffic light bounding box.
[0080] In the filtering of the traffic light bounding box, the embodiment of the present application can first determine the effective detection region in the image to be detected. The effective detection region is used to filter out the traffic light bounding boxes located at the left and right edges of the image, that is, to filter the traffic light bounding boxes horizontally, for example, the traffic light bounding boxes of the adjacent intersections on the left and right sides or the traffic light bounding boxes of non-motor vehicles far away from the traffic light bounding box concerned by the autonomous vehicle.
[0081] Therefore, one way to determine the effective detection region is to take the 80% region in the middle of the road image as the effective detection region, specifically, 10% of the area on the left and right sides can be cut off, but the height of the road image remains unchanged, and then the horizontal coordinate x in the center position coordinate (x, y) of each traffic light bounding box is used to determine whether the traffic light bounding box falls into the effective detection region. The traffic light bounding box falling into the effective detection region is taken as the first filtering result. Of course, in addition to using the cutting method, a border of the effective detection region can also be directly added in the original image to be detected. After the border of the effective detection region is determined, the traffic light bounding box far away from the traffic light bounding box concerned by the autonomous vehicle will be located outside the border and thus be filtered out.
[0082] It should be noted that since the camera installation position and shooting angle of the autonomous vehicle basically ensure that the traffic light of the next intersection corresponding to the autonomous vehicle is displayed in the middle or upper left and right positions of the image, the above-mentioned effective detection region constraint can filter out the traffic light bounding boxes located at the left and right edges of the image while ensuring that the traffic light bounding box concerned by the autonomous vehicle is not mistakenly filtered out.
[0083] In addition, since the traffic light concerned by the autonomous vehicle is usually the closest traffic light to the autonomous vehicle and closest to the middle of the image, based on the principle that the closer the distance, the larger the area, the shorter the straight-line distance of the traffic light from the camera optical center, the larger the area of the detected traffic light bounding box, that is, the more likely it is the traffic light bounding box concerned by the autonomous vehicle.
[0084] Based on this, the embodiments of the present application can further calculate the area of each traffic light detection box in the first filtering result, determine the traffic light detection box with the largest area from them, and then compare the area of each other traffic light detection box with the area of the traffic light detection box with the largest area respectively. If the area ratio of the traffic light detection box with the largest area to the area of the traffic light detection box is not less than a preset area ratio threshold, it means that the area of the traffic light detection box is also large, so the traffic light detection box can be retained. Otherwise, the traffic light detection box can be filtered out from the first filtering result, thereby obtaining the second filtering result. The preset area ratio threshold can be set to 0.70 for example. The numerical value is an empirical value, which can be flexibly adjusted according to actual needs, and is not specifically limited here.
[0085] In an embodiment of the present application, the plurality of cameras with different focal lengths includes a long-focus camera, a medium-focus camera and a short-focus camera, and the determination of whether the traffic light detection result meets the preset camera switching condition includes: determining whether the traffic light detection result contains a traffic light detection box; in the case that the traffic light detection result contains a traffic light detection box, determining whether the traffic light detection result meets the size switching condition of the traffic light detection box; in the case that the traffic light detection result does not contain a traffic light detection box and the target camera is a long-focus camera, repeatedly performing the step of detecting the to-be-detected image by using the preset traffic light detection model to obtain a traffic light detection result; in the case that the traffic light detection result does not contain a traffic light detection box and the target camera is a medium-focus camera or a short-focus camera, determining the time interval between the current detection time and the previous detection time, and determining whether the traffic light detection result meets the detection time interval switching condition according to the time interval.
[0086] The embodiments of the present application can set three cameras with different focal lengths according to actual scenes, for example, including a long-focus camera sensor 30, a medium-focus camera sensor 60 and a short-focus camera sensor 120. The long-focus camera sensor 30 can capture traffic lights at a farther distance, the medium-focus camera sensor 60 can capture traffic lights at a relatively close distance, and the short-focus camera sensor 120 can capture traffic lights at a closer distance. The mutual switching among the three can meet the traffic light detection needs in a larger range.
[0087] Based on the size of the traffic intersection in the actual scene and the safety distance required by the autonomous vehicle to lock the traffic light state, the actual detection distance range of the traffic lights covered by the three cameras with different focal lengths used in the embodiments of the present application can reach 15-220 meters, meeting the traffic light detection needs in most intersection scenes.
[0088] As described above, the size switching condition of the traffic light detection box defined in the embodiments of the present application is mainly for the case that the traffic light detection box can be detected in the to-be-detected image, and the detection time interval switching condition is mainly for the case that the traffic light detection box cannot be detected in the to-be-detected image. Therefore, when determining whether the traffic light detection result meets the preset camera switching condition, it can be first judged whether the current traffic light detection result contains the traffic light detection box. If it contains, it can be further judged whether the size of the detected traffic light detection box meets the size switching condition of the traffic light detection box.
[0089] If the traffic light detection result does not contain the traffic light detection box, it can be further distinguished into two cases. One case is that the target camera currently used is a long-focus camera. According to the principle of near large and far small, it is indicated that the distance between the current autonomous vehicle and the next traffic light intersection is far, which causes the long-focus camera to be unable to capture the traffic light. Here, it is not necessary to consider whether the long-focus camera has a missing detection problem because there is a high probability that the long-focus camera cannot capture the traffic light in the case of a long distance. In this case, only the long-focus camera can be used to collect the long-range image, and therefore it is necessary to provide a certain fault tolerance space for the long-focus camera. Therefore, it is returned to continue to perform the step of detecting the to-be-detected image collected by the long-focus camera by using the preset traffic light detection model.
[0090] The other case is that the target camera currently used is a medium-focus camera or a short-focus camera, which indicates that the distance between the current autonomous vehicle and the next traffic light intersection is close. In this case, the probability that the medium-focus camera and the short-focus camera cannot capture the traffic light is small, and it can be considered whether the camera has a missing detection problem. Specifically, it can be first determined the time interval between the detection time of the current traffic light detection result and the time of the last detection of the traffic light detection box, and then it can be determined whether the camera has a missing detection problem according to the time interval. If the medium-focus camera or the short-focus camera has a missing detection, a certain fault tolerance mechanism can be designed, but compared with the long-focus camera, the fault tolerance space of the medium-focus camera and the short-focus camera will be smaller and will be subject to the detection time interval switching condition.
[0091] In an embodiment of the present application, the target camera is a long-focus camera, and the determination of whether the traffic light detection result meets the preset camera switching condition comprises: determining whether the shortest side of the traffic light detection box is greater than a first preset size threshold; in the case that the shortest side of the traffic light detection box is greater than the first preset size threshold, determining that the traffic light detection result meets the size switching condition of the traffic light detection box; and in the case that the shortest side of the traffic light detection box is not greater than the first preset size threshold, determining that the traffic light detection result does not meet the size switching condition of the traffic light detection box.
[0092] In the determination of whether the traffic light detection result meets the size switching condition of the traffic light detection frame, if the target camera currently used is the long-focus camera, the shortest side of the traffic light detection frame with the largest area can be compared with a first preset size threshold value l1, which can be set based on the maximum value of the shortest side of the complete traffic light detection frame that can be captured by the long-focus camera within its shooting range.
[0093] If the shortest side of the traffic light detection frame with the largest area is greater than the first preset size threshold value l1, it indicates that the current shooting distance has reached the upper limit of the shooting range of the long-focus camera, and continuing to use the long-focus camera to capture images will cause the traffic light to exceed the image boundary, so camera switching is needed, that is, the current traffic light detection result triggers the size switching condition of the traffic light detection frame. If the shortest side of the traffic light detection frame with the largest area is not greater than the first preset size threshold value l1, it indicates that the current shooting distance is still within the shooting range of the long-focus camera, and the long-focus camera can continue to be used for shooting, without the need for camera switching, that is, the current traffic light detection result does not trigger the size switching condition of the traffic light detection frame.
[0094] In an embodiment of the present application, the target camera is a medium-focus camera or a short-focus camera, and the determination of whether the traffic light detection result meets the preset camera switching condition includes: determining whether the shortest side of the traffic light detection frame is greater than a second preset size threshold value; in the case where the shortest side of the traffic light detection frame is greater than the second preset size threshold value, determining that the traffic light detection result meets the size switching condition of the traffic light detection frame; and in the case where the shortest side of the traffic light detection frame is not greater than the second preset size threshold value, determining that the traffic light detection result does not meet the size switching condition of the traffic light detection frame.
[0095] In the determination of whether the traffic light detection result meets the size switching condition of the traffic light detection frame, if the target camera currently used is the medium-focus camera or the short-focus camera, the shortest side of the traffic light detection frame with the largest area can be compared with a second preset size threshold value l2, which can be set based on the maximum value of the shortest side of the complete traffic light detection frame that can be captured by the medium-focus camera or the short-focus camera within its shooting range.
[0096] If the shortest side of the traffic light bounding box with the largest area is greater than the second preset size threshold l2, it indicates that the current shooting distance has reached the upper limit of the shooting range of the medium or short camera, and continuing to use the medium or short camera to collect images will cause the traffic light to be out of the image boundary, so camera switching is needed, that is, the current traffic light detection result triggers the size switching condition of the traffic light bounding box. If the shortest side of the traffic light bounding box with the largest area is not greater than the second preset size threshold l2, it indicates that the current shooting distance is still within the shooting range of the medium or short camera, and the medium or short camera can continue to be used for shooting, that is, the current traffic light detection result does not trigger the size switching condition of the traffic light bounding box.
[0097] It should be noted that the above embodiment separately sets the first preset size threshold l1 for the long camera, and sets the same second preset size threshold l2 for the medium and short cameras, because the second preset size threshold l2 is already set to be large enough, and setting the same second preset size threshold can simplify the judgment process to some extent. Of course, those skilled in the art can also set different preset size thresholds for the long, medium and short cameras according to actual needs, wherein the shorter the camera focal length, the larger the corresponding preset size threshold.
[0098] In an embodiment of the present application, the switching of the target camera under the condition that the traffic light detection result meets the preset camera switching condition comprises: switching the target camera from the long camera to the medium camera under the condition that the traffic light detection result meets the size switching condition of the traffic light bounding box and the target camera is the long camera; switching the target camera from the medium camera to the short camera under the condition that the traffic light detection result meets the size switching condition of the traffic light bounding box and the target camera is the medium camera; and switching the target camera from the short camera to the long camera under the condition that the traffic light detection result meets the size switching condition of the traffic light bounding box and the target camera is the short camera.
[0099] The embodiment of the present application can distinguish the following cases when the traffic light detection result meets the size switching condition of the traffic light bounding box and the target camera is switched.
[0100] 1) The target camera is the long camera, which indicates that the distance from the autonomous vehicle to the next traffic light will exceed the range of the complete traffic light that the long camera can capture, so the long camera can be switched to the medium camera to expand the camera's shooting field of view and realize relatively close distance traffic light detection.
[0101] 2) the target camera is a medium focal length camera, which means that the distance from the autonomous vehicle to the next traffic intersection is about to exceed the range of the medium focal length camera that can capture the complete traffic light, so the medium focal length camera can be switched to a short focal length camera to further expand the camera's field of view and achieve closer distance traffic light detection;
[0102] 3) the target camera is a short focal length camera, which means that the distance from the autonomous vehicle to the next traffic intersection is about to exceed the range of the short focal length camera that can capture the complete traffic light, at this time it can be considered that the autonomous vehicle has basically driven to or passed the position of the next traffic light intersection, so it can be switched back to a long focal length camera to capture the traffic light of the next intersection.
[0103] It can be seen that, with the driving of the autonomous vehicle, the above switching process can be regarded as a reciprocating process, for example, the camera switching process when the autonomous vehicle drives from the current position to intersection 1 and then from intersection 1 to intersection 2 can be represented as: long focal length camera-medium focal length camera-short focal length camera-long focal length camera-medium focal length camera-short focal length camera…, and so on.
[0104] In an embodiment of the present application, the previous detection time is the previous detection time corresponding to the traffic light detection result containing a traffic light bounding box, and the determination of whether the traffic light detection result meets the detection time interval switching condition according to the time interval includes: in the case that the time interval between the current detection time and the previous detection time is greater than a preset time interval threshold, it is determined that the traffic light detection result meets the detection time interval switching condition; in the case that the time interval between the current detection time and the previous detection time is not greater than the preset time interval threshold, it is determined that the traffic light detection result does not meet the detection time interval switching condition.
[0105] As mentioned earlier, the previous detection time of the embodiment of the present application refers to the time when the traffic light bounding box is last detected, and the previous detection time is updated each time a traffic light bounding box is detected. The length of the interval between the current detection time and the previous detection time indicates whether the autonomous vehicle has missed detection or has driven to the next traffic intersection.
[0106] Specifically, if the time interval between the current detection time and the previous detection time is greater than a preset time interval threshold t, it indicates that there has been a relatively long period of time without detecting a traffic light, and the probability of long-term missed detection of the camera is small in this case. It is very likely that the autonomous vehicle has driven to the corresponding traffic intersection, and because the distance is too close, the medium focal length camera and the short focal length camera have continuously failed to capture the complete traffic light, so it is necessary to switch the currently used target camera to start the traffic light detection of the next traffic intersection.
[0107] If the time interval between the current detection time and the previous detection time is less than the preset time threshold t, it indicates that the target camera has not captured the traffic light temporarily due to some reasons such as the front vehicle shielding, and in this case, the target camera can be allowed to have a certain fault tolerance space, that is, the target camera is allowed to repeatedly attempt to collect the to-be-detected image until the to-be-detected image collected by the target camera contains a complete traffic light or the preset time interval threshold t is triggered.
[0108] In an embodiment of the present application, the switching the target camera in the case that the traffic light detection result meets the preset camera switching condition comprises: in the case that the traffic light detection result meets the detection time interval switching condition and the target camera is a medium focal length camera or a short focal length camera, switching the target camera from the medium focal length camera or the short focal length camera to a long focal length camera.
[0109] The detection time interval switching condition of the embodiments of the present application is mainly set for the medium focal length camera and the short focal length camera, because for the long focal length camera, it usually starts to collect images when the autonomous vehicle is far away from the traffic intersection, so it is very likely that the long focal length camera cannot detect the traffic light in a continuous period of time, and in this case, it is obviously not suitable to constrain the long focal length camera by the above-mentioned preset time interval threshold, and since the long focal length camera is already a camera that can shoot the farthest distance, there is no basis for switching.
[0110] The medium focal length camera and the short focal length camera are used when the autonomous vehicle is close to the traffic intersection, and under normal circumstances, they can capture complete traffic lights, and if they cannot capture complete traffic lights for a continuous period of time, it indicates that the autonomous vehicle has reached or passed the traffic intersection, and then the medium focal length camera or the short focal length camera currently in use can be switched to a long focal length camera, thereby starting the detection of the traffic light of the next traffic intersection.
[0111] Of course, it should be noted that the skilled in the art can flexibly extend the traffic light detection method of the present application to other numbers of cameras with different focal lengths according to actual needs, for example, only one long focal length camera and one short focal length camera are set, or more than three cameras with different focal lengths are set, which are not listed one by one here.
[0112] In order to facilitate the understanding of the embodiments of the present application, the following describes the embodiments of the present application with reference to the accompanying drawings. Figure 2As shown, a traffic light detection flowchart in an embodiment of the present application is provided. First, two camera switching conditions are defined, one is a traffic light detection box size switching condition set for the case that a traffic light detection box can be detected in the to-be-detected image, and a first preset size threshold l1 and a second preset size threshold l2 are specifically set, and the other is a detection time interval switching condition set for the case that a traffic light detection box cannot be detected in the to-be-detected image, and a preset time interval threshold t is specifically set.
[0113] Then, based on the principle of near large and far small, the long-focus camera sensor 30 is initialized to be used as the target camera to collect the to-be-detected image, a preset traffic light detection model is used for traffic light detection, a traffic light detection result is obtained, and it is judged whether a traffic light is detected according to the traffic light detection result. If not, the image continues to be collected for detection, until a traffic light is detected, and then the traffic light detection box output by the model is further filtered to obtain the traffic light detection box actually concerned by the autonomous vehicle at present.
[0114] Then, it is judged whether the shortest side of the largest-area traffic light detection box after filtering is greater than the first preset size threshold l1. If not, the traffic light detection result can be directly output, and if yes, it is considered that the size switching condition of the traffic light detection box is triggered, and the long-focus camera sensor 30 needs to be switched to the medium-focus camera sensor 60.
[0115] The image collection and detection flow of the medium-focus camera sensor 60 is basically the same as that of the long-focus camera, and the main difference has two points. One difference is that if a traffic light cannot be detected in the to-be-detected image collected by the medium-focus camera, the detection time interval also needs to be calculated. If the detection time interval exceeds the preset time interval threshold t, the detection time interval switching condition is triggered, that is, the medium-focus camera sensor 60 needs to be switched to the long-focus camera sensor 30, and if the preset time interval threshold t is not exceeded, the image continues to be repeatedly collected and detected. The other difference is that the traffic light detection box corresponding to the to-be-detected image collected by the medium-focus camera needs to be compared with the second preset size threshold l2. If the shortest side of the traffic light detection box is greater than the second preset size threshold l2, it is considered that the size switching condition of the traffic light detection box is triggered, that is, the medium-focus camera sensor 60 needs to be switched to the short-focus camera sensor 120.
[0116] The image collection and detection flow of the short-focus camera sensor 120 is basically the same as that of the medium-focus camera, and the main difference is that when the short-focus camera triggers the detection time interval switching condition or the size switching condition of the traffic light detection box, the short-focus camera sensor 120 is switched to the long-focus camera sensor 30.
[0117] Based on Figure 2It can be seen that the traffic light detection process of the application forms a closed loop detection as a whole, that is, the traffic light detection result based on vision is used as the input of camera switching, and the result after camera switching is used as the input of vision detection again. Compared with the traffic light detection scheme based on self-positioning and high-precision map, the adverse effects caused by self-positioning error and high-precision map error are avoided, and the detection accuracy is improved.
[0118] In addition, the traffic light detection process of the application adopts multiple cameras with different focal lengths to alternately collect images, solves the problem of wide detection distance of traffic lights, and automatically switches the multiple cameras with different focal lengths according to the vision detection result. Only one camera is enabled at the same time, which reduces resource consumption and ensures the real-time performance of detection.
[0119] The application also provides a traffic light detection device 300, as shown in Figure 3 The device 300 at least includes an acquisition unit 310, a detection unit 320, a determination unit 330, a switching unit 340 and an output unit 350, wherein:
[0120] The acquisition unit 310 is configured to acquire a to-be-detected image collected by a target camera, the target camera being any one of multiple cameras with different focal lengths.
[0121] The detection unit 320 is configured to detect the to-be-detected image by using a preset traffic light detection model to obtain a traffic light detection result.
[0122] The determination unit 330 is configured to determine whether the traffic light detection result meets a preset camera switching condition, the preset camera switching condition including a size switching condition of a traffic light detection box and a detection time interval switching condition.
[0123] The switching unit 340 is configured to switch the target camera and output a traffic light detection result corresponding to the switched camera in the case that the traffic light detection result meets the preset camera switching condition.
[0124] The output unit 350 is configured to directly output a traffic light detection result corresponding to the target camera in the case that the traffic light detection result does not meet the preset camera switching condition.
[0125] In an embodiment of the application, the traffic light detection result includes multiple traffic light detection boxes, and the determination unit 330 is specifically configured to filter the multiple traffic light detection boxes by using a preset traffic light detection box filtering strategy to obtain filtered traffic light detection boxes, and determine whether the filtered traffic light detection boxes meet the size switching condition of the traffic light detection box.
[0126] In an embodiment of the present application, the determining unit 330 is specifically configured to: determine an effective detection region of the image to be detected; filter the plurality of traffic light detection boxes according to the effective detection region and positions of the traffic light detection boxes, to obtain a first filtering result; determine a maximum area of the traffic light detection box according to the first filtering result; and filter the first filtering result according to the maximum area of the traffic light detection box, to obtain the second filtering result as the filtered traffic light detection box.
[0127] In an embodiment of the present application, the plurality of cameras with different focal lengths include a long-focus camera, a medium-focus camera and a short-focus camera, and the determining unit 330 is specifically configured to: determine whether the traffic light detection result contains a traffic light detection box; in the case that the traffic light detection result contains a traffic light detection box, determine whether the traffic light detection result meets the size switching condition of the traffic light detection box; in the case that the traffic light detection result does not contain a traffic light detection box and the target camera is a long-focus camera, repeatedly perform the step of detecting the image to be detected by using the preset traffic light detection model to obtain a traffic light detection result; and in the case that the traffic light detection result does not contain a traffic light detection box and the target camera is a medium-focus camera or a short-focus camera, determine a time interval between a current detection time and a previous detection time, and determine whether the traffic light detection result meets the detection time interval switching condition according to the time interval.
[0128] In an embodiment of the present application, the target camera is a long-focus camera, and the determining unit 330 is specifically configured to: determine whether a shortest side of the traffic light detection box is greater than a first preset size threshold; in the case that the shortest side of the traffic light detection box is greater than the first preset size threshold, determine that the traffic light detection result meets the size switching condition of the traffic light detection box; and in the case that the shortest side of the traffic light detection box is not greater than the first preset size threshold, determine that the traffic light detection result does not meet the size switching condition of the traffic light detection box.
[0129] In an embodiment of the present application, the target camera is a medium-focus camera or a short-focus camera, and the determining unit 330 is specifically configured to: determine whether a shortest side of the traffic light detection box is greater than a second preset size threshold; in the case that the shortest side of the traffic light detection box is greater than the second preset size threshold, determine that the traffic light detection result meets the size switching condition of the traffic light detection box; and in the case that the shortest side of the traffic light detection box is not greater than the second preset size threshold, determine that the traffic light detection result does not meet the size switching condition of the traffic light detection box.
[0130] In an embodiment of the present application, the switching unit 340 is specifically configured to: in a case where the traffic light detection result meets the size switching condition of the traffic light detection frame and the target camera is a long-focus camera, switching the target camera from the long-focus camera to a medium-focus camera; in a case where the traffic light detection result meets the size switching condition of the traffic light detection frame and the target camera is the medium-focus camera, switching the target camera from the medium-focus camera to a short-focus camera; and in a case where the traffic light detection result meets the size switching condition of the traffic light detection frame and the target camera is the short-focus camera, switching the target camera from the short-focus camera to the long-focus camera.
[0131] In an embodiment of the present application, the previous detection time is a previous detection time corresponding to a case where the traffic light detection result contains a traffic light detection frame, and the determination unit 330 is specifically configured to: in a case where a time interval between the current detection time and the previous detection time is greater than a preset time interval threshold, determining that the traffic light detection result meets the detection time interval switching condition; and in a case where the time interval between the current detection time and the previous detection time is not greater than the preset time interval threshold, determining that the traffic light detection result does not meet the detection time interval switching condition.
[0132] In an embodiment of the present application, the switching unit 340 is specifically configured to: in a case where the traffic light detection result meets the detection time interval switching condition and the target camera is the medium-focus camera or the short-focus camera, switching the target camera from the medium-focus camera or the short-focus camera to the long-focus camera.
[0133] It can be understood that the traffic light detection device described above can implement each step of the traffic light detection method provided in the foregoing embodiments, and the related explanations about the traffic light detection method are all applicable to the traffic light detection device, which will not be described herein again.
[0134] Figure 4 FIG. 1 is a structural schematic diagram of an electronic device according to an embodiment of the present application. It is to be understood that the electronic device shown in FIG. 1 is only an example of the electronic device according to the present application, and the electronic device according to the present application can also have other structures. Figure 4 At the hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The memory can include a memory such as a random-access memory (RAM), and can also include a non-volatile memory such as at least one disk memory. Of course, the electronic device can also include other hardware required by a business.
[0135] The processor, the network interface and the memory can be connected with each other through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, Figure 4 Only one bidirectional arrow is used to represent the bus, but it does not mean that there is only one bus or only one type of bus.
[0136] The memory is used to store programs. Specifically, the program can include program code including computer operation instructions. The memory can include an internal memory and a non-volatile memory, and provide instructions and data for the processor.
[0137] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs, and forms a traffic light detection device at a logical level. The processor executes the program stored in the memory, and is specifically used for executing the following operations:
[0138] Obtaining a to-be-detected image collected by a target camera, the target camera being any one of a plurality of cameras with different focal lengths;
[0139] Detecting the to-be-detected image by using a preset traffic light detection model to obtain a traffic light detection result;
[0140] Determining whether the traffic light detection result meets a preset camera switching condition, the preset camera switching condition including a size switching condition of a traffic light detection frame and a detection time interval switching condition;
[0141] In a case where the traffic light detection result meets the preset camera switching condition, switching the target camera, and outputting a traffic light detection result corresponding to the switched camera;
[0142] In a case where the traffic light detection result does not meet the preset camera switching condition, directly outputting a traffic light detection result corresponding to the target camera.
[0143] The above as described in the present application Figure 1The method performed by the traffic light detection apparatus disclosed in the embodiments shown can be applied in a processor or implemented by the processor. The processor can be an integrated circuit chip with processing capability. In the implementation process, the steps of the method can be completed by hardware integrated logic circuit or software form of instructions in the processor. The processor mentioned above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; or a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium in the art. The storage medium is located in the memory, and the processor reads the information in the memory, and combines the hardware to complete the steps of the method.
[0144] The electronic device can also execute the method performed by the traffic light detection apparatus in the middle of the traffic light, and realize the function of the traffic light detection apparatus in the middle of the traffic light. The embodiments of the present application will not be repeated here. Figure 1 The electronic device can also execute the method performed by the traffic light detection apparatus in the middle of the traffic light, and realize the function of the traffic light detection apparatus in the middle of the traffic light. The embodiments of the present application will not be repeated here. Figure 1 The electronic device can also execute the method performed by the traffic light detection apparatus in the middle of the traffic light, and realize the function of the traffic light detection apparatus in the middle of the traffic light. The embodiments of the present application will not be repeated here.
[0145] The present application also provides a computer readable storage medium, which stores one or more programs, the one or more programs include instructions, when the instructions are executed by an electronic device including a plurality of application programs, the electronic device can execute the method performed by the traffic light detection apparatus in the embodiments shown in the middle of the traffic light, and specifically for executing: Figure 1 The electronic device can also execute the method performed by the traffic light detection apparatus in the middle of the traffic light, and realize the function of the traffic light detection apparatus in the middle of the traffic light. The embodiments of the present application will not be repeated here.
[0146] Obtaining a to-be-detected image collected by a target camera, the target camera being any one of a plurality of cameras with different focal lengths;
[0147] Detecting the to-be-detected image by using a preset traffic light detection model to obtain a traffic light detection result;
[0148] determine whether the traffic light detection result meets a preset camera switching condition, the preset camera switching condition including a size switching condition of a traffic light detection frame and a detection time interval switching condition;
[0149] switch the target camera and output a traffic light detection result corresponding to the switched camera in a case where the traffic light detection result meets the preset camera switching condition;
[0150] directly output the traffic light detection result corresponding to the target camera in a case where the traffic light detection result does not meet the preset camera switching condition.
[0151] Those skilled in the art will understand that embodiments of the present application can be provided as methods, systems, or computer program products. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer-readable program code.
[0152] The present application is described in reference to the flowcharts and / or block diagrams of the methods, apparatus (systems) and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in a flow or multiple flows and / or blocks Figure 1 The functions specified in a flow or multiple flows and / or blocks
[0153] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including instruction apparatus, which implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in a flow or multiple flows and / or blocks Figure 1 The functions specified in a flow or multiple flows and / or blocks
[0154] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide functions for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1one or more processes and / or blocks Figure 1 steps of a function specified in one or more blocks.
[0155] In one typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0156] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory, etc. The memory is an example of computer readable media.
[0157] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.
[0158] It should also be noted that the terms "comprising," "including," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements recited, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without limitation, an element preceded by "comprises a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the recited element.
[0159] Those skilled in the art will appreciate that embodiments of the present application can be devised for a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer readable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.
[0160] The above embodiments are only used to illustrate the present application, but not to limit it. Various modifications and changes can be made by those skilled in the art. Any modification, equivalent replacement, improvement, and the like made within the spirit and principle of the present application shall fall into the scope of claims of the present application.
Claims
1. A traffic light detection method, wherein: The method comprises: Acquire an image to be detected captured by a target camera, wherein the target camera is any one of a plurality of cameras with different focal lengths; Detecting the image to be detected using a preset traffic light detection model to obtain a traffic light detection result; Determining whether the traffic light detection result satisfies a preset camera switching condition, wherein the preset camera switching condition includes a traffic light detection frame size switching condition and a detection time interval switching condition; When the traffic light detection result satisfies the preset camera switching condition, switching the target camera and outputting the traffic light detection result corresponding to the switched camera; When the traffic light detection result does not meet the preset camera switching condition, directly outputting the traffic light detection result corresponding to the target camera; The detection time interval switching condition is determined based on the time interval between the detection time of the current traffic light detection result and the time when the traffic light detection frame was last detected.
2. The method according to claim 1, wherein: The traffic light detection result includes a plurality of traffic light detection frames, and determining whether the traffic light detection result meets a preset camera switching condition includes: Filtering the multiple traffic light detection frames using a preset traffic light detection frame filtering strategy to obtain filtered traffic light detection frames; It is determined whether the filtered traffic light detection frame meets a size switching condition of the traffic light detection frame.
3. The method according to claim 2, wherein: The filtering of the plurality of traffic light detection frames by using a preset traffic light detection frame filtering strategy to obtain filtered traffic light detection frames includes: Determining an effective detection area of the image to be detected; filtering the plurality of traffic light detection frames according to the effective detection area and the position of each traffic light detection frame to obtain a first filtering result; determining a maximum area of the traffic light detection frame according to the first filtering result; The first filtering result is filtered according to the maximum area of the traffic light detection frame to obtain a second filtering result as the filtered traffic light detection frame.
4. The method according to claim 1, wherein: The plurality of cameras with different focal lengths include a telephoto camera, a medium focal length camera, and a short focal length camera, and determining whether the traffic light detection result satisfies a preset camera switching condition includes: Determining whether the traffic light detection result includes a traffic light detection frame; In a case where the traffic light detection result includes a traffic light detection frame, determining whether the traffic light detection result satisfies a size switching condition of the traffic light detection frame; If the traffic light detection result does not include a traffic light detection frame and the target camera is a telephoto camera, repeatedly performing the step of detecting the image to be detected using a preset traffic light detection model to obtain a traffic light detection result; When the traffic light detection result does not include a traffic light detection frame and the target camera is a medium-focus camera or a short-focus camera, determine the time interval between the detection time of the current traffic light detection result and the time when the traffic light detection frame was previously detected, and determine whether the traffic light detection result meets the detection time interval switching condition based on the time interval.
5. The method of claim 1, wherein: The target camera is a telephoto camera, and determining whether the traffic light detection result meets a preset camera switching condition includes: Determining whether the shortest side of the traffic light detection frame is greater than a first preset size threshold; When the shortest side of the traffic light detection frame is larger than a first preset size threshold, determining that the traffic light detection result satisfies a size switching condition of the traffic light detection frame; When the shortest side of the traffic light detection frame is not greater than the first preset size threshold, it is determined that the traffic light detection result does not meet the size switching condition of the traffic light detection frame.
6. The method of claim 1, wherein: The target camera is a medium-focus camera or a short-focus camera, and determining whether the traffic light detection result meets a preset camera switching condition includes: Determining whether the shortest side of the traffic light detection frame is greater than a second preset size threshold; When the shortest side of the traffic light detection frame is larger than a second preset size threshold, determining that the traffic light detection result satisfies a size switching condition of the traffic light detection frame; When the shortest side of the traffic light detection frame is not greater than the second preset size threshold, it is determined that the traffic light detection result does not meet the size switching condition of the traffic light detection frame.
7. The method of claim 1, wherein: When the traffic light detection result satisfies the preset camera switching condition, switching the target camera includes: When the traffic light detection result satisfies the size switching condition of the traffic light detection frame and the target camera is a telephoto camera, switching the target camera from the telephoto camera to a medium-focus camera; If the traffic light detection result satisfies the size switching condition of the traffic light detection frame and the target camera is a medium-focus camera, switching the target camera from a medium-focus camera to a short-focus camera; When the traffic light detection result satisfies a size switching condition of the traffic light detection frame and the target camera is a short-focus camera, the target camera is switched from a short-focus camera to a long-focus camera.
8. The method of claim 4, wherein: Determining whether the traffic light detection result meets the detection time interval switching condition according to the time interval includes: In a case where the time interval is greater than a preset time interval threshold, determining that the traffic light detection result satisfies the detection time interval switching condition; When the time interval is not greater than the preset time interval threshold, it is determined that the traffic light detection result does not meet the detection time interval switching condition.
9. The method of claim 1, wherein: When the traffic light detection result satisfies the preset camera switching condition, switching the target camera includes: When the traffic light detection result meets the detection time interval switching condition and the target camera is a medium-focus camera or a short-focus camera, the target camera is switched from the medium-focus camera or the short-focus camera to a long-focus camera.
10. A traffic light detection device, wherein: The device comprises: an acquisition unit, configured to acquire an image to be detected captured by a target camera, wherein the target camera is any one of a plurality of cameras with different focal lengths; a detection unit, configured to detect the image to be detected using a preset traffic light detection model to obtain a traffic light detection result; a determining unit, configured to determine whether the traffic light detection result satisfies a preset camera switching condition, wherein the preset camera switching condition includes a traffic light detection frame size switching condition and a detection time interval switching condition; a switching unit, configured to switch the target camera if the traffic light detection result satisfies the preset camera switching condition, and output the traffic light detection result corresponding to the switched camera; An output unit, configured to directly output the traffic light detection result corresponding to the target camera if the traffic light detection result does not meet the preset camera switching condition; The detection time interval switching condition is determined based on the time interval between the detection time of the current traffic light detection result and the time when the traffic light detection frame was last detected.
11. An electronic device comprising: processor; as well as A memory arranged to store computer executable instructions, which when executed cause the processor to perform the method of any one of claims 1 to 9.
12. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, causes the electronic device to execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Real-time traffic light identification method
CN109949594A
Traffic light detection method and device based on long- and short-focus camera, and storage medium
CN113947769A