Sun visor control method, apparatus, electronic device and storage medium
By acquiring facial images of users inside the vehicle, obtaining the sunlight boundary line and the line connecting the eyes, and calculating the rotation angle and extension length of the sun visor, the problem of low accuracy in automatic sun visor control is solved, enabling precise adjustment of the sun visor and improving driving safety and comfort.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- BEIJING CO WHEELS TECH CO LTD
- Filing Date
- 2025-12-15
- Publication Date
- 2026-06-25
AI Technical Summary
The existing automatic sun visor control system has low accuracy and cannot accurately determine whether sunlight is shining into the driver's eyes, causing the driver to frequently make manual adjustments, which distracts the driver and increases driving risks.
By acquiring facial images of users inside the vehicle, obtaining the sunlight boundary line and the line connecting the eyes, calculating the first distance and the second distance, and calculating the rotation angle and extension length of the sun visor based on these distances, the sun visor can be automatically adjusted.
It improves the accuracy of automatic control of the sun visor, reduces the driver's workload, enhances driving safety and comfort, and reduces driving safety risks.
Smart Images

Figure CN2025142577_25062026_PF_FP_ABST
Abstract
Description
Sun visor control methods, devices, electronic equipment and storage media
[0001] Cross-references to related applications
[0002] This application claims priority to Chinese Patent Application No. 202411886287.2, filed on December 19, 2024, entitled “Sunshade Control Method, Apparatus, Electronic Device and Storage Medium”, the entire contents of which are incorporated herein by reference. Technical Field
[0003] This disclosure relates to the field of vehicle control technology, and in particular to a sun visor control method, device, electronic device and storage medium. Background Technology
[0004] A vehicle sun visor is a panel-like structure installed above the windshield of a car. Its main function is to prevent strong sunlight from shining directly into the driver's eyes, thereby affecting driving safety.
[0005] Currently, some sun visors have a fixed structure, requiring users to manually adjust them for optimal sun shading. However, this manual adjustment method is inconvenient and uncomfortable for the driver, especially during driving, as frequent manual adjustments can distract the driver and increase driving risks.
[0006] Another current method for sun visors uses automatic control. It employs photosensitive elements such as photoresistors or photovoltage sensors to collect ambient light intensity. Based on this intensity, it determines whether to activate the sun visor and the shading range. The sun visor activates when the light intensity exceeds a certain threshold, and the greater the light intensity, the wider the shading range. However, this method relies on light intensity for control, which cannot accurately represent whether sunlight is actually reaching the driver's eyes. Therefore, the accuracy of this automatic control method is relatively low. Summary of the Invention
[0007] In view of the above problems, this application proposes a sunshade control method, device, electronic device and storage medium to solve the problem of low accuracy of automatic sunshade control.
[0008] According to one aspect of an embodiment of this application, a sun visor control method is provided, the method comprising:
[0009] Acquire facial images of the user inside the vehicle, and obtain the sunlight boundary line and the eye-to-eye line of the user in the facial image;
[0010] Calculate the first distance between the sunlight dividing line and the eye-to-eye connection line, and calculate the second distance between the user's eyes and the sun visor;
[0011] The rotation angle of the sun visor is calculated based on the first distance and the second distance, and the extension length of the sun visor is calculated based on the first distance;
[0012] Adjust the sunshade according to the rotation angle and the extension length.
[0013] Optionally, calculating the rotation angle of the sun visor based on the first distance and the second distance includes: calculating the ratio of the first distance to the second distance, performing an arcsine calculation on the ratio to obtain a target angle, and determining the rotation angle of the sun visor as the product of the target angle and a preset angle scaling ratio.
[0014] Optionally, calculating the extension length of the sun visor based on the first distance includes: multiplying the first distance by a preset length scaling factor to determine the extension length of the sun visor.
[0015] Optionally, calculating the first distance between the sunlight dividing line and the eye-connecting line includes: calculating candidate distances between multiple pairs of first and second pixels; in each pair of first and second pixels, the first pixel is a pixel on the sunlight dividing line, and the second pixel is a pixel on the eye-connecting line, and the first and second pixels are located on the same vertical line; calculating the average and standard deviation of the candidate distances, and determining the sum of the average and standard deviation as the first distance between the sunlight dividing line and the eye-connecting line.
[0016] Optionally, calculating the second distance between the user's eyes and the sun visor includes: obtaining the vertical distance between the user's eyes and the camera; calculating the coordinates of the user's eyes in the camera coordinate system based on the vertical distance; and calculating the second distance between the user's eyes and the sun visor based on the coordinates of the user's eyes in the camera coordinate system and a preset coordinate of the sun visor in the camera coordinate system.
[0017] Optionally, adjusting the sun visor according to the rotation angle and the extension length includes: adjusting the sun visor according to the rotation angle; stopping the rotation of the sun visor when the sun visor reaches a preset maximum angle but has not reached the rotation angle, and continuing to adjust the sun visor according to the extension length; or, adjusting the sun visor according to the extension length; stopping the extension of the sun visor when the sun visor reaches a preset maximum length but has not reached the extension length, and continuing to adjust the sun visor according to the rotation angle.
[0018] Optionally, adjusting the sun visor according to the rotation angle and the extension length includes: calculating a target rotation angle based on a preset angle weight and the rotation angle, and adjusting the sun visor according to the target rotation angle; calculating a target extension length based on a preset length weight and the extension length, and adjusting the sun visor according to the target extension length.
[0019] Optionally, after acquiring the sunlight boundary line and the user's eye-connecting line in the facial region image, the method further includes: determining whether the sunlight boundary line is located below the eye-connecting line; calculating the first distance between the sunlight boundary line and the eye-connecting line, and calculating the second distance between the user's eyes and the sun visor, includes: when the sunlight boundary line is not located below the eye-connecting line, calculating the first distance between the sunlight boundary line and the eye-connecting line, and calculating the second distance between the user's eyes and the sun visor.
[0020] According to another aspect of the embodiments of this application, a sunshade control device is provided, the device comprising:
[0021] The acquisition module is used to acquire facial region images of users inside the vehicle, and to acquire the sunlight boundary line and the eye-to-eye connection line of the user in the facial region image;
[0022] The first calculation module is used to calculate the first distance between the sunlight dividing line and the eye connection line, and to calculate the second distance between the user's eyes and the sun visor;
[0023] The second calculation module is used to calculate the rotation angle of the sun visor based on the first distance and the second distance, and to calculate the extension length of the sun visor based on the first distance;
[0024] An adjustment module is used to adjust the sunshade according to the rotation angle and the extension length.
[0025] Optionally, the second calculation module includes: an angle calculation unit, used to calculate the ratio of the first distance to the second distance, perform arcsine calculation on the ratio to obtain a target angle, and determine the rotation angle of the sunshade by multiplying the target angle by a preset angle scaling ratio.
[0026] Optionally, the second calculation module includes a length calculation unit, used to determine the extension length of the sunshade by multiplying the first distance by a preset length scaling ratio.
[0027] Optionally, the first calculation module includes: a first distance calculation unit, used to calculate candidate distances between multiple pairs of first pixels and second pixels; in each pair of first pixels and second pixels, the first pixel is a pixel on the sunlight dividing line, the second pixel is a pixel on the eye-connecting line, and the first pixel and the second pixel are located on the same vertical line; the average value and standard deviation of the candidate distances are calculated, and the sum of the average value and the standard deviation is determined as the first distance between the sunlight dividing line and the eye-connecting line.
[0028] Optionally, the first calculation module includes: a second distance calculation unit, configured to obtain the vertical distance between the user's eyes and the camera, calculate the coordinates of the user's eyes in the camera coordinate system based on the vertical distance, and calculate a second distance between the user's eyes and the sun visor based on the coordinates of the user's eyes in the camera coordinate system and a preset coordinate of the sun visor in the camera coordinate system.
[0029] Optionally, the adjustment module includes: a first adjustment unit, configured to adjust the sun visor according to the rotation angle; when the sun visor reaches a preset maximum angle but has not reached the rotation angle, stop rotating the sun visor and continue adjusting the sun visor according to the extension length; or, adjust the sun visor according to the extension length; when the sun visor reaches a preset maximum length but has not reached the extension length, stop extending the sun visor and continue adjusting the sun visor according to the rotation angle.
[0030] Optionally, the adjustment module includes: a second adjustment unit, configured to calculate a target rotation angle based on a preset angle weight and the rotation angle, and adjust the sun visor according to the target rotation angle; and to calculate a target extension length based on a preset length weight and the extension length, and adjust the sun visor according to the target extension length.
[0031] Optionally, the device further includes: a judgment module for judging whether the sunlight dividing line is located below the eye-connecting line; and a first calculation module for calculating a first distance between the sunlight dividing line and the eye-connecting line, and calculating a second distance between the user's eyes and the sun visor when the sunlight dividing line is not located below the eye-connecting line.
[0032] According to another aspect of the embodiments of this application, a vehicle is provided, the vehicle including a control system and a sun visor, the control system being configured to perform the sun visor control method as described in any of the preceding claims.
[0033] According to another aspect of the embodiments of this application, an electronic device is provided, the electronic device including a processor and a computer-readable storage medium storing a computer program; when the computer program is executed by the processor, the processor causes the processor to perform the sun visor control method as described in any of the preceding claims.
[0034] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, causes the processor to perform the sun visor control method as described in any of the preceding claims.
[0035] In this embodiment, an image of the user's facial region inside the vehicle is acquired, and the sunlight boundary line and the line connecting the user's eyes in the facial region image are obtained. A first distance between the sunlight boundary line and the line connecting the eyes, and a second distance between the user's eyes and the sun visor are calculated. The first distance between the sunlight boundary line and the line connecting the eyes can characterize the distance between the user's eyes and the sunlight entering the area, and the second distance between the user's eyes and the sun visor can characterize the distance between the user's eyes and the sun visor. The difference between the first distance and the second distance can affect the different adjustment range of the sun visor. Therefore, the rotation angle and extension length of the sun visor calculated based on the first distance and the second distance take into account the actual situation of sunlight shining on the user's face, which is more in line with the actual scenario. This not only realizes the automatic control of the sun visor, but also makes the control of the sun visor more accurate.
[0036] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0037] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some drawings of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 is a flowchart of a sunshade control method according to an embodiment of this application;
[0039] Figure 2 is a flowchart of another sunshade control method according to an embodiment of this application;
[0040] Figure 3 is a structural block diagram of a sunshade control device according to an embodiment of this application;
[0041] Figure 4 is a structural block diagram of an electronic device according to an embodiment of this application;
[0042] Figure 5 is a structural block diagram of a computer-readable storage medium according to an embodiment of this application. Specific Implementation
[0043] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0044] Referring to FIG1, a flowchart of a sunshade control method according to an embodiment of the present application is shown.
[0045] The sun visor control method in this application embodiment can be applied to electronic devices in vehicles. These electronic devices may include a camera for acquiring images, a processor for performing image analysis, data calculation, adjusting the sun visor, and other operations, etc.
[0046] As shown in Figure 1, the sun visor control method may include the following steps:
[0047] Step 101: Acquire an image of the user's facial region inside the vehicle, and obtain the sunlight boundary line and the eye-to-eye connection line in the facial region image.
[0048] In this embodiment, a camera can be installed at a suitable location on the vehicle to capture images of the facial area of the user inside the vehicle. To improve the accuracy of the facial images, the camera can be configured to shoot directly at the user's face. Furthermore, image clarity can be ensured by using a high-definition camera or similar means.
[0049] The users inside the vehicle can include the driver and the front passenger. For example, a camera can be installed in front of the driver's seat to capture images of the driver's face; a camera can be installed in front of the front passenger's seat to capture images of the front passenger's face.
[0050] By performing image analysis on the user's facial region image, the sunlight boundary line and the line connecting the user's eyes can be obtained in the facial region image.
[0051] The sunlight dividing line refers to the line of light and shadow that forms on a user's face when sunlight shines on it.
[0052] For example, firstly, the facial region image is converted into a grayscale image, as grayscale images simplify subsequent processing and are more sensitive to brightness changes. Then, the grayscale image is binarized to obtain a binarized image to highlight the contrast between light and dark areas; for example, global threshold binarization or adaptive threshold binarization can be used. Next, in the binarized image, the brightness changes in the vertical direction are analyzed. Specifically, the image can be scanned line by line in the vertical direction, comparing the brightness values of adjacent pixels. When there is a sudden change in brightness between adjacent pixels (e.g., the brightness difference exceeds a preset brightness), either of these two pixels is taken as a sunlight boundary point. Finally, all sunlight boundary points are connected to form a sunlight boundary line. Of course, other applicable methods can be used to obtain the sunlight boundary line, and this embodiment does not limit this.
[0053] The eye-connecting line refers to the line segment formed by connecting the user's two eyes.
[0054] For example, firstly, a face detection algorithm is used to accurately locate the user's face. This can be achieved through a Haar cascade classifier, HOG (Histogram of Oriented Gradients) + SVM (Support Vector Machine), or a deep learning model. Then, based on the face detection, an eye detection algorithm is used to locate the position of the two eyes. This can also be accomplished using a Haar cascade classifier, HOG + SVM, or a deep learning model. Next, the center pixel or corner pixel of each eye is extracted. Finally, the center pixels of the two eyes are connected as a line connecting the two eyes, or the corner pixels of the two eyes are connected as a line connecting the two eyes.
[0055] Step 102: Calculate the first distance between the sunlight dividing line and the eye connection line, and calculate the second distance between the user's eyes and the sun visor.
[0056] Since the sunlight dividing line and the eye connection line are not necessarily parallel, the sunlight dividing line and the eye connection line can be discretized to calculate the first distance between them based on multiple pairs of pixels.
[0057] For example, the process of calculating the first distance between the sunlight dividing line and the eye-connecting line may include: calculating candidate distances between multiple pairs of first and second pixels, calculating the average of the candidate distances, and determining the average as the first distance between the sunlight dividing line and the eye-connecting line. Wherein, in each pair of first and second pixels, the first pixel is a pixel on the sunlight dividing line, and the second pixel is a pixel on the eye-connecting line, and the first and second pixels are located on the same vertical line. In this method, by using the average of the candidate distances between multiple pairs of first and second pixels after discretization on the sunlight dividing line and the eye-connecting line, the first distance between the sunlight dividing line and the eye-connecting line can be characterized more accurately.
[0058] For example, the process of calculating the first distance between the sunlight dividing line and the eye-connecting line may include: calculating candidate distances between multiple pairs of first and second pixels; calculating the average and standard deviation of the candidate distances; and determining the sum of the average and standard deviation as the first distance between the sunlight dividing line and the eye-connecting line. In each pair of first and second pixels, the first pixel is a pixel on the sunlight dividing line, and the second pixel is a pixel on the eye-connecting line, and the first and second pixels are located on the same vertical line. In this method, the standard deviation between multiple pairs of first and second pixels is added to the average of the candidate distances between the discrete pairs of first and second pixels on the sunlight dividing line and the eye-connecting line. The value obtained by adding the standard deviation to the average can be considered a "typical" value in the dataset, thus the obtained first distance between the sunlight dividing line and the eye-connecting line is more accurate.
[0059] It should be noted that the candidate distance and the first distance mentioned above are actual distances, not distances in the image. The units for the candidate distance and the first distance are length units. If the pixel distance between the first pixel and the second pixel is n (i.e., n pixels), then based on the physical size dy (vertical dimension) of the pixel in the camera's intrinsic parameters, the product of the pixel distance n and the physical size dy is used as the candidate distance between the first pixel and the second pixel.
[0060] When calculating the second distance between the user's eyes and the sun visor, it is necessary to first determine the position of the user's eyes and the position of the sun visor. It should be noted that the user's eyes and the sun visor correspond to each other; specifically, if the user is the primary driver, the sun visor is the primary driver's side sun visor; if the user is the secondary driver, the sun visor is the secondary driver's side sun visor.
[0061] For example, the process of calculating the second distance between the user's eyes and the sun visor may include: obtaining the vertical distance between the user's eyes and the camera; calculating the coordinates of the user's eyes in the camera coordinate system based on the vertical distance; and calculating the second distance between the user's eyes and the sun visor based on the coordinates of the user's eyes in the camera coordinate system and a preset coordinate of the sun visor in the camera coordinate system. By transforming the positions of both the user's eyes and the sun visor to the camera coordinate system and then calculating the second distance in the same camera coordinate system, the accuracy of the second distance can be guaranteed. It should be noted that the user's eyes correspond to the camera; specifically, if the user is the primary driver, the camera is the camera in the primary driver's position; if the user is the secondary driver, the sun visor is the camera in the secondary driver's position.
[0062] Image processing often involves pixel coordinate systems, image coordinate systems, and camera coordinate systems.
[0063] Pixel coordinate system: The pixel coordinate system is a two-dimensional Cartesian coordinate system with the top-left corner of the image as the origin and pixels as the unit. The position of each pixel in the image is represented by its coordinates (u, v) on the image plane, where u represents the column number of the pixel in the image (i.e., the horizontal direction) and v represents the row number of the pixel in the image (i.e., the vertical direction).
[0064] Image coordinate system: The image coordinate system is a two-dimensional rectangular coordinate system with the intersection of the optical axis and the image plane (corresponding to the center point of the image) as the origin and the unit as millimeters or meters. The position of each pixel in the image is represented by its coordinates (x, y) on the image plane.
[0065] Camera coordinate system: The camera coordinate system is a three-dimensional rectangular coordinate system with the optical center of the camera as the origin and the optical axis as the Z-axis. It is usually represented by (Xc, Yc, Zc).
[0066] After obtaining the eye-binding line of the user in the facial region image, the midpoint of this line can be used as the position of the user's eyes. The coordinates of each pixel in the eye-binding line in the pixel coordinate system can be directly obtained, therefore the coordinates of the user's eyes (i.e., the midpoint of the eye-binding line) in the pixel coordinate system can also be obtained.
[0067] In this embodiment of the application, the camera is a depth camera. The depth camera can capture the user's facial region image and the corresponding depth map of the user's facial region image. The depth information of each pixel can be directly read from the depth map. The depth information is the vertical distance between the pixel and the depth camera. Correspondingly, the vertical distance between the user's eyes and the camera can be obtained according to the coordinates of the user's eyes (i.e., the midpoint of the eye-to-eye line) in the pixel coordinate system.
[0068] After obtaining the coordinates of the user's eyes in the pixel coordinate system and the vertical distance between the user's eyes and the camera, the coordinates of the user's eyes in the camera coordinate system can be calculated based on the camera's intrinsic parameters by transforming between the pixel coordinate system and the camera coordinate system. These intrinsic parameters may include the focal length f, the coordinates of the optical center (corresponding to the center point of the image) (u0, v0), and the physical dimensions of the pixels, such as dx (horizontal dimension) and dy (vertical dimension).
[0069] First, the coordinates of the user's eyes in the pixel coordinate system are converted to the coordinates of the user's eyes in the image coordinate system. Specifically, for example, if the coordinates of the user's eyes in the pixel coordinate system are (u, v), and the coordinates of the user's eyes in the image coordinate system are (x, y), the coordinates of the optical center are (u0, v0), the physical dimensions of the pixels are dx and dy, and the focal length is f, then x = (u - u0) * fx, y = (v - v0) * fy, fx = f / dx, and fy = f / dy.
[0070] Then, the coordinates of the user's eyes in the image coordinate system are converted to the coordinates of the user's eyes in the camera coordinate system. Specifically, for example, if the coordinates of the user's eyes in the image coordinate system are (x, y), and the coordinates of the user's eyes in the camera coordinate system are (Xc, Yc, Zc), and the various intrinsic parameters of the camera are as described in the example above, then Xc = fx*x / Zc, Yc = fy*y / Zc, Zc = Zc, where Zc is the vertical distance between the user's eyes and the camera.
[0071] In this embodiment, the coordinates of the sun visor in the camera coordinate system are pre-calibrated. Based on the second coordinates and the preset coordinates of the sun visor in the camera coordinate system, the second distance between the user's eyes and the sun visor can be calculated. Specifically, the second distance is calculated using the Euclidean distance calculation method.
[0072] Step 103: Calculate the rotation angle of the sunshade based on the first distance and the second distance, and calculate the extension length of the sunshade based on the first distance.
[0073] The first distance is the distance between the sunlight dividing line and the line connecting the user's eyes. The second distance is the distance between the user's eyes and the sun visor. The sun visor can be adjusted to increase the shading range of the sun visor downwards to cover the second distance, thereby blocking sunlight from reaching the user's eyes.
[0074] In this embodiment of the application, the rotation angle of the sunshade can be calculated based on the first distance and the second distance, and the extension length of the sunshade can be calculated based on the first distance.
[0075] For example, the process of calculating the rotation angle of the sun visor based on the first distance and the second distance includes: calculating the ratio of the first distance to the second distance; calculating the target angle by performing an arcsine calculation on the ratio; and determining the rotation angle of the sun visor by multiplying the target angle by a preset angle scaling ratio. Here, the angle scaling ratio represents the proportional relationship between the calculated rotation angle and the actual rotation angle. The angle scaling ratio is obtained in advance through extensive experimental analysis and verification, and this embodiment does not impose any limitations on it.
[0076] For example, the process of calculating the extension length of the sun visor based on the first distance includes: multiplying the first distance by a preset length scaling ratio to determine the extension length of the sun visor. The length scaling ratio represents the proportional relationship between the calculated extension length and the actual extension length. This length scaling ratio is obtained in advance through extensive experimental analysis and verification, and this embodiment does not impose any limitations on it.
[0077] Step 104: Adjust the sunshade according to the rotation angle and the extension length.
[0078] In one alternative implementation, the sun visor can be rotated first. If the conditions are still not met after the sun visor has been rotated to its maximum angle, then the sun visor can be extended or retracted. Therefore, the process of adjusting the sun visor according to the rotation angle and the extension length includes: adjusting the sun visor according to the rotation angle; stopping the rotation of the sun visor when the sun visor reaches the preset maximum angle but has not reached the rotation angle, and continuing to adjust the sun visor according to the extension length. This method takes into account that the extension of the sun visor may obstruct the user's view, so it prioritizes rotating the sun visor to avoid obstructing the user's view.
[0079] In one alternative embodiment, the sun visor can be extended and adjusted first. If the condition is still not met after the sun visor is extended to its maximum length, the sun visor can be rotated. Therefore, the process of adjusting the sun visor according to the rotation angle and the extension length includes: adjusting the sun visor according to the extension length; stopping the extension of the sun visor when the sun visor reaches the preset maximum length but has not reached the extension length, and continuing to adjust the sun visor according to the rotation angle.
[0080] In one alternative implementation, corresponding weights can be assigned to the rotation angle and the extension length, and both the rotation angle and the extension length can be adjusted simultaneously during a single adjustment. Therefore, the process of adjusting the sun visor according to the rotation angle and the extension length includes: calculating a target rotation angle based on preset angle weights and the rotation angle, and adjusting the sun visor according to the target rotation angle; calculating a target extension length based on preset length weights and the extension length, and adjusting the sun visor according to the target extension length.
[0081] The target rotation angle is the product of a preset angle weight and the rotation angle. The target extension length is the product of a preset length weight and the extension length. Similarly, to reduce obstruction of the user's view, the angle weight can be set higher than the length weight. The specific values of the angle weight and length weight can be set according to actual needs; this embodiment does not impose any restrictions on them.
[0082] It should be noted that, for the specific implementation of each of the above steps, any one or any multiple of the above specific implementation methods can be used in the same embodiment, and these implementation methods can be arbitrarily combined.
[0083] In this embodiment, the first distance between the sunlight dividing line and the eye-to-eye connection line can characterize the distance between the user's eyes and the sunlight entering the area, and the second distance between the user's eyes and the sun visor can characterize the distance between the user's eyes and the sun visor. The difference between the first distance and the second distance can affect the adjustment range of the sun visor. Therefore, the rotation angle and extension length of the sun visor calculated based on the first distance and the second distance take into account the actual situation of sunlight shining on the user's face, which is more in line with the actual scenario. This not only realizes the automatic control of the sun visor, but also makes the control of the sun visor more accurate.
[0084] Referring to FIG2, a flowchart of another sunshade control method according to an embodiment of the present application is shown.
[0085] As shown in Figure 2, the sun visor control method may include the following steps:
[0086] Step 201: Acquire an image of the user's facial region inside the vehicle, and obtain the sunlight boundary line and the eye-to-eye connection line in the facial region image.
[0087] Step 202: Determine whether the sunlight dividing line is located below the eye connection line.
[0088] The phrase "the sunlight dividing line is located below the eye-connecting line" means that the sunlight dividing line is lower than the eye-connecting line in the vertical direction.
[0089] In determining whether the sunlight dividing line is located below the eye connection line, to reduce the computational load, it can be determined whether the highest pixel in the sunlight dividing line is located below the lowest pixel in the eye connection line. If so, it can be determined that the sunlight dividing line is located below the eye connection line; otherwise, it can be determined that the sunlight dividing line is not located below the eye connection line.
[0090] Since the vertical axis of the pixel coordinate system is vertically downward, the larger the vertical coordinate of a pixel, the lower the pixel is. Therefore, the highest pixel in the sunlight dividing line can be the pixel with the smallest vertical coordinate in the pixel coordinate system in the sunlight dividing line; the lowest pixel in the eye connection line can be the pixel with the largest vertical coordinate in the pixel coordinate system in the eye connection line.
[0091] Step 203: When the sunlight dividing line is not located below the eye-connecting line, calculate the first distance between the sunlight dividing line and the eye-connecting line, and calculate the second distance between the user's eyes and the sun visor.
[0092] If the sunlight dividing line is not located below the eye-connecting line, it indicates that sunlight is shining into the user's eyes. Therefore, it is necessary to continue calculating the first distance between the sunlight dividing line and the eye-connecting line, and the second distance between the user's eyes and the sun visor, in order to perform subsequent sun visor adjustment operations.
[0093] When the sunlight dividing line is below the eye connection line, it means that the sun visor has blocked the sunlight, so the sunlight does not shine into the user's eyes, and therefore no further steps are required.
[0094] Step 204: Calculate the rotation angle of the sunshade based on the first distance and the second distance, and calculate the extension length of the sunshade based on the first distance.
[0095] Step 205: Adjust the sunshade according to the rotation angle and the extension length.
[0096] It should be noted that the specific process of each step in the sunshade control method shown in Figure 2 can be referred to the relevant description of the corresponding step in the sunshade control method shown in Figure 1 above. The corresponding step can be implemented in the manner described in any of the corresponding embodiments above.
[0097] In this embodiment, the sunshade control method described above can be executed periodically to achieve dynamic adjustment.
[0098] In this embodiment, after adjusting the sunshade according to the rotation angle and the extension length, the sunshade control method described above can be executed again to check whether the sunshade control has achieved the sunshade effect.
[0099] The embodiments of this application can achieve the following beneficial effects:
[0100] Improve driving safety: By automatically adjusting the position of the sun visor, the impact of sunlight on the driver's vision is minimized, reducing the resulting driving safety risks.
[0101] Enhanced driving comfort: The intelligent sun visor adjustment system can automatically adjust according to changes in the driving environment, reducing the driver's workload and allowing the driver to focus more on driving.
[0102] Precise control: Through high-precision image recognition technology and intelligent calculation, the required rotation angle and extension length of the sun visor can be accurately calculated and adjusted.
[0103] Enhanced driving experience: By reducing the need for drivers to manually adjust the sun visor, drivers can focus more on driving, making driving easier and more enjoyable, thus enhancing the driving experience.
[0104] Wide adaptability: It can be widely applied to various vehicles, whether it is a regular sedan, a commercial vehicle, or a bus, and can effectively improve driving comfort and safety.
[0105] Referring to FIG3, a structural block diagram of a sunshade control device according to an embodiment of the present application is shown.
[0106] As shown in Figure 3, the sun visor control device may include the following modules:
[0107] The acquisition module 301 is used to acquire facial region images of users inside the vehicle, and to acquire the sunlight boundary line and the eye connection line of the user in the facial region image;
[0108] The first calculation module 302 is used to calculate the first distance between the sunlight dividing line and the eye connection line, and to calculate the second distance between the user's eyes and the sun visor;
[0109] The second calculation module 303 is used to calculate the rotation angle of the sun visor based on the first distance and the second distance, and to calculate the extension length of the sun visor based on the first distance;
[0110] Adjustment module 304 is used to adjust the sunshade according to the rotation angle and the extension length.
[0111] Optionally, the second calculation module 303 includes: an angle calculation unit, used to calculate the ratio of the first distance to the second distance, perform arcsine calculation on the ratio to obtain a target angle, and determine the rotation angle of the sunshade by multiplying the target angle by a preset angle scaling ratio.
[0112] Optionally, the second calculation module 303 includes: a length calculation unit, used to determine the extension length of the sunshade by multiplying the first distance by a preset length scaling ratio.
[0113] Optionally, the first calculation module 302 includes: a first distance calculation unit, used to calculate candidate distances between multiple pairs of first pixels and second pixels; in each pair of first pixels and second pixels, the first pixel is a pixel on the sunlight dividing line, the second pixel is a pixel on the eye-connecting line, and the first pixel and the second pixel are located on the same vertical line; the average value and standard deviation of the candidate distances are calculated, and the sum of the average value and the standard deviation is determined as the first distance between the sunlight dividing line and the eye-connecting line.
[0114] Optionally, the first calculation module 302 includes: a second distance calculation unit, used to obtain the vertical distance between the user's eyes and the camera, calculate the coordinates of the user's eyes in the camera coordinate system based on the vertical distance, and calculate a second distance between the user's eyes and the sun visor based on the coordinates of the user's eyes in the camera coordinate system and a preset coordinate of the sun visor in the camera coordinate system.
[0115] Optionally, the adjustment module 304 includes: a first adjustment unit, configured to adjust the sun visor according to the rotation angle; when the sun visor reaches a preset maximum angle but has not reached the rotation angle, stop rotating the sun visor and continue adjusting the sun visor according to the extension length; or, adjust the sun visor according to the extension length; when the sun visor reaches a preset maximum length but has not reached the extension length, stop extending the sun visor and continue adjusting the sun visor according to the rotation angle.
[0116] Optionally, the adjustment module 304 includes: a second adjustment unit, configured to calculate a target rotation angle based on a preset angle weight and the rotation angle, and adjust the sun visor according to the target rotation angle; and to calculate a target extension length based on a preset length weight and the extension length, and adjust the sun visor according to the target extension length.
[0117] Optionally, the device further includes: a judgment module for judging whether the sunlight dividing line is located below the eye-connecting line; and a first calculation module 302, specifically used to calculate a first distance between the sunlight dividing line and the eye-connecting line, and to calculate a second distance between the user's eyes and the sun visor when the sunlight dividing line is not located below the eye-connecting line.
[0118] In this embodiment, the first distance between the sunlight dividing line and the eye-to-eye connection line can characterize the distance between the user's eyes and the sunlight entering the area, and the second distance between the user's eyes and the sun visor can characterize the distance between the user's eyes and the sun visor. The difference between the first distance and the second distance can affect the adjustment range of the sun visor. Therefore, the rotation angle and extension length of the sun visor calculated based on the first distance and the second distance take into account the actual situation of sunlight shining on the user's face, which is more in line with the actual scenario. This not only realizes the automatic control of the sun visor, but also makes the control of the sun visor more accurate.
[0119] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0120] In an embodiment of this application, a vehicle is also provided, the vehicle including a control system and a sun visor, the control system being used to execute the sun visor control method as described in any of the above embodiments.
[0121] In embodiments of this application, an electronic device is also provided. This electronic device may include a processor and a computer-readable storage medium storing a computer program; when the computer program is executed by the processor, it causes the processor to perform the sun visor control method of any of the above embodiments.
[0122] Referring to FIG4, a structural block diagram of an electronic device according to an embodiment of the present application is shown. As shown in FIG4, the electronic device 11 includes a processor 111 and a computer-readable storage medium 112, on which a computer program 1121 is stored.
[0123] The processor 111 is used to execute the computer program 1121 stored on the computer-readable storage medium 112. When the processor 111 executes the computer program 1121, it implements the sunshade control method of any of the above embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0124] The processor 111 mentioned above may include, but is not limited to: a central processing unit (CPU), a network processor (NP), 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, etc.
[0125] The computer-readable storage medium 112 mentioned above may include, but is not limited to: read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), electronically erasable programmable read-only memory (EEPROM), hard disk, floppy disk, flash memory, etc.
[0126] In embodiments of this application, a computer-readable storage medium is also provided, on which a computer program is stored, which can be executed by a processor of an electronic device, and when the computer program is executed by the processor, the processor performs the sun visor control method as described in any of the above embodiments.
[0127] Referring to FIG5, a structural block diagram of a computer-readable storage medium according to an embodiment of the present application is shown. As shown in FIG5, a computer program 211 is stored on the computer-readable storage medium 21. When the computer program 211 is executed by a processor, the processor performs the sunshade control method as described in any of the above embodiments, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0128] The various embodiments in this specification are related to each other and are described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other.
[0129] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and regulations of the locality and with authorization from the owner of the relevant device.
[0130] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0131] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0132] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0133] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0134] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0135] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0136] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0137] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0138] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. In summary, the content of this specification should not be construed as a limitation of this application.
Claims
1. A sun visor control method, the method comprising: capturing an image of a face region of a user in a vehicle, obtaining a sunlight boundary line in the image and a connecting line of two eyes of the user; calculating a first distance between the sunlight boundary line and the connecting line of the two eyes, and calculating a second distance between the two eyes of the user and a sun visor; calculating a rotation angle of the sun visor based on the first distance and the second distance, and calculating an extension length of the sun visor based on the first distance; adjusting the sun visor according to the rotation angle and the extension length.
2. The method of claim 1, wherein, The calculating of the rotation angle of the sun visor based on the first distance and the second distance comprises: calculating a ratio of the first distance to the second distance, and performing an inverse sine calculation on the ratio to obtain a target angle; multiplying the target angle by a preset angle scaling ratio to determine the rotation angle of the sun visor.
3. The method of claim 1 or 2, wherein, The calculating of the extension length of the sun visor based on the first distance comprises: multiplying the first distance by a preset length scaling ratio to determine the extension length of the sun visor.
4. The method according to any one of claims 1 to 3, wherein, The calculating of the first distance between the sunlight boundary line and the connecting line of the two eyes comprises: calculating candidate distances between a plurality of pairs of first pixel points and second pixel points, wherein the first pixel point in each pair of the first pixel point and the second pixel point is a pixel point on the sunlight boundary line, the second pixel point is a pixel point on the connecting line of the two eyes, and the first pixel point and the second pixel point are located on the same vertical line; calculating an average value and a standard deviation of the candidate distances, and determining a sum of the average value and the standard deviation as the first distance between the sunlight boundary line and the connecting line of the two eyes.
5. The method according to any one of claims 1 to 4, wherein, The calculating of the second distance between the two eyes of the user and the sun visor comprises: obtaining a vertical distance between the two eyes of the user and a camera, and calculating coordinates of the two eyes of the user in a camera coordinate system based on the vertical distance; calculating the second distance between the two eyes of the user and the sun visor based on the coordinates of the two eyes of the user in the camera coordinate system and preset coordinates of the sun visor in the camera coordinate system.
6. The method according to any one of claims 1 to 5, wherein, The adjusting of the sun visor according to the rotation angle and the extension length comprises: adjusting the sun visor according to the rotation angle; when the sun visor reaches a preset maximum angle and has not reached the rotation angle, stopping rotating the sun visor and continuing to adjust the sun visor according to the extension length; or adjusting the sun visor according to the extension length; when the sun visor reaches a preset maximum length and has not reached the extension length, stopping extending the sun visor and continuing to adjust the sun visor according to the rotation angle. The adjusting of the sun visor according to the rotation angle and the extension length comprises:
7. The method according to any one of claims 1 to 6, wherein, calculating a target rotation angle according to a preset angle weight and the rotation angle, and adjusting the sun visor according to the target rotation angle; and calculating a target extension length according to a preset length weight and the extension length, and adjusting the sun visor according to the target extension length. 8.The method of claim 7, wherein After the sunlight dividing line and the eyes connecting line in the face region image are acquired, the method further includes: determining whether the sunlight dividing line is below the eyes connecting line. The first distance between the sunlight dividing line and the eyes connecting line is calculated, and the second distance between the eyes of the user and the sun visor is calculated, including: when the sunlight dividing line is not below the eyes connecting line, the first distance between the sunlight dividing line and the eyes connecting line is calculated, and the second distance between the eyes of the user and the sun visor is calculated. 9.A sun visor control device, the device comprising: an acquisition module configured to acquire a face region image of a user in a vehicle, and acquire a sunlight dividing line and an eyes connecting line in the face region image; a first calculation module configured to calculate a first distance between the sunlight dividing line and the eyes connecting line, and calculate a second distance between eyes of the user and a sun visor; a second calculation module configured to calculate a rotation angle of the sun visor based on the first distance and the second distance, and calculate an extension length of the sun visor based on the first distance; an adjustment module configured to adjust the sun visor according to the rotation angle and the extension length. 10.A vehicle, comprising a control system and a sun visor, the control system being configured to perform the sun visor control method according to any one of claims 1 to 8. 11.An electronic device, comprising a processor and a computer readable storage medium, the computer readable storage medium storing a computer program; when the computer program is executed by the processor, the processor performs the sun visor control method according to any one of claims 1 to 8.
12. A computer readable storage medium, wherein, The computer readable storage medium stores a computer program, when the computer program is executed by the processor, the processor performs the sun visor control method according to any one of claims 1 to 8.