Hair quality detection method and system, electronic equipment and storage medium
Through the improved Yolov8 network and feature matching algorithm, the high cost and subjectivity of traditional hair quality testing are solved, efficient and accurate hair density and diameter assessment is achieved, and the scalability and stability of detection are improved.
Patent Information
- Application Number
- CN202510777680.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-16
AI Technical Summary
Traditional hair quality detection methods have high labor costs, strong subjectivity and poor scalability. The existing hair detection method based on yolov7 is too rigid, prone to false detection and poor scalability.
The Yolov8 network is used to train the labels of hair roots and follicle units. The overlapping follicle units and hair roots are filtered through a mask image. The minimum enclosing rectangle is used to replace the traditional post-processing. The principal component analysis and DBSCAN clustering algorithm are combined to match the hair follicles and hair roots, and a hair health score mapping formula is constructed.
It reduces labor costs, improves the scalability and stability of detection, reduces missed detections, accurately assesses hair density and diameter, and provides an objective assessment of hair health.
Smart Images

Figure CN120655614A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of hair quality detection based on image recognition, and in particular to a hair quality detection method, system, electronic device and storage medium. Background Art
[0002] The purpose of hair quality testing is to understand the nutritional status of hair growth and hair loss.
[0003] The traditional method of testing hair quality is through a hair quality tester, which essentially uses a microscope camera to take microscopic pictures of the hair, and then uses professional interpretation to judge the severity of the user's current hair density and hair diameter. This method is highly subjective and increases the store's labor costs and professionalism.
[0004] Currently, a hair detection method based on YOLOv7 in deep learning detects the number of hairs in a follicle by directly labeling the hair roots, classifying them as p1, p2, and p3, indicating one hair in a follicle, two hairs in a follicle, and three hairs in a follicle. When detecting hair diameter, this method directly labels and categorizes coarse, medium, and fine hair. This approach is too rigid and prone to false detections. It also lacks scalability, as a single follicle opening may contain four or five hairs.
[0005] Therefore, developing a professional method for detecting hair density and thickness, reducing labor costs, and improving the scalability and stability of detection will be beneficial to user experience. Summary of the Invention
[0006] Purpose of the invention: To propose a hair quality detection method, and further propose a system and storage medium that can automatically execute the hair quality detection method, aiming to solve the above-mentioned defects existing in the current microscopic hair detection method.
[0007] A hair quality detection method proposed by the present invention comprises the following steps:
[0008] Collect a predetermined number of image samples containing hair roots and hair follicles, and mark the hair roots and hair follicle units from them as labels to guide Yolov8 network training;
[0009] Input the image to be detected into the trained Yolov8 network to obtain the predicted frame of the image to be detected and the mask map within the predicted frame;
[0010] Filtering out hair follicle units with an overlap greater than a first preset value according to the mask image; filtering out overlapping hair roots according to the minimum circumscribed rectangle of the mask image;
[0011] Matching hair follicle units and hair roots;
[0012] Based on the matching results, the hair diameter and the hair density within the predetermined field of view are calculated;
[0013] A hair health score mapping formula is constructed to perform score mapping on the calculated hair diameter and hair density, and the severity levels of hair density and hair diameter are evaluated to obtain the current hair health status.
[0014] In a further embodiment, filtering out overlapping hair roots according to the minimum bounding rectangle of the mask image specifically includes:
[0015] Calculate the mask map within each prediction box through the trained Yolov8 network output, and find the minimum bounding rectangle of the obtained mask map;
[0016] Sort all minimum bounding rectangles by confidence score and select the box with the highest confidence as the current maximum value box;
[0017] Calculate the overlapping area of other boxes with the maximum value box, and delete them if it exceeds the preset threshold.
[0018] In a further embodiment, the calculation formula for the minimum bounding rectangle of the mask image is:
[0019]
[0020] Where, Represents the intersection area of two minimum enclosing rectangles; 、 Represents the width and height of the first minimum enclosing rectangle; 、 Represents the width and height of the second minimum enclosing rectangle.
[0021] In a further embodiment, matching the follicular unit and the hair root specifically includes:
[0022] Binarize the obtained hair root mask image to obtain the set of all points of the hair root contour;
[0023] Using principal component analysis, the eigenvectors and eigenvalues of hair roots were obtained;
[0024] The slope of the main direction line of the hair root is obtained through the eigenvector; the two intersection points of the main direction line and the minimum circumscribed rectangle are the hair tip and hair root points of the hair root, and the Euclidean distance between the hair tip and hair root points is the length of the hair root;
[0025] The slope of the negative line is calculated using the eigenvector, and the distance between the intersection of the negative line and the circumscribed rectangle is the diameter of the hair root.
[0026] In a further embodiment, the calculation formulas for the main direction and the negative direction of the hair root are:
[0027]
[0028]
[0029]
[0030] Where C is the covariance matrix; is the set of contour points of the mask image; is the main direction, It is the negative direction.
[0031] In a further embodiment, a hair health score mapping formula is constructed to calculate the hair density score:
[0032]
[0033] Where, Represents the grade score of hair density; base1 is the score interval divided by the numerical range of hair density; density represents the number of hairs per square centimeter.
[0034] In a further embodiment, a hair health score mapping formula is constructed to calculate the average hair diameter score:
[0035]
[0036] Where, Represents the grade score of average hair diameter; base2 is the numerical range of the score interval divided by the average hair diameter; diameter represents the average hair diameter.
[0037] In a further embodiment, the hair density score is calculated based on , average hair diameter score , divided into four levels, moderate for 5-6 points, mild for 3-5 points, moderate for 1-3 points, and severe for 0-1 points.
[0038] In addition, the present invention also proposes a hair quality detection system, which includes a trained Yolov8 network, an inference module, and a scoring module.
[0039] Collect a predetermined number of image samples containing hair roots and hair follicles, and mark the hair roots and hair follicle units from them as labels to guide Yolov8 network training.
[0040] The inference module is configured to input the image to be detected into a trained Yolov8 network to obtain a predicted frame of the image to be detected and a mask image within the predicted frame; filter out hair follicle units with an overlap greater than a first preset value based on the mask image; filter out overlapping hair roots based on the minimum bounding rectangle of the mask image; and match the hair follicle units with the hair roots.
[0041] The scoring module calculates the hair diameter and hair density within a predetermined field of view based on the matching results, and performs a scoring map on the calculated hair diameter and hair density to evaluate the severity of the hair density and hair diameter, thereby obtaining the current hair health status.
[0042] In addition, the present invention also proposes an electronic device, which includes a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the above-mentioned hair quality detection method is implemented.
[0043] In addition, the present invention also proposes a computer-readable storage medium, which stores at least one executable instruction. When the executable instruction is run on an electronic device, the electronic device executes the above-mentioned hair quality detection method.
[0044] Beneficial Effects: Compared to existing hair detection methods based on Yolov7, this invention does not use fixed labels for fine hair, medium hair, coarse hair, or p1, p2, and p3. Instead, it uses the matching of hair and follicle units to solve this problem, improving the algorithm's scalability in subsequent processes. Furthermore, because two hairs in a follicle unit may be close together, according to Yolov8iou's post-processing, one would be deleted. This invention changes its post-processing logic, replacing the original post-processing method with a minimum bounding rectangle, greatly reducing the possibility of missed detection in overlapping scenes and effectively retaining the most hair. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 Flowchart of the hair quality detection method in an embodiment of the present invention.
[0046] Figure 2 Schematic diagram of the structure of the Yolov8 network in an embodiment of the present invention.
[0047] Figure 3 This is the prediction result of hair density in the embodiment of the present invention.
[0048] Figure 4 This is the prediction result of hair thickness in the embodiment of the present invention.
[0049] Figure 5 This is the effect of using normal NMS processing.
[0050] Figure 6This is the effect of using the method of the present invention. DETAILED DESCRIPTION
[0051] In the following description, numerous specific details are provided to provide a more thorough understanding of the present invention. However, it will be apparent to those skilled in the art that the present invention may be practiced without one or more of these details. In other instances, certain technical features well known in the art have not been described to avoid confusion with the present invention.
[0052] Example 1:
[0053] This embodiment discloses an improved hair quality detection method based on Yolov8, which is described below in three aspects: training stage, inference stage, and scoring stage.
[0054] 1. Training Phase
[0055] The hair roots and hair follicle units in the training set images are labeled, where the hair roots are labeled as hair_rotate and the hair follicle units are labeled as hair_unit.
[0056] 2. Reasoning Stage
[0057] Initialization: The image to be detected is fed into the trained network. During post-processing, the hair roots and follicle units are initialized. Detected follicle units are filtered. Specifically, if the area of intersection between two follicle units exceeds 50%, the larger one is retained, while the smaller one is deleted. If the Euclidean distance between the center points of two follicle units is less than 100 pixels, the two units are merged and their union is taken. Initializing the follicle units yields three pieces of information: the follicle unit number, center of gravity, and outline. Next, the hair roots are initialized. Data required includes the diameter and length of individual hairs, the root and tip endpoints, and the hair outline. This is achieved by first filtering out roots with high overlap by obtaining the minimum bounding rectangle of the root outline, retaining those with larger areas. Binarization is then used to filter out smaller roots. Principal component analysis is then performed to obtain the eigenvectors and eigenvalues of the hair roots. The eigenvectors are used to determine the slope of the main direction line of the hair roots. The two intersection points of the main direction line and the minimum circumscribed rectangle are the tip and root points of the hair root. The Euclidean distance between these two points is the length of the hair root. The slope of the secondary direction line is then calculated using the eigenvector. The distance between the intersection points of the negative direction line and the circumscribed rectangle is the diameter of the hair root.
[0058] Matching: Then, the hair and hair follicles are matched. The specific implementation steps are as follows: first, traverse the hair roots obtained after initialization, and then traverse the hair follicle units obtained after initialization. If the hair follicle unit contains the root point of the hair root, first calculate the Euclidean distance between the center point of the hair follicle unit and the root point, and then compare this distance with the current minimum distance to see which is smaller. If the current distance is smaller than the shortest distance already obtained, update the shortest distance and remember the serial number of the hair follicle unit. The purpose is to find the hair follicle unit that best matches the hair root. If the hair follicle unit contains the tip point of the hair root, first swap the positions of the root point and the tip point, and then calculate the Euclidean distance between the two.
[0059] Similarly, if this distance is shorter than the known minimum distance, update the minimum distance and memorize the follicular unit number. If neither the tip nor the root of a hair root is within a follicular unit, traverse all the contour points of the hair root. If a contour point is within a follicular unit, calculate the distance d1 from the root to this contour point and the distance d2 from the tip to this contour point. If d1 is less than d2, calculate the distance from the root to the center of the follicular unit. If both distances are less than the current minimum distance, update the current minimum distance and memorize the follicular unit number. If d1 is greater than d2, calculate the distance from the tip to the center of the follicular unit. If both distances are less than the current minimum distance, swap the coordinates of the root and tip, update the minimum distance, and memorize the current follicular unit number. After traversing all hair roots, perform DBSCAN clustering analysis on those hair roots that do not have a matching follicular unit to find the follicular unit that best matches the unmatched root.
[0060] 3. Scoring Stage
[0061] Hair diameter: Based on references to specific literature, we categorize hair diameter into four severity levels: moderate, mild, moderate, and severe. Hair diameters greater than 90 μm are considered moderate, 70 to 90 μm are considered mild, 60 to 70 μm are considered moderate, and less than 60 μm are considered severe. These are mapped to specific scores using a mathematical model. Moderate scores range from 5 to 6, mild scores from 3 to 5, moderate scores from 1 to 3, and severe scores from 0 to 1.
[0062] Hair density: Based on references to specific literature, we categorize hair density into four severity levels: moderate, mild, moderate, and severe. Moderate hair density is defined as greater than 116.27 hairs per square centimeter, mild hair density is greater than 77.52 but less than 116.27, moderate hair density is greater than 38.77 but less than 77.52, and severe hair density is less than 38.77. These values are then converted into scores using a mathematical model. Moderate hair density is between 5 and 6, mild hair density is between 3 and 5, moderate hair density is between 1 and 3, and severe hair density is between 0 and 1.
[0063] Example 2:
[0064] Based on Example 1, Figure 1 As shown, the specific process details of the quality detection method disclosed in this embodiment are as follows:
[0065] Step S1: Use Labelme software to label the hair roots and hair follicle units as labels to guide Yolov8 model training.
[0066] The hair root is marked as hair_rotate and the hair follicle unit is marked as hair_unit.
[0067] In step S2, the image to be detected is input into the trained Yolov8 model to obtain the predicted frame and mask map of the image to be detected.
[0068] In step S3, hair follicle units with a high degree of overlap are filtered out according to the obtained mask image, and overlapping hair roots are filtered out according to the minimum bounding rectangle, replacing the original post-processing method.
[0069] Step S4: match all hair follicle units and hair roots using the hair follicle unit and hair root matching algorithm, and match unmatched ones using the DBSCAN clustering algorithm.
[0070] Step S5: score and map the obtained hair diameter and hair density according to literature data, evaluate the severity level of hair density and hair diameter, and thus obtain the hair health status.
[0071] Preferably, step S1 can be implemented as follows:
[0072] Mark the hair roots as hair_rotate. When marking follicle units, include all hair roots within the same follicle unit and mark them as hair_unit. Because the follicle opening is connected to the hair, it has a good feature. The hair roots and scalp have a large difference in features, which also makes them a good feature, increasing the recognition rate.
[0073] Preferably, step S2 can be implemented as follows:
[0074] Select the Yolov8 model, as shown in the attached Figure 2 As shown, the Yolov8 model's network architecture consists of three main components: the Backbone, the Panoptic Feature Pyramid Network (PAFPN), and the Head. When the input image is 1*640*640, the trained Yolov8 network produces two outputs: (1, 38, 8400) and (1, 32, 160, 160). The first parameter of the first output represents the batch size (the number of images), and the second parameter represents the coordinate parameters of the four boxes, the two categories, and the 32 mask weights.
[0075] The second output is the output mask. The first parameter is BatchSize, which is the number of images. The second parameter is the prototype of the mask. The third parameter is the specific size of the mask. The actual mask needs to be obtained by maskweight*mask.
[0076] Because there are a large number of duplicate frames in the output prediction frame, filtering is required to get the final result. NMS (non-maximum suppression) is usually used in this step. Its purpose is to select the frame with the highest confidence and the best representation of the target's true position from the bounding boxes with high overlap. Its principle is to first sort all the bounding boxes according to the confidence score, and then select the frame with the highest confidence as the current maximum value frame. Next, calculate the IOU (intersection-over-union) of other frames with the maximum value frame. If the IOU of a frame with the maximum value frame exceeds the preset threshold, the frame is considered redundant and deleted. This processing method can be used to filter duplicate hair follicle units, but it will have great disadvantages when filtering hair roots. For example Figure 3 As shown in the figure, when the hair roots in the hair follicle unit are dense, the IOU between them is almost 1, which can easily lead to missed detection of hair roots.
[0077] Therefore, this embodiment designs a new IOU calculation method for hair roots. The mask image within each predicted box is calculated using the output of the trained Yolov8 model. The minimum bounding rectangle of the obtained mask image is then found. All minimum bounding rectangle boxes are sorted by confidence score, and the box with the highest confidence score is selected as the current maximum value box. Next, the area of the overlapping area between other boxes and the maximum value box is calculated. If it exceeds a preset threshold, it is deleted. The calculation of the minimum bounding rectangle is shown in Equation (1).
[0078]
[0079] Represents the intersection area of two minimum enclosing rectangles; 、 Represents the width and height of the first minimum enclosing rectangle; 、 Represents the width and height of the second minimum enclosing rectangle.
[0080] To determine the number of hairs in each follicle unit, the follicle unit and the hair root must be matched. First, the root mask is binarized to obtain the set of all root contour points. Then, principal component analysis is performed to obtain the eigenvectors and eigenvalues of the root. The eigenvectors are used to determine the slope of the main direction line of the root. The two intersection points of the main direction line and the minimum circumscribed rectangle are the tip and root points of the root. The Euclidean distance between these two points is the length of the root. The eigenvectors are then used to determine the slope of the secondary direction line. The distance between the intersection points of the negative direction line and the circumscribed rectangle is the diameter of the root.
[0081] Preferably, step S4 can be implemented as follows:
[0082] First, traverse the initialized hair root, then traverse the initialized follicle units. If the follicle unit contains the root point of the hair root, first calculate the Euclidean distance between the follicle unit's center point and the root point. Then compare this distance with the current minimum distance, which is smaller. If the current distance is smaller than the shortest distance, update the shortest distance and memorize the follicle unit's sequence number. The goal is to find the follicle unit that best matches the hair root. If the follicle unit contains the tip point of the hair root, first swap the root and tip points and then calculate the Euclidean distance between them.
[0083] Similarly, if this distance is shorter than the known minimum distance, update the minimum distance and memorize the follicular unit number. If neither the tip nor the root of a hair root is within a follicular unit, traverse all the contour points of the hair root. If a contour point is within a follicular unit, calculate the distance d1 from the root to this contour point and the distance d2 from the tip to this contour point. If d1 is less than d2, calculate the distance from the root to the center of the follicular unit. If both distances are less than the current minimum distance, update the current minimum distance and memorize the follicular unit number. If d1 is greater than d2, calculate the distance from the tip to the center of the follicular unit. If both distances are less than the current minimum distance, swap the coordinates of the root and tip, update the minimum distance, and memorize the current follicular unit number. After traversing all hair roots, perform DBSCAN clustering analysis on those hair roots that do not have a matching follicular unit to find the follicular unit that best matches the unmatched root.
[0084] The calculation formulas for the main direction and negative direction of the hair root are shown in Equation (2), Equation (3), and Equation (4).
[0085]
[0086]
[0087]
[0088] C is the covariance matrix; is the set of contour points of the mask image; is the main direction, It is the negative direction.
[0089] Preferably, step S5 can be implemented as follows:
[0090] In order to reduce the influence of human subjective judgment, a mapping formula for the hair health score is designed according to step S4.
[0091] According to relevant literature, when the degree of hair loss is 1-3, the average hair density is (129.8±12.0) roots per square centimeter, and the average hair diameter is (0.092±0.009) mm. When the degree of hair loss is 4-5, the average hair density is (129.4±14.2) roots per square centimeter, and the average hair diameter is (0.090±0.012) mm. When the degree of hair loss is 6-7, the average hair density is (119.0±15.0) roots per square centimeter, and the average hair diameter is (0.078±0.008) mm. Therefore, the severity can be divided into four levels: moderate, mild, moderate, and severe. Moderate is 5-6 points, mild is 3-5 points, moderate is 1-3 points, and severe is 0-1 point.
[0092] The calculation of hair density score is shown in formula (5), and the calculation of average hair diameter score is shown in formula (6).
[0093]
[0094]
[0095] Represents the grade score of hair density; base1 is the score interval divided by the numerical range of hair density; density represents the number of hairs per square centimeter; Represents the grade score of average hair diameter; base2 is the numerical range of the score interval divided by the average hair diameter; diameter represents the average hair diameter.
[0096] The average hair diameter is calculated using the following formula:
[0097] Value diameter = sum of hair diameters / number of hairs.
[0098] Hair density is calculated using the following formula:
[0099] valueHair density = number of hairs / actual field of view area.
[0100] The prediction results of hair density and hair thickness are shown in the attached Figure 3 and attached Figure 4 As shown, in hair density testing, the present invention can detect all hair follicle openings in an image and accurately distinguish the number of hairs within each follicle opening. In hair thickness testing, the present invention detects all hair roots in an image and correctly displays thick and medium hair, allowing the specific number of hair roots to be calculated during subsequent scoring. This demonstrates excellent detection accuracy and great practical value.
[0101] The hair itself is very close, Figure 5 and attached Figure 6 The figure shows the comparison between the effects of using normal NMS and the post-processing method of the present invention.
[0102] ①, ②, ③, ⑤, ⑥, ⑦, ⑧, ⑨, ⑩, and ⑪ represent densely packed hairs on the same strand. As can be seen, due to their close proximity, using the traditional NMS IOU calculation method, their IOU is almost 1, and only the one with the highest confidence score is retained, while the others are filtered out. However, the present invention utilizes the minimum bounding rectangle to replace the traditional IOU, detecting all these densely packed hairs. ④ represents hair occlusion, which can also be effectively detected using the present invention. This demonstrates that the present invention can effectively reduce missed detections.
[0103] Example 3:
[0104] The technical process of the hair quality detection method disclosed in the above embodiment can be implemented in whole or in part through software, hardware, firmware or any other combination.
[0105] When implemented in hardware, the aforementioned embodiments can be implemented by compiling all or part of the operating logic and computational processes into software and then running them on an electronic device, specifically a hair quality detection system. The electronic device includes a processor, memory, a communication interface, and a communication bus. The processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to execute the technical process of the hair quality detection method disclosed in the aforementioned embodiments.
[0106] As an example, a hair quality detection system can be composed of a trained Yolov8 network, an inference module, and a scoring module. A predetermined number of image samples containing hair roots and follicles are collected, and the hair roots and follicle units are marked from them as labels to guide the training of the Yolov8 network. The inference module is used to input the image to be detected into the trained Yolov8 network to obtain a prediction frame of the image to be detected and a mask map within the prediction frame; based on the mask map, hair follicle units with an overlap greater than a first preset value are filtered out; overlapping hair roots are filtered out based on the minimum bounding rectangle of the mask map; and hair follicle units and hair roots are matched. Based on the matching results, the scoring module calculates the hair diameter and hair density within a predetermined field of view, and scores and maps the calculated hair diameter and hair density to assess the severity of the hair density and hair diameter, thereby determining the current hair health status.
[0107] When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. If the above methods are implemented in the form of software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of the present application. The aforementioned storage media include various media that can store program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), magnetic disks, or optical disks. Thus, the embodiments of the present application are not limited to any specific hardware, software, or firmware, or any combination of hardware, software, and firmware.
[0108] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as limiting the present invention itself. Various changes may be made to it in form and detail without departing from the spirit and scope of the present invention as defined in the appended claims.
Claims
1. A hair quality detection method, characterized in that: The steps include: Collect a predetermined number of image samples containing hair roots and hair follicles, and mark the hair roots and hair follicle units from them as labels to guide Yolov8 network training; Input the image to be detected into the trained Yolov8 network to obtain the predicted frame of the image to be detected and the mask map within the predicted frame; Filtering out hair follicle units with an overlap greater than a first preset value according to the mask image; filtering out overlapping hair roots according to the minimum circumscribed rectangle of the mask image; Matching hair follicle units and hair roots; Based on the matching results, the hair diameter and the hair density within the predetermined field of view are calculated; A hair health score mapping formula is constructed to perform score mapping on the calculated hair diameter and hair density, and the severity levels of hair density and hair diameter are evaluated to obtain the current hair health status.
2. The hair quality detection method according to claim 1, wherein: Filter out overlapping hair roots based on the minimum bounding rectangle of the mask image, including: Calculate the mask map within each prediction box through the trained Yolov8 network output, and find the minimum bounding rectangle of the obtained mask map; Sort all minimum bounding rectangles by confidence score and select the box with the highest confidence as the current maximum value box; Calculate the overlapping area of other boxes with the maximum value box, and delete them if it exceeds the preset threshold.
3. The hair quality detection method according to claim 2, characterized in that: The calculation formula of the minimum bounding rectangle of the mask image is: ; Where, Represents the intersection area of two minimum enclosing rectangles; 、 Represents the width and height of the first minimum enclosing rectangle; 、 Represents the width and height of the second minimum enclosing rectangle.
4. The hair quality detection method according to claim 1, wherein: Matching of hair follicle units and hair roots, including: Binarize the obtained hair root mask image to obtain the set of all points of the hair root contour; Using principal component analysis, the eigenvectors and eigenvalues of hair roots were obtained; The slope of the main direction line of the hair root is obtained through the eigenvector; the two intersection points of the main direction line and the minimum circumscribed rectangle are the hair tip and hair root points of the hair root, and the Euclidean distance between the hair tip and hair root points is the length of the hair root; The slope of the negative line is calculated using the eigenvector, and the distance between the intersection of the negative line and the circumscribed rectangle is the diameter of the hair root.
5. The hair quality detection method according to claim 4, characterized in that: The calculation formula for the main direction and negative direction of the hair root is: ; ; ; Where C is the covariance matrix; is the set of contour points of the mask image; is the main direction, It is the negative direction.
6. The hair quality detection method according to claim 1, wherein: Construct a hair health score mapping formula to calculate the hair density score : ; Where base1 is the fractional interval divided by the range of hair density; density represents the number of hairs per square centimeter; Construct a hair health score mapping formula to calculate the average hair diameter score : ; Where base1 is the fractional interval divided by the numerical range of hair density; density represents the number of hairs per square centimeter; base2 is the fractional interval divided by the numerical range of average hair diameter; diameter represents the average hair diameter.
7. The hair quality detection method according to claim 6, characterized in that: Calculated hair density score , average hair diameter score , divided into four levels, moderate for 5-6 points, mild for 3-5 points, moderate for 1-3 points, and severe for 0-1 points.
8. A hair quality detection system, characterized in that: Includes trained Yolov8 network, reasoning module, and scoring module; Collect a predetermined number of image samples containing hair roots and hair follicles, and mark the hair roots and hair follicle units from them as labels to guide Yolov8 network training; The inference module is configured to input the image to be detected into a trained Yolov8 network to obtain a prediction frame of the image to be detected and a mask image within the prediction frame; filter out hair follicle units with an overlap greater than a first preset value based on the mask image; filter out overlapping hair roots based on a minimum bounding rectangle of the mask image; and match the hair follicle units with the hair roots. The scoring module calculates the hair diameter and the hair density within a predetermined field of view based on the matching results, and performs scoring mapping on the calculated hair diameter and hair density to evaluate the severity level of the hair density and hair diameter, thereby obtaining the current hair health status.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the hair quality detection method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The storage medium stores at least one executable instruction. When the executable instruction is executed on the electronic device, the electronic device executes the hair quality detection method according to any one of claims 1 to 8.
