Segmented slope difference curve pre-judging method and automobile headlamp self-adaptive adjusting system
Through the segmented slope difference curve prediction method, the camera is used to detect lane lines and adaptively adjust the headlight angle, which solves the problem that traditional headlights cannot be adjusted in time, eliminates the blind spots of curve lighting and improves night driving safety.
Patent Information
- Application Number
- CN202510792974.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-09-26
AI Technical Summary
Traditional car headlights are unable to adjust in time to the direction of travel, resulting in a lighting blind spot on the outside of the curve. Existing technologies lack real-time dynamic adjustment strategies, and are unable to identify the curve ahead in advance and adaptively adjust the lighting direction, affecting nighttime driving safety.
A segmented slope difference curve prediction method is adopted. Lane lines are detected by cameras, slope angles are calculated segment by segment, the curve type is identified using the difference in adjacent slope angles, and the headlight angle is adaptively adjusted to form a closed loop of detection-prediction-control.
It effectively eliminates blind spots in curve lighting, improves nighttime driving safety, has high real-time and noise resistance capabilities, enhances the security and robustness of the system, and has fault handling links and multi-task concurrent processing capabilities.
Smart Images

Figure CN120708176A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of intelligent transportation and relates to a segmented slope difference curve prediction method and an automobile headlamp self-adaptive adjustment system. Background Art
[0002] During nighttime driving, headlight blind spots are a significant contributing factor to accidents on curves. Traditional automotive headlights, with their fixed horizontal angle, suffer from the following drawbacks: First, there's a problem of delayed illumination on curves. Traditional headlights follow the curve, and their illumination direction can't adjust in time with the direction of travel. This creates an illumination blind spot on the outer edge of the curve, making it difficult for the driver to observe road conditions in advance. Second, traditional methods can't proactively identify the curve ahead and adaptively adjust the headlights' illumination direction. Finally, while some existing solutions use cameras to detect lane markings, they lack a complete "detection-prediction-control" closed loop, particularly lacking a real-time dynamic adjustment strategy for headlight angle. Therefore, a stable curve prediction method is urgently needed to identify the type of curve ahead (left / right / straight ahead) and adaptively adjust the headlight angle based on the curve type and angle to improve nighttime driving safety. Summary of the Invention
[0003] Purpose of the invention: In response to the shortcomings of traditional headlamp control methods and systems, the present invention proposes a segmented slope difference curve prediction method and an automobile headlamp adaptive adjustment system, forming a closed loop of "detection-prediction-control", using lane line detection technology to identify the lane line in front of the vehicle, segmenting the lane line, and calculating the slope angle of each segment one by one. By comparing the slope angle difference of adjacent segments, the front lane type and the automobile headlamp pre-steering angle are obtained, and the horizontal angle of the automobile headlamp is adaptively adjusted based on the detection data to eliminate the blind spot of the curve lighting.
[0004] Technical solution: The present invention provides a segmented slope difference curve prediction method, comprising the following steps:
[0005] Image preprocessing: The camera collects images of the road ahead, and then generates a binary bird's-eye view image through camera calibration, perspective transformation, and threshold processing;
[0006] Lane line extraction: Use the sliding window method to detect lane line pixels, fit the quadratic polynomial curves of the left and right lane lines, and obtain the lane line coordinate point set;
[0007] Segmented slope angle calculation: The lane line is divided into segments using the acquired lane line coordinate point set, and the slope angle of each segment is calculated;
[0008] Curve determination is based on the difference in adjacent slope angles. The slope angle differences of adjacent segments are averaged. If the average angle difference exceeds a threshold, it is determined to be a curve, and the direction of the curve is determined based on the positive or negative sign of the average angle difference. Otherwise, it is determined to be a straight line.
[0009] Furthermore, the lane line extraction uses a sliding window method to detect lane line pixels, fits quadratic polynomial curves of the left and right lane lines, and obtains a lane line coordinate point set, including:
[0010] Initialize the sliding window data, including the number of windows, window height, width, and minimum pixel count. For each window, filter out the lane line pixels within the window based on the current center coordinates and store them in the left and right lane line pixel point sets respectively.
[0011] Fitting a quadratic polynomial curve: Use the least squares method to fit a quadratic polynomial to the extracted lane line pixel set to generate a smooth lane line curve;
[0012] Given a set of pixels Solve the polynomial coefficients (a, b, c) to minimize the fitting error:
[0013]
[0014] The matrix form is: A T Aθ=A T x;
[0015] where θ = [a, b, c] T , x=[x1,x2,...,x N ] T ;
[0016] Fitting condition: When the number of lane line pixels N ≥ 1500, effective fitting is triggered to avoid noise interference.
[0017] Furthermore, the lane line segmentation is as follows:
[0018] Automatically adjust the number of segments according to vehicle speed:
[0019]
[0020] Adaptive segmentation is achieved according to vehicle speed and the maximum range of M is limited to no more than 10;
[0021] v<40km / h, i.e. low-speed scenario: reduce the number of segments, lower the amount of calculation, and ensure real-time performance;
[0022] V≧40km / h, that is, high-speed scenario: the higher the speed, the shorter the time it takes for the vehicle to reach the curve, requiring longer-distance prediction, and increasing the number of segments to refine the lane line slope changes.
[0023] Furthermore, the segment slope angle is calculated as follows:
[0024] Divide a single lane curve into M segments, each segment contains L = N / M points, and for the k-th segment point set Calculate the average slope angle of the segment:
[0025]
[0026] in: is the accumulation of segmented lateral displacement;
[0027] It is the accumulation of absolute values of segmented longitudinal displacement to eliminate the influence of coordinate direction.
[0028] Furthermore, the curve determination based on the slope difference between adjacent lane segments is as follows:
[0029] Calculate the slope difference between adjacent segments: Δθ k =θ k+1 -θ k , then the global slope average angle difference is:
[0030]
[0031] Bend judgment: If T is the threshold, which is used to judge a road as a curve. is the pre-steering angle of the car headlights, and then if For left bend, if The left lane is a right turn, and the right lane is a straight drive; and the left and right lane line detection results are combined for cross-validation.
[0032] Furthermore, it also includes visualization, which visualizes the left / right / straight signs, the pre-steering angle of the car headlights, and the measured distance of the lane line. The specific content is as follows:
[0033] According to the changing trend of the average angle difference of the global slope of the lane line Compare with the threshold to determine whether the road ahead is a curve. If it is a curve, The positive or negative value determines the left / right turn, and the corresponding left / right turn sign is displayed, as well as the corresponding car headlight pre-steering angle; otherwise, the straight sign is displayed;
[0034] The measurement of the measured distance of the lane line is based on perspective transformation, and a mapping relationship between pixel coordinates and actual physical distance is established. The highest point of the lane line fitting curve in the image is obtained, and the y pixel value of this point is converted into the actual physical distance, which is the farthest measured distance of the lane line, and then visualized on the screen.
[0035] The present invention also discloses a vehicle headlamp horizontal angle adaptive adjustment system, comprising:
[0036] The curve prediction module processes the image in front of the vehicle during driving using the segmented slope difference curve prediction method and sends the detection data to the Arduino controller in real time;
[0037] The data processing module parses and extracts the command of the curve prediction module to obtain the current frame number, whether there is a curve, direction, and the vehicle headlight pre-steering angle data;
[0038] The headlight horizontal angle adaptive control module drives the aircraft to adaptively adjust the horizontal angle of the headlights based on the data obtained by the data processing module, and supports the communication abnormality protection mechanism;
[0039] The communication abnormal state processing module defines the communication abnormal state protection mechanism, including three states: normal working state NORMAL, communication timeout warning state WARNING and emergency stop state EMERGENCY_STOP. The initial state is NORMAL.
[0040] Preferably, the data processing module adds a data validity verification mechanism, including:
[0041] Unified direction data format function, allowing fuzzy matching, ensuring that the final stored direction format is unified in lowercase, i.e. straight / right / left;
[0042] Data validity verification function: if the direction value is left or right, the direction is considered valid. Otherwise, the invalid direction is defined as "straight" and the curve flag isCurve is set to false.
[0043] Preferably, the headlamp horizontal angle adaptive control module updates the headlamp position in a non-blocking mode, including:
[0044] Multi-task concurrent processing, that is, using non-blocking mode to handle multiple tasks simultaneously, receiving new serial port commands and checking communication anomalies while moving the headlights;
[0045] Smoothly control the adaptive steering of the headlights, controlling the angle of each headlight movement based on the step size, with each movement taking small steps of 1°, and gradually approaching the target angle through multiple cycles;
[0046] The headlamp horizontal angle adaptive control module is also provided with priority management, which ensures that high-priority tasks are executed first and communication abnormality status checks are executed first by reasonably arranging the task sequence.
[0047] Preferably, the communication abnormality state processing module includes:
[0048] A three-level communication abnormality protection mechanism is established to deal with communication anomalies. The initial state is the normal working state. In the initial state, data is received in real time and the headlights are controlled by data information to perform adaptive horizontal adjustment.
[0049] If the time from the last data reception exceeds the timeout threshold TIMEOUT, the state will be switched to the communication timeout warning state. In the communication timeout warning state, the current angle will be maintained and new signals will be waited for. After receiving a valid signal, the normal working state will be restored.
[0050] If the time from the last data reception exceeds twice the timeout threshold TIMEOUT, the state is switched to the emergency stop state. In the emergency stop state, the headlights immediately return to the center and the horizontal adjustment of the headlights is stopped.
[0051] Beneficial effects:
[0052] 1. The present invention discloses a segmented slope difference curve prediction method with low computational complexity, high real-time performance, and strong noise resistance. 2. By verifying this function through data validity, the system significantly improves the fault tolerance for abnormal input data while ensuring the steering accuracy of the aircraft, which is an important guarantee for the safety and robustness of the headlamp adaptive control system. 3. A three-level communication abnormality protection mechanism is established. This processing mechanism ensures the accuracy of the headlamp adaptive control through hierarchical response, smooth transition, and safety protection, and constructs a complete fault processing link of "detection-prediction-control". 4. The non-blocking design of the headlamp adaptive control has the functions of multi-task concurrent processing and controlling the smooth steering of the headlamp. Even in the communication abnormality state, the system can still continue to process other tasks (such as sensor data reception, communication status check, etc.), and the entire control system will not be paralyzed due to communication abnormality. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 This is a flow chart of the segmented slope difference curve prediction algorithm of the present invention;
[0054] Figure 2 It is an execution diagram of the segmented slope difference curve prediction algorithm in the present invention;
[0055] Figure 3 This is a flow chart of the automobile headlamp horizontal angle adaptive adjustment system of the present invention;
[0056] Figure 4 It is an execution diagram of the data validity verification mechanism in the present invention;
[0057] Figure 5 It is an execution diagram of the automobile headlamp horizontal angle adaptive adjustment system in the present invention. DETAILED DESCRIPTION
[0058] In order to better understand the technical solution of the present application, a detailed description will be given below with reference to the accompanying drawings and specific implementation methods.
[0059] like Figure 1 FIG. 1 is a flow chart of a segmented slope difference curve prediction method based on lane line detection designed by the present invention. The specific steps are as follows:
[0060] (1) Image preprocessing: The camera collects the road image ahead, and then generates a binary bird's-eye view image through camera calibration, perspective transformation, and threshold processing;
[0061] Camera calibration is the process of mapping camera image pixel coordinates to real-world 3D coordinates using a calibration object of known geometry (in this example, a multi-view checkerboard image is used as the calibration image). Its core goal is to solve the camera's intrinsic parameter matrix and distortion coefficients to eliminate lens distortion and achieve scale restoration.
[0062] It should be noted that the image captured by the camera is a two-dimensional projection of a three-dimensional scene, and there is a phenomenon of perspective distortion. That is, the lane lines parallel to the ground that need to be detected and identified in this embodiment will converge at the vanishing point in the image, forming a trapezoidal structure. The presentation effect of the lane lines appearing larger when near and smaller when far will result in a low pixel density of the lane lines in the distance, making detection difficult.
[0063] A 9×6 checkerboard image of known size is used as the calibration object. The correspondence between the world coordinates (3D) and image coordinates (2D) of the corner points within the checkerboard is established. The specific mathematical expression is as follows:
[0064]
[0065] Where: s is the scale factor; K is the camera intrinsic parameter matrix: f x ,f y : focal length (in pixels), c x , c y : Principal point (center of the image, usually the width and height of the image). [R|t] is the camera extrinsic matrix, describing the position and orientation of the camera in the world coordinate system, where R is the rotation matrix (3×3) and t is the translation vector (3×1).
[0066] Perspective transformation defines the source point matrix as the four selected points in the original image, forming an irregular quadrilateral (lane line area), and the target point matrix D as the corresponding four points in the transformed image, forming a rectangle (bird's eye view). Through a homography matrix M, its two-dimensional projection transformation relationship is constructed. The matrix satisfies:
[0067] D i =M·Si (i=1,2,3,4)
[0068] Where M is represented by:
[0069]
[0070] Determine the homography matrix M, transform the source and target points into homogeneous coordinates, construct the linear equation system Ah=0, where h is the element vector of M, use the least squares method to solve h, and normalize it so that h 33 =1.
[0071] It is known that for each pixel (x′, y′) in the bird's-eye view, calculate its corresponding position (x, y) in the original image. The calculation formula is as follows:
[0072]
[0073] Thresholding is a key preprocessing step for lane detection. Its core goal is to extract the white and yellow lane lines from the color image captured by the camera using a multi-color space fusion strategy, combining the characteristics of the HLS and HSV color spaces. This generates a binary image containing only the lane lines (white pixels represent lane lines, black pixels represent background). This step, through color space conversion and thresholding, eliminates interfering factors such as road surface texture and shadows.
[0074] Through the coordinated efforts of camera calibration, perspective transformation, and threshold processing, high-quality lane line binary images can be stably output in complex environments, providing high-quality input for subsequent lane line fitting and curve detection.
[0075] (2) Lane line extraction: The lane line pixels are searched row by row in the binary image of the bird's-eye view using the sliding window method. Then, a quadratic polynomial curve is fitted using the least squares method to generate the coordinate point set of the left and right lane lines.
[0076] The sliding window method detects lane line pixels. The specific steps are as follows:
[0077] Sliding window initialization, number of windows: N window =9, Window height: h=height / / N window , window width: 2×margin (margin=100) and minimum number of pixels: minpix=50 (stop updating the window center when the number of pixels in the window is insufficient).
[0078] Window pixel search, for each window, according to the current center coordinate (x c ,y c) Filter out the lane line pixels (good_x, good_y) in the window. If the number of pixels exceeds minpix = 50, update the center of the next window to the horizontal mean of the current pixel, otherwise keep the center unchanged.
[0079] Collect pixel points and store the valid pixel points of all windows into the left and right lane line lists (left_x, left_y) and (right_x, right_y) respectively.
[0080] Fit the quadratic polynomial curve of the left and right lane lines, and use the least squares method to fit the quadratic polynomial x=ay to the extracted lane line pixel point set 2 +by+c, generate smooth lane curves. Given a set of pixel points Solve the polynomial coefficients (a, b, c) to minimize the fitting error:
[0081]
[0082] The matrix form is: A T Aθ=A T x
[0083] where θ = [a, b, c] T , x=[x1,x2,...,x N ] T .
[0084] Fitting condition: When the number of lane line pixels N ≥ 1500, effective fitting is triggered to avoid noise interference.
[0085] It should be noted that the lane line coordinate point set is based on the coefficients (a, b, c) obtained by the above fitting, generating continuous x values within the image range (y from 0 to the image height): x = ay 2 +by+c, thus obtaining the complete coordinate point set of the left and right lane lines.
[0086] (3) Segmented slope angle calculation: The lane line is divided into segments using the acquired lane line coordinate point set, and the slope angle of each segment is calculated;
[0087] It should be noted that in this embodiment, the lane segmentation part adopts an adaptive segmentation strategy. The number of segments (M) is adaptively adjusted based on the vehicle speed and the maximum range of M is limited to no more than 10. This method can dynamically balance detection accuracy and computing resources. The mathematical expression is as follows:
[0088]
[0089] v<40km / h (low-speed scenario): Reduce the number of segments, lower the amount of calculation, ensure real-time performance, and avoid delays caused by excessive calculations;
[0090] v≧40km / h (high-speed scenario): The higher the speed, the shorter the time it takes for the vehicle to reach the curve, requiring longer-distance prediction. Increasing the number of segments can refine the lane line slope changes and improve the recognition accuracy of long curvature curves.
[0091] In the calculation of segmented slope angle, a single lane curve is divided into M segments, each segment contains L = N / M points (N is the number of pixels of the lane line), and the kth segment point set is Calculate the average slope angle of the segment:
[0092]
[0093] in:
[0094] is the accumulation of segmented lateral displacement;
[0095] It is the accumulation of absolute values of segmented longitudinal displacement (eliminating the influence of coordinate direction).
[0096] (4) Curve determination based on adjacent slope angle differences: The slope angle differences of adjacent segments are averaged. If the average angle difference exceeds the threshold, it is determined to be a curve, and the direction of the curve (left / right) is determined based on the sign of the average angle difference. Otherwise, it is determined to be a straight line. The calculation process is as follows:
[0097] Calculate the slope difference between adjacent segments: Δθ k =θ k+1 -θ k , then the global slope average angle difference is:
[0098]
[0099] Bend judgment: If (Threshold T = 2°), it is determined to be a curve, is the pre-steering angle of the car headlights, and then if For left bend, if The system uses the left and right lane line detection results to perform cross-validation to improve the accuracy of curve detection and car headlight pre-steering angle calculation.
[0100] Compared with the traditional curvature radius method or the head-to-tail slope method, the segmented slope difference curve prediction method of the present invention has the following advantages, as shown in Table 1.
[0101] Table 1 is a comparison and analysis of the performance of multiple curve detection algorithms
[0102]
[0103] It should be noted that the segmented slope difference curve prediction method of the present invention has lower computational complexity than the curvature radius method, and its real-time performance is much higher than the curvature radius method. In addition, the segmented slope difference can reduce a series of noises such as local occlusion and dotted line breakpoints. In comparison, the curvature radius method will cause the curvature calculation to fail when there is local occlusion, and its fitting error will increase when there is a dotted line breakpoint. The head and tail slope method is extremely dependent on the head and tail ends. Once there is local occlusion or dotted line breakpoints, it will cause abnormal curve judgment.
[0104] Furthermore, the present invention can detect and identify compound curves by establishing a slope change matrix, Θ = [Δθ1Δθ2···Δθ M-1 ], M is the number of segments that the lane line is divided into.
[0105] When the signs in Θ change alternately, it is determined to be an S-shaped curve, as shown in Table 2:
[0106] Table 2 shows the slopes between different segments of the lane line.
[0107] <![CDATA[Δθ1]]> <![CDATA[Δθ2]]> <![CDATA[Δθ3]]> <![CDATA[Δθ4]]> <![CDATA[Δθ5]]> <![CDATA[Δθ6]]> 5° 1° -3° -8° -4° 1°
[0108] (5) Visualization: Visualize the signboards (left turn / right turn / straight ahead), the pre-steering angle of the car headlights, and the measured distance of the lane lines to improve the driving safety and comfort of the driver and passengers.
[0109] According to the changing trend of the average angle difference of the global slope of the lane line By comparing with the threshold, we can know whether the road ahead is a curve. If it is a curve, then according to The positive or negative value determines whether it is a left or right turn, and the corresponding left / right turn sign is displayed, as well as the corresponding car headlight pre-steering angle; otherwise, a straight sign is displayed.
[0110] To measure the measured distance of the lane line, it is necessary to establish a mapping relationship between pixel coordinates and actual physical distance based on perspective transformation. The highest point of the lane line fitting curve in the image is obtained, and the y pixel value of this point is converted into the actual physical distance, which is the farthest measured distance of the lane line. This is then visualized on the screen. The specific implementation process is as follows:
[0111] First, calibrate the longitudinal / lateral conversion coefficient:
[0112] Vertical calibration: Place a marker at a known distance (30 meters) and measure its pixel position in the bird's-eye view. The calculation formula is as follows:
[0113]
[0114] in:
[0115] ym_per_pix: vertical conversion coefficient, the actual vertical distance represented by each pixel (meters / pixel);
[0116] actual_dis: actual distance; pic_dis: pixel distance from the bottom of the image to the landmark in the bird's-eye view.
[0117] Lateral calibration: Given a known lane width (3.7 meters), measure its pixel width in the bird's-eye view. The calculation formula is as follows:
[0118]
[0119] in:
[0120] xm_per_pix: horizontal conversion coefficient, the actual horizontal distance represented by each pixel (meters / pixel);
[0121] actual_width: actual lane width; pic_width: pixel width of the lane in the bird's-eye view.
[0122] Secondly, in the bird's-eye view after perspective change, the bottom of the image corresponds to the vehicle position (y=0 meters), and the top of the image corresponds to the farthest visible distance. Therefore, by obtaining the highest point (minimum y pixel value) of the lane line fitting curve,
[0123] Converting the y pixel value of the point to the actual distance is the measured distance of the lane line. The calculation formula is as follows:
[0124] max_dis=(image_height-y pixel )×ym_per_pix
[0125] in:
[0126] y pixel : y coordinate of the highest point of the lane line fitting curve (pixels);
[0127] image_height: the height of the bird's-eye view image (pixels);
[0128] ym_per_pix: vertical conversion coefficient.
[0129] Finally, the measured distance of the lane line is calculated in real time and the calculation results are visualized on the screen.
[0130] For example, Figure 2 This is the execution flow chart of the segmented slope difference curve prediction algorithm in the present invention (the execution flow chart of the curve prediction module in the vehicle headlight horizontal angle adaptive adjustment system). Figure 2As shown, during the driving process of the car, the front image and the current speed of the car are obtained in real time through the camera and speed sensor. The camera calibration, perspective transformation and threshold processing in the image preprocessing work together to stably output a high-quality lane line binary image; enter the lane line extraction module, use the sliding window method to collect lane line pixel points in the binary image, and use the least squares method to fit the quadratic polynomial to the pixel point set to generate smooth left and right lane line curves to obtain a complete lane line coordinate point set; according to the current speed of the car obtained in real time, the lane line is adaptively segmented. When the speed is lower than 40km / h, the default M is 5 segments. When the speed is higher than 40km / h, one segment is added for every 40km / h, and M does not exceed 10. The slope angle of each lane line segment is calculated separately, and the global slope average angle difference is obtained by taking the difference between the slope angles of adjacent segments. like (Threshold T is 2°), it is determined to be a curve and isCurve is set to true, Pre-steering angle for car headlights Then if For left turn and set direction to "left", if For a right turn, set direction to "right"; otherwise, for a straight drive, set isCurve to false and direction = "straight". Finally, cross-validation is performed on the combined left and right lane line detection data to improve the stability of curve detection and headlight pre-steering angle calculation, and the data is sent to the controller.
[0131] like Figure 3 FIG. 1 is a flow chart of a vehicle headlamp horizontal angle adaptive adjustment system designed by the present invention, and the specific steps are as follows:
[0132] The curve prediction module processes the image ahead of the vehicle during driving using the segmented slope difference curve prediction method based on lane line detection, and sends the detection data to the Arduino controller in real time.
[0133] The data processing module parses and extracts the commands of the curve prediction module to obtain data such as the current frame number, whether there is a curve, direction, and the pre-steering angle of the car headlights (cmd_id, isCurve, direction, and turnAngle).
[0134] In the data processing module, a new function has been added to unify the direction data format, allowing fuzzy matching (such as "Straight", "RIGHT", "left", etc.). This enhances robustness while ensuring that the final stored direction format is unified in lowercase (straight / right / left).
[0135] In the data processing module, a new data validation mechanism has been added. If the direction value is (left / right), the direction is considered valid. Otherwise, the invalid direction is set to straight and the curve sign is removed. Invalid data (empty strings, garbled characters, or irrelevant characters) or communication errors can cause the headlights to misinterpret the direction (for example, misinterpreting "right"). Direction validation filters out invalid data, preventing headlights from misdirecting to oncoming vehicles and causing dazzling accidents, thereby ensuring system stability. Table 3 shows specific application scenarios of the data validation mechanism.
[0136] Table 3 Specific application scenarios of data validity verification mechanism
[0137]
[0138] Through this mechanism, the system significantly improves its fault tolerance to abnormal input data while ensuring the aircraft's steering accuracy, and is an important guarantee for the safety and robustness of the adaptive headlamp control system.
[0139] For example, Figure 4 This is the execution diagram of the data validity verification mechanism in the present invention. Figure 4 As shown in the figure, as the host computer processes the front image of the vehicle in real time through the segmented slope difference curve prediction method based on lane line detection, it receives the original data (cmd_id, isCurve, direction and turnAngle), and performs fuzzy matching on the direction data (such as "Straight", "RIGHT", "left", etc.). If the match is unsuccessful, it proves that the data is invalid data (such as: empty string, garbled code or irrelevant characters, etc.). In order to eliminate the interference of invalid data, it is defined as "straight" and the curve mode isCurve is determined to be false. Otherwise, isCurve and direction in the data are uniformly converted to lowercase to facilitate subsequent direction validity verification; then it is determined whether the direction in the data contains "left" or "right". If not, it is determined to be an invalid direction and defined as "straight". The curve mode isCurve is turned off and false. Otherwise, it is defined as a valid direction, isCurve is determined to be true, and the steering angle of the car headlights should be calculated according to turnAngle (constrained angle range). Finally, a valid instruction is output based on the data.
[0140] The headlight horizontal angle adaptive control module drives the aircraft to adaptively adjust the horizontal angle of the headlights based on the data analyzed and obtained by the data processing module, and supports the communication abnormality status protection mechanism.
[0141] The specific control process of the headlamp level adaptive control module is as follows:
[0142] First, calculate the target angle tragetAngle. If isCurve is false and the direction is "straight", define targetAngle as MIDDLE_ANGLE (90°). If isCurve is true and the direction is "left", the current targetAngle is the sum of MIDDLE_ANGLE and turnAngle. Conversely, if the direction is "right", the targetAngle is the difference between the two.
[0143] Next, let currentAngle be the current angle of the vehicle's headlights. The difference between currentAngle and targetAngle, angleDiff, is calculated. The aircraft-driven headlight steering step size, step, is determined based on the value of angleDiff. If angleDiff is greater than 5°, the step size is doubled to improve response speed.
[0144] Finally, the current angle of the headlight is updated and limited to a safe and reasonable range of the headlight steering angle. The aircraft is then controlled to drive the headlight to rotate to the current angle.
[0145] The headlamp horizontal angle adaptive control module uses a non-blocking mode to update the headlamp position, including:
[0146] Multi-task concurrent processing, that is, the use of non-blocking mode can handle multiple tasks simultaneously, can receive new serial port commands and check communication anomalies while moving the headlights, making the control module highly real-time.
[0147] Smoothly control the adaptive steering of the headlights, controlling the angle of each headlight movement based on the step size. Each movement is in small steps (1°), gradually approaching the target angle through multiple cycles to avoid severe headlight shaking.
[0148] Priority management ensures that high-priority tasks (such as communication abnormality status inspection) are executed first by reasonably arranging the task sequence.
[0149] The communication abnormal state processing module defines the communication abnormal state protection mechanism, which includes three states: NORMAL (normal working state), WARNING (communication timeout warning state) and EMERGENCY_STOP (emergency stop state).
[0150] The specific operation mode of the communication abnormal state protection mechanism is as follows:
[0151] The initial state is NORMAL, in which data is received in real time and used to control the headlights' horizontal adaptive adjustment. If the time since the last data reception exceeds the TIMEOUT threshold, the state switches to the communication timeout warning state. In this state, the current angle is maintained, waiting for a new signal, and normal operation resumes upon receiving a valid signal. If the time since the last data reception exceeds twice the TIMEOUT, the state switches to the emergency stop state, in which the headlights immediately return to center and horizontal adjustment ceases, preventing prolonged signal loss from causing the headlights to continuously point in the wrong direction. Table 4 shows a scenario-based analysis of the advantages of adaptive headlight horizontal angle control under the three-level communication abnormality protection mechanism.
[0152] Table 4. Horizontal angle adaptive control of vehicle headlights under the three-level communication abnormal state protection mechanism
[0153]
[0154]
[0155] For example, Figure 5 This is the execution diagram of the vehicle headlight horizontal angle adaptive adjustment system in the present invention. Figure 5 As shown in the figure, when the vehicle's headlamp horizontal angle adaptive adjustment system is activated, the host computer first needs to predict the curve and, based on the curve prediction, send detection data (including: command ID, whether it is a curve, angle, and direction) to the lower computer in real time. The lower computer checks the communication status in real time. If the communication status is NORMAL (normal working state), it receives the serial port data and verifies the data validity. If the data is invalid, it is forced to go straight. Otherwise, the data is valid, the curve direction / angle is analyzed, and the target angle (targetAngle) is calculated. Then, the lower computer is driven to adaptively adjust the horizontal angle of the headlamp and update the current angle (currentAngle). If the communication status is WARNING (communication timeout warning status), the headlights are controlled to maintain the current angle to avoid frequent adjustments of the aircraft due to signal loss, and wait for new data. If new data is received in this state, the communication status is updated to NORMAL. Conversely, if the timeout reaches twice the time, the communication status is updated to EMERGENCY_STOP (emergency stop status), driving the aircraft to control the headlights to return to the center immediately, determine the basic range of headlight illumination, and avoid long-term headlight pointing in the wrong direction, which may lead to traffic accidents. Then, the adaptive adjustment of the headlights is stopped. Finally, during system operation, the current system status is regularly fed back to the host computer.
[0156] The above embodiments are intended only to illustrate the technical concepts and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. They are not intended to limit the scope of protection of the present invention. Any equivalent changes or modifications made in accordance with the spirit of the present invention are intended to be covered by the scope of protection of the present invention.
Claims
1. A segmented slope difference curve prediction method, characterized in that: The following steps are involved: Image preprocessing: The camera collects images of the road ahead, and then generates a binary bird's-eye view image through camera calibration, perspective transformation, and threshold processing; Lane line extraction: Use the sliding window method to detect lane line pixels, fit the quadratic polynomial curves of the left and right lane lines, and obtain the lane line coordinate point set; Segmented slope angle calculation: The lane line is divided into segments using the acquired lane line coordinate point set, and the slope angle of each segment is calculated; Curve determination is based on the difference in adjacent slope angles. The slope angle differences of adjacent segments are averaged. If the average angle difference exceeds a threshold, it is determined to be a curve, and the direction of the curve is determined based on the positive or negative sign of the average angle difference. Otherwise, it is determined to be a straight line.
2. The method for predicting a curve using segmented slope difference according to claim 1, characterized in that: The lane line extraction method uses a sliding window method to detect lane line pixels, fits the quadratic polynomial curves of the left and right lane lines, and obtains the lane line coordinate point set, including: Initialize the sliding window data, including the number of windows, window height, width, and minimum pixel count. For each window, filter out the lane line pixels within the window based on the current center coordinates and store them in the left and right lane line pixel point sets respectively. Fitting a quadratic polynomial curve: Use the least squares method to fit a quadratic polynomial to the extracted lane line pixel set to generate a smooth lane line curve; Given a set of pixels Solve the polynomial coefficients (a, b, c) to minimize the fitting error: The matrix form is: A T Aθ=A T x; such as,θ=[a,b,c] T , x=[x1,x2,…,x N ] T 4 Fitting condition: When the number of lane line pixels N ≥ 1500, effective fitting is triggered to avoid noise interference.
3. The method for predicting a curve using segmented slope difference according to claim 1, wherein: The lane line segments are as follows: Automatically adjust the number of segments according to vehicle speed: Adaptive segmentation is achieved according to vehicle speed and the maximum range of M is limited to no more than 10; v<40km / h, i.e. low-speed scenario: reduce the number of segments, lower the amount of calculation, and ensure real-time performance; V≧40km / h, that is, high-speed scenario: the higher the speed, the shorter the time it takes for the vehicle to reach the curve, requiring longer-distance prediction, and increasing the number of segments to refine the lane line slope changes.
4. The method for predicting a curve using segmented slope difference according to claim 1, characterized in that: The segment slope angle is calculated as follows: Divide a single lane curve into M segments, each segment contains L = N / M points, and for the k-th segment point set Calculate the average slope angle of the segment: in: is the accumulation of segmented lateral displacement; It is the accumulation of absolute values of segmented longitudinal displacement to eliminate the influence of coordinate direction.
5. The method for predicting a curve using segmented slope difference according to claim 4, characterized in that: Curve determination based on the slope difference between adjacent lane segments is as follows: Calculate the slope difference between adjacent segments: Δθ k =θ k+1 -θ k , then the global slope average angle difference is: Bend judgment: If T is the threshold, which is used to judge a road as a curve. is the pre-steering angle of the car headlights, and then if For left bend, if The left lane is a right turn, and the right lane is a straight drive; and the left and right lane line detection results are combined for cross-validation.
6. The method for predicting a curve using segmented slope difference according to claim 1, characterized in that: It also includes visualization, which visualizes the left / right / straight signs, the pre-steering angle of the car headlights, and the measured distance of the lane line. The specific contents are as follows: According to the changing trend of the average angle difference of the global slope of the lane line Compare with the threshold to determine whether the road ahead is a curve. If it is a curve, The positive or negative value determines the left / right turn, and the corresponding left / right turn sign is displayed, as well as the corresponding car headlight pre-steering angle; otherwise, the straight sign is displayed; The measurement of the measured distance of the lane line is based on perspective transformation, and a mapping relationship between pixel coordinates and actual physical distance is established. The highest point of the lane line fitting curve in the image is obtained, and the y pixel value of this point is converted into the actual physical distance, which is the farthest measured distance of the lane line, and then visualized on the screen.
7. A vehicle headlight horizontal angle adaptive adjustment system, characterized in that: include: A curve prediction module processes the image ahead of the vehicle during driving using the segmented slope difference curve prediction method described in any one of claims 1 to 6, and sends detection data to the Arduino controller in real time; The data processing module parses and extracts the command of the curve prediction module to obtain the current frame number, whether there is a curve, direction, and the vehicle headlight pre-steering angle data; The headlight horizontal angle adaptive control module drives the aircraft to adaptively adjust the horizontal angle of the headlights based on the data obtained by the data processing module, and supports the communication abnormality protection mechanism; The communication abnormal state processing module defines the communication abnormal state protection mechanism, including three states: normal working state NORMAL, communication timeout warning state WARNING and emergency stop state EMERGENCY_STOP. The initial state is NORMAL.
8. The vehicle headlamp horizontal angle adaptive adjustment system according to claim 7, characterized in that: The data processing module adds a new data validity verification mechanism, including: Unified direction data format function, allowing fuzzy matching, ensuring that the final stored direction format is unified in lowercase, i.e. straight / right / left; Data validity verification function. If the direction value is left or right, the direction is considered valid. Otherwise, the invalid direction is defined as "straight" and the curve flag isCurve is set to false.
9. The vehicle headlamp horizontal angle adaptive adjustment system according to claim 7, characterized in that: The headlamp horizontal angle adaptive control module updates the headlamp position in a non-blocking mode, including: Multi-task concurrent processing, that is, using non-blocking mode to handle multiple tasks simultaneously, receiving new serial port commands and checking communication anomalies while moving the headlights; Smoothly control the adaptive steering of the headlights, controlling the angle of each headlight movement based on the step size, with each movement taking small steps of 1°, and gradually approaching the target angle through multiple cycles; The headlamp horizontal angle adaptive control module is also provided with priority management, which ensures that high-priority tasks are executed first and communication abnormality status checks are executed first by reasonably arranging the task sequence.
10. The vehicle headlamp horizontal angle adaptive adjustment system according to claim 7, characterized in that: The communication abnormality state processing module includes: A three-level communication abnormality protection mechanism is established to deal with communication anomalies. The initial state is the normal working state. In the initial state, data is received in real time and the headlights are controlled by data information to perform adaptive horizontal adjustment. If the time from the last data reception exceeds the timeout threshold TIMEOUT, the state will be switched to the communication timeout warning state. In the communication timeout warning state, the current angle will be maintained and new signals will be waited for. After receiving a valid signal, the normal working state will be restored. If the time from the last data reception exceeds twice the timeout threshold TIMEOUT, the state is switched to the emergency stop state. In the emergency stop state, the headlights immediately return to the center and the horizontal adjustment of the headlights is stopped.