Plant height and ear height measurement method, scale recognition method, system and electronic equipment
Through image processing technology, the scales are identified and cut, and the plant height and ear height are calculated, which solves the problems of low efficiency and error-prone traditional measurement methods, and achieves fast and accurate plant height and ear height measurement.
Patent Information
- Application Number
- CN202111483708.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2041-12-07
AI Technical Summary
The prior art has problems such as low efficiency, cumbersome operation, error-prone and large labor force in measuring plant height and ear height, and is especially unable to effectively measure adult plants and ear height.
Image processing technology is used to identify the scale. By obtaining the height image to be measured, cutting and identifying the scale image, calculating the scale value, and combining inclination correction and distance mean calculations to obtain the measurement data of plant height and ear height.
It achieves rapid, accurate and stable measurement of plant height and ear height, overcomes the inefficiency and error-prone problems of traditional methods, and has the advantages of fast speed, high accuracy and strong repeatability.
Smart Images

Figure CN114170593B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a plant height and ear height measurement method, a scale recognition method, a system and electronic equipment. Background Art
[0002] Plant height and ear height are important traits that affect the yield of a single plant. Statistical research on the number, plant height and ear height per unit area and breeding of high-quality varieties are of great significance to increasing yield and development. In order to increase yield and lodging resistance and other scientific research experiments, statistical analysis of plant height and ear height is an indispensable part.
[0003] China started late in using digital image technology in agriculture. In recent years, the importance of China's agricultural development has become increasingly prominent. Among them, the technology of using digital image technology for trait measurement has gradually attracted the attention and research of some researchers, and has achieved certain research results in plant height measurement. A common method is to use a camera to collect pictures to predict growth. This method is continuous and can be measured unmanned. The disadvantage is that it can only measure seedlings, not dense adults, and cannot measure ear height. At present, the plant height and ear height of the whole growth process are mainly measured by mechanical equipment such as rulers and manually assisted. However, this measurement requires manual recording and statistical data, which has the disadvantages of low efficiency, cumbersome operation, easy errors, and large labor force. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of existing manual recording and statistical data, such as low efficiency, complicated operation, easy error, large labor force, etc., and provide a plant height and ear height measurement method, a scale recognition method, a system and an electronic device.
[0005] In order to achieve the above purpose, a scale recognition method is disclosed, comprising the following steps:
[0006] Acquire a height image to be measured of the measurement target, wherein the height image to be measured contains a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, and the reference area includes a height line;
[0007] Performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image;
[0008] Performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data;
[0009] Obtaining second scale line areas in the scale image after image processing according to the second scale line predetermined conditions, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculating the position information corresponding to the second scale line area closest to the height line according to the mean distance;
[0010] Obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area.
[0011] As an implementable method, the steps of obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, cutting the height image to be measured according to the scale area, and obtaining a scale image include:
[0012] In the height image to be measured after image processing, a plurality of first short-line areas are obtained according to the first scale line shape characteristic conditions, and a plurality of first scale line areas are obtained according to the first scale line angle conditions in the first short-line areas, and the inclination of each first scale line area is calculated, and the inclination average is calculated according to the inclinations of all the first scale line areas, and the inclination of the height image to be measured is corrected by using the inclination average as the inclination of the height image to be measured to obtain a corrected height image to be measured;
[0013] A coordinate system is established according to the first scale line area, the X-axis coordinate values on the left and right sides of the first scale line area are calculated, and 20 pixels are added to the X-axis coordinate values on the left and right sides as a clipping area to clip the corrected height image to be measured, so as to obtain a scale image.
[0014] As an implementable manner, image processing is performed on the to-be-measured height image. In the to-be-measured height image after image processing, multiple first short-line regions are obtained according to the first scale line shape feature condition. In the first short-line regions, multiple first scale line regions are obtained according to the first scale line included angle condition. The inclination of each first scale line region is calculated, and the average inclination is calculated according to the inclinations of all the first scale line regions. Using the average inclination as the inclination of the to-be-measured height image, the inclination correction of the to-be-measured height image is performed, and the calculation process of obtaining the corrected to-be-measured height image includes:
[0015] The to-be-measured height image is grayscaled, smoothed, binarized, and morphologically processed. Based on the connected components, multiple regions are obtained in the processed to-be-measured height image. The area Area1 corresponding to each region, the aspect ratio w1h1 of the minimum bounding rectangle corresponding to each region, the inclination angle angle1 of the minimum bounding rectangle corresponding to each region, and the area ratio A1wh1 of the area of the same region to the area of the minimum bounding rectangle are calculated;
[0016] The first short-line regions that meet the first scale line shape feature condition are obtained. The first scale line shape feature condition is: (angle1[i] < 45) ∧ (6 < w1h1[i] < 18) ∧ (A1wh1[i] > 0.55) ∧ (200 < Area1[i] < 2000), where Area1[i] represents the area corresponding to the i-th region, w1h1[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th region, angle1[i] represents the inclination angle of the minimum bounding rectangle corresponding to the i-th region, and A1wh1[i] represents the area ratio of the area corresponding to the i-th region to the area of the minimum bounding rectangle;
[0017] The inclination angle angles1 of each first short-line region are calculated. According to the inclination angle angles1 of the first short line, the included angle parallelAcngle1 between any two first short-line regions and the included angle verticalAngle1 between the line connecting the centers of any two first short-line regions and one of the two first short-line regions are calculated. The calculation process is: parallelAngle1 = |angles1[i] - angles1[j]|, verticalAngle1 = |angles1[i] - vertAngles1[k]|, where angles1[i] represents the inclination angle of the i-th first short-line region, angles1[j] represents the inclination angle of the j-th first short-line region, and vertAngles1[k] represents the inclination angle of the line connecting the centers of the i-th first short-line region and the j-th first short-line region;
[0018] Obtain a first scale line region that satisfies the first scale line angle condition in the first short line region, where the first scale line angle condition is: (parallelAcngle1 < 12) ∧ (80 < verticalAngle1 < 100);
[0019] In the formula, the two first scale line regions that satisfy the condition (parallelAcngle1 < 12) are parallel, and the connecting lines of the centers of the two first scale line regions that satisfy the condition (80 < verticalAngle3 < 100) are respectively perpendicular to the two first scale line regions;
[0020] Calculate the inclination angle angles1’ of the first scale line region, and calculate the average inclination angle averageAnglee1’ based on the inclination angles angles1’ of all the first scale line regions. The calculation formula is as follows: In the formula, angles’[i] represents the inclination angle of the i-th first scale line region;
[0021] Use the average inclination angle averageAngle1’ as the inclination angle of the image of the height to be measured to perform inclination correction on the image of the height to be measured, and obtain the corrected image of the height to be measured.
[0022] As an implementable method, in the scale image after image processing, obtain a first scale value region according to the first scale value predetermined condition, cut the scale image after image processing according to the first scale value region to obtain a character image, and perform recognition on the character image based on a recognition model to obtain the scale value data corresponding to the first scale value region. The steps of obtaining one of the scale value data as the first scale value data include:
[0023] In the scale image after image processing, obtain a scale value region according to the first scale value shape feature condition, obtain a single character region according to the single character shape feature condition in the first scale value region, and cut the scale image after image processing according to the single character region to obtain a single character image;
[0024] Perform image processing on the single character image, use a convolutional neural network model to recognize the single character image after image processing to obtain the single character data corresponding to the single character image, and perform combination, sorting, and verification processing on the single character data to obtain the scale value data corresponding to the first scale value region; when there is one scale value data, use the scale value data as the first scale value data, and when there are multiple scale value data, use the scale value data with the largest value as the first scale value data.
[0025] As an implementable manner, in the processed scale image, a scale value area is obtained according to the first scale value contour feature condition. In the first scale value area, a single character area is obtained according to the single character contour feature condition. The process of cutting the processed scale image according to the single character area to obtain a single character image includes:
[0026] Based on the connected components, multiple areas are obtained in the processed scale image. The area Area1’ of each area and the aspect ratio w1h1’ of the minimum bounding rectangle corresponding to each area are calculated.
[0027] The first single character area that meets the first single character contour feature condition is obtained. The first single character contour feature condition is: (0.15 < wlh1’[i] < 0.8) ∧ (700 < Area2’[i] < 10000); where Area1’[i] represents the area corresponding to the i-th area, and w1h1’[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th area.
[0028] The first single character area is subjected to dilation and erosion processing, and adjacent first single character areas are combined to obtain a string area.
[0029] Based on the connected components, multiple areas are obtained in the string area. The area Area2 of each area, the aspect ratio w1h2 of the minimum bounding rectangle corresponding to each area, the tilt angle angle2’ of the minimum bounding rectangle corresponding to each digit area, and the area ratio A1wh2 of the area and the minimum bounding rectangle of the same digit area are calculated.
[0030] In the string area, the first scale value area that meets the first scale value contour feature condition is obtained. The first scale value contour feature condition is: (1.0 < w1h2[i] < 2.5) ∧ (0.5 < A1wh2[i]) ∧ (5000 < Area2[i] < 35000) ∧ (15 > angle2[i]), where Area2[i] represents the area corresponding to the i-th area, w1h2[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th area, angle2[i] represents the tilt angle of the minimum bounding rectangle corresponding to the i-th area, and A1wh2[i] represents the area ratio of the area and the minimum bounding rectangle corresponding to the i-th area.
[0031] In the first scale value area, the number of single character areas is identified according to the second single character contour feature condition, and it is determined whether the number of single character areas in the scale value area meets the predetermined number condition. If it is less than the predetermined number, the scale value area is discarded. If it is equal to the predetermined number, each single character area is obtained. If it is greater than the predetermined number, the predetermined number of single character areas with the closest adjacent distance is obtained.
[0032] Cut the processed scale image based on the obtained single-character regions equal to the predetermined number to obtain single-character images.
[0033] As an implementable manner, the steps of obtaining the second scale line region according to the predetermined conditions of the second scale line in the processed scale image, obtaining the position information corresponding to each second scale line region, and calculating the average distance between adjacent scale line regions according to the position information corresponding to each second scale line region specifically include:
[0034] Based on the connected regions, obtain multiple regions in the processed image of the height to be measured, calculate the area Area2' of each region, the aspect ratio w1h2' of the minimum bounding rectangle corresponding to each region, the tilt angle angle2' of the minimum bounding rectangle corresponding to each region, and the area ratio A1wh2' of the area of the same region and the area of the minimum bounding rectangle;
[0035] Obtain the second scale line regions that simultaneously meet the second scale line shape feature conditions, and the second scale line shape feature conditions are:
[0036] (angle2’[i]<10)∧(6<w1h2’[i]<18)∧(A1wh2’[i]>0.55)∧(200<Area2’[i]<2000), where Area2’[i] represents the area corresponding to the i-th region, w1h2’[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th region, angle2’[i] represents the tilt angle of the minimum bounding rectangle corresponding to the i-th region, and A1wh2’[i] represents the area ratio of the area corresponding to the i-th region and the area of the minimum bounding rectangle;
[0037] Establish a coordinate system according to the second scale line, obtain the Y coordinate corresponding to each second scale line region, and calculate the distance value between adjacent second scale line regions; arrange the distance values of the adjacent second scale line regions from large to small to form an array, obtain the distance values after removing the positions in the first one-third and the last one-third of the array, and calculate the average distance. The calculation formula is:
[0038] In the formula, averageLine represents the average distance, and LineDistArr[j] represents the Y-axis distance value between the i-th second scale line region and the i + 1-th second scale line region.
[0039] As an implementable method, the position information of the height line, the position information of the first scale value data and the position information of the second scale line area are obtained, and the calculation method of obtaining the corresponding scale value data of the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information and the corresponding position information of the second scale line area includes:
[0040] A coordinate system is established according to the second scale line, with the upper left vertex of the scale ruler image as the origin of the coordinate axis, the length direction of the second scale line area is the X axis, the direction in which the scale value data corresponding to the second scale line increases is the positive direction of the Y axis, and the Y axis coordinate value corresponding to the height line, the Y axis coordinate value corresponding to the first scale value data, and the Y axis coordinate value corresponding to the first scale line area are obtained, which are respectively used as the position information endResultY of the height line, the position information MaxPositionY corresponding to the first scale value data, and the position information MaxYLineY corresponding to the first scale line area;
[0041] When MaxYLineY>MaxPositionY, the scale value data ResultValue corresponding to the height line = MaxNum + (MaxYLineY-MaxPositionY) / averageLine + (endResultY-MaxYLineY) / averageLine, wherein MaxNum represents the first scale value data, MaxYLineY is the position information corresponding to the second scale line, MaxPositionY is the position information corresponding to the first scale value data, endResultY represents the position information corresponding to the height line, and averageLine represents the distance average;
[0042] When MaxYLineY≤MaxPositionY, the scale value data ResultValue corresponding to the height line is MaxNum+(endResultY–MaxPositionY) / averageLine, wherein MaxNum represents the first scale value data, MaxPositionY is the position information corresponding to the first scale value data, endResultY represents the position information corresponding to the height line, and averageLine represents the average distance.
[0043] Accordingly, the present invention also provides a method for identifying plant height and ear height, comprising the following steps:
[0044] Acquire a height image to be measured of the measurement target, wherein the height image to be measured includes a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, the reference area includes a height line, and the scale value data corresponding to the height line is the plant height or ear height to be measured;
[0045] Performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image;
[0046] Performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data;
[0047] Obtaining second scale line areas in the scale image after image processing according to the second scale line predetermined conditions, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculating the position information corresponding to the second scale line area closest to the height line according to the mean distance;
[0048] Obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area.
[0049] Accordingly, the present invention also provides a scale recognition system, comprising the following modules:
[0050] An acquisition module: acquires a height image to be measured of a measurement target, wherein the height image to be measured contains a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, and the reference area includes a height line;
[0051] A scale cutting module: performing image processing on the height image to be measured, obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image;
[0052] A first scale value recognition module: performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data;
[0053] The second scale line recognition module: obtains the second scale line area in the scale image after image processing according to the second scale line predetermined condition, obtains the position information corresponding to each second scale line area, calculates the average distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculates the position information corresponding to the second scale line area closest to the height line according to the distance average;
[0054] Calculation module: obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area.
[0055] Correspondingly, the present invention also provides an electronic device comprising: at least one processor, and a memory communicatively connected to at least one of the processors; at least one of the processors is used to read a program in the memory to execute any of the above methods.
[0056] Beneficial effects of the present invention: The present invention provides a plant height and ear height measurement method, a scale recognition method, a system and an electronic device, including: cutting the height image to be measured to obtain a scale image; cutting the scale image to obtain a character image, and recognizing the character image to obtain corresponding first scale value data; calculating the distance mean of adjacent second scale line areas in the scale image; calculating the position information corresponding to the second scale line area closest to the height line according to the distance mean; calculating the corresponding scale value data of the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area. The present invention applies image recognition technology to the field of crop trait measurement, overcomes the shortcomings of slow statistical data speed, easy error, and cumbersomeness of traditional measurement, and has the advantages of fast speed, high accuracy, strong stability, and repeatable batch processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 Schematic diagram of the steps of the scale recognition method according to an embodiment of the present invention.
[0058] Figure 2 A schematic diagram of a height image to be measured obtained by the scale recognition method according to an embodiment of the present invention.
[0059] Figure 3 This is a schematic diagram of a software shooting interface when the scale recognition method according to an embodiment of the present invention obtains an image of the height to be measured of a measurement target.
[0060] Figure 4 It is a schematic diagram of the effect obtained after the scale recognition method according to an embodiment of the present invention performs image processing on the height image to be measured.
[0061] Figure 5 This is a schematic diagram of the effect of selecting the first short line area according to the first scale line appearance feature condition in the scale recognition method according to an embodiment of the present invention.
[0062] Figure 6 It is a schematic diagram of the effect of the corrected image of the height to be measured obtained by the scale recognition method according to an embodiment of the present invention.
[0063] Figure 7 It is a schematic diagram of the ruler image effect obtained by the ruler recognition method according to an embodiment of the present invention.
[0064] Figure 8 It is a schematic diagram of the effect after the scale recognition method according to an embodiment of the present invention performs image processing on the scale image.
[0065] Fig. 9 It is a schematic diagram of the effect of removing the interference area outside the first single character area by the scale recognition method according to an embodiment of the present invention.
[0066] Fig.10 It is a schematic diagram of the effect of identifying the first scale value area by the scale recognition method according to an embodiment of the present invention.
[0067] Fig.11 It is a schematic diagram of the effect of obtaining the first scale value area by the scale recognition method according to an embodiment of the present invention.
[0068] Fig.12 This is a diagram showing the effect of obtaining a single character area by the scale recognition method according to an embodiment of the present invention.
[0069] Fig.13 It is a schematic diagram of components of a scale part in a height image to be measured in a scale recognition method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0071] See also Figure 1 This embodiment provides a technical solution: a scale recognition method, comprising the following steps:
[0072] Step S100: Acquire a height image to be measured of the measurement target, wherein the height image to be measured includes a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, the reference area includes a height line, wherein the scale value data corresponding to the height line is the height to be measured;
[0073] Step S200: performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image;
[0074] Step S300: performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data;
[0075] Step S400: obtaining second scale line areas in the scale image after image processing according to the second scale line predetermined conditions, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; and calculating the position information corresponding to the second scale line area closest to the height line according to the mean distance;
[0076] Step S500: Obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area.
[0077] like Figure 2As shown in the figure, the image of the height to be measured is obtained. In this embodiment, there are certain limitations on obtaining the image of the height to be measured of the measurement target. The mobile phone selected here is Xiaomi 6x, with a rear camera of 12 million. The distance when taking pictures is between 10-20 cm, and the focus must be clear. It is ensured that there are more than 3 scale lines in the image of the height to be measured and at least one scale line is marked with a scale value, such as Figure 3 As shown, this is a diagram showing the effect of the software shooting interface when obtaining the image of the height to be measured of the measurement target.
[0078] In this embodiment, if Fig.13 As shown, the scale portion includes a reference area 20 and a scale area 10, the scale area includes scale lines 11, and at least one scale line is marked with a scale value 12, the scale value data corresponding to the scale lines increase from top to bottom, and the scale value data corresponding to adjacent scale lines differ by 1 cm, the reference area is located below the scale area, and the scale value data corresponding to the height line 21 on the upper side of the reference area is the measured data, i.e., plant height or ear height, etc.; however, in other embodiments, the scale value data corresponding to the scale lines may also decrease from top to bottom.
[0079] In this embodiment, the recognition model selected is a convolutional neural network, the template library is a single character image of 10 numbers from 0 to 9, and the library has a total of 17,000 character images. The trained model and parameters are saved in the model for use in recognition.
[0080] The steps of obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image include:
[0081] Obtaining a first short-line region in the height image to be measured after image processing according to the first scale line shape characteristic condition, obtaining a plurality of first scale line regions in the first short-line region according to the first scale line angle condition, calculating the inclination of each first scale line region, calculating the inclination average according to the inclinations of all the first scale line regions, using the inclination average as the inclination of the height image to be measured to perform inclination correction on the height image to be measured, and obtaining a corrected height image to be measured;
[0082] A coordinate system is established according to the first scale line area, the X-axis coordinate values on the left and right sides of the first scale line area are calculated, and 20 pixels are added to the X-axis coordinate values on the left and right sides as a clipping area to clip the corrected height image to be measured, so as to obtain a scale image.
[0083] Specifically, in the two-dimensional coordinate system of the height image to be measured, the upper left corner of the height image to be measured is set as the point (0, 0), the horizontal axis of the image is the positive X direction, and the vertical axis of the image is the positive Y direction; obtain the first scale line area, and count the minimum X coordinate of the first scale line area in the two-dimensional coordinate system, that is, the leftmost side of all short lines, denoted as X_left, and count the maximum X coordinate of the first scale line area, that is, the rightmost side of all short lines, denoted as X_right; expand the actual values of X_left and X_right outward by 20 pixel points, and cut out the image between the expanded X_left and X_right, which is used as the effective area, as Figure 7 shown is the scale image obtained after cutting the height image to be measured.
[0084] Perform image processing on the height image to be measured. In the processed height image to be measured, obtain the first short line area according to the external shape feature conditions of the first scale line. In the first short line area, obtain multiple first scale line areas according to the included angle conditions of the first scale line. Calculate the inclination of each first scale line area, and calculate the average inclination according to the inclinations of all the first scale line areas. Use the average inclination as the inclination of the height image to be measured to perform inclination correction on the height image to be measured. The calculation process of the corrected height image to be measured includes:
[0085] Perform processing such as grayscale conversion, smoothing, binarization, and morphology on the height image to be measured, as Figure 4 shown is the schematic diagram of the effect after processing the height image to be measured. Based on the connected regions, obtain multiple regions in the processed height image to be measured, and calculate the area Area1 corresponding to each region, the aspect ratio w1h1 of the minimum circumscribed rectangle corresponding to each region, the inclination angle angle1 of the minimum circumscribed rectangle corresponding to each region, and the area ratio A1wh1 of the area of the same region to the area of the minimum circumscribed rectangle;
[0086] Obtain the first short line area that meets the external shape feature conditions of the first scale line. The external shape feature conditions of the first scale line are: (angle1[i] < 45) ∧ (6 < w1h1[i] < 18) ∧ (A1wh1[i] > 0.55) ∧ (200 < Area1[i] < 2000), that is, it is necessary to meet the above four conditions at the same time. In the formula, Area1[i] represents the area corresponding to the i-th region, w1h1[i] represents the aspect ratio of the minimum circumscribed rectangle corresponding to the i-th region, angle1[i] represents the inclination angle of the minimum circumscribed rectangle corresponding to the i-th region, and A1wh1[i] represents the area ratio of the area corresponding to the i-th region to the area of the minimum circumscribed rectangle;
[0087] as Figure 5The figure shows the effect display diagram of the first short line region selected according to the shape feature conditions of the first scale line. Calculate the inclination angles angles1 of each first short line region. According to the inclination angles angles1 of the first short lines, calculate the included angle parallelAcngle1 between any two first short line regions and the included angle verticalAngle1 between the connecting line of the center points of any two first short line regions and one of the two first short line regions. The calculation process is as follows: parallelAngle1 = |angles1[i] - angles1[j]|, verticalAngle1 = |angles1[i] - vertAngles1[k]|, where angles1[i] represents the inclination angle of the i-th first short line region, angles1[j] represents the inclination angle of the j-th first short line region, and vertAngles1[k] represents the inclination angle of the connecting line of the center points of the i-th first short line region and the j-th first short line region;
[0088] Obtain the first scale line region that meets the first scale line included angle condition in the first short line region. The first scale line included angle condition is: (parallelAcngle1 < 12) ∧ (80 < verticalAngle1 < 100);
[0089] That is, it is necessary to meet the above two conditions at the same time. In the formula, the two first scale line regions that meet the condition (parallelAcngle1 < 12) are parallel to each other, and the connecting lines of the center points of the two first scale line regions that meet the condition (80 < verticalAngle3 < 100) are respectively perpendicular to the two first scale line regions;
[0090] Calculate the inclination degree angles1’ of the first scale line region. Calculate the average inclination degree averageAnglee1’ according to the inclination degrees angles1’ of all the first scale line regions. The calculation formula is as follows: In the formula, angles’[i] represents the inclination degree of the i-th first scale line region;
[0091] Use the average inclination degree averageAngle1’ as the inclination degree of the image of the height to be measured, and perform inclination correction on the image of the height to be measured to obtain the corrected image of the height to be measured.
[0092] Such as Figure 5The following shows the corrected height image to be measured. Among them, the average inclination is used as the inclination of the height image to be measured, and the corrected height image to be measured obtained after correcting the inclination of the height image to be measured is still the same size as the original image and is still a color image. The technology of finally performing inclination correction according to the obtained value is the prior art, and will not be described in detail in this embodiment..
[0093] In this embodiment, the mean filter is mainly used for the smoothing process among graying, smoothing, binarization, and morphological processing of the height image to be measured. The output of the mean filter is the simple average of the corresponding pixel values of the input image in the sliding window of each pixel, and it has a good effect on noise processing; the kernel size of the filter used here is 3*3. The binarization uses local adaptive binarization, and the kernel size is 25*25. The morphology is used to eliminate small particle noise and the boundaries of connected domains, and the kernel size of the morphological operation is 3*3.
[0094] In this embodiment, (angle1[i]<45) in the first scale line shape feature condition is used to limit photographing, and the inclination angle of the camera during photographing cannot exceed 45 degrees. (6<w1h1[i]<18) limits the aspect ratio range of the area. (A1wh1[i]>0.55) represents the ratio of the area of the area to the area of the minimum circumscribed rectangle of the short line. (200<Area1[i]<2000) limits the area range of the area. In this embodiment, the first short line area is roughly screened out through the above feature conditions. At this time, there may be some interference from short lines similar to scales, so further screening is needed next.
[0095] The image processing of the scale image includes graying, smoothing, binarization, morphology and other processes, as Figure 8 The following shows the effect display diagram obtained after graying, smoothing, binarization, morphology and other processes on the scale image.
[0096] In the processed scale image, the first scale value area is obtained according to the first scale value preset condition. The processed scale image is cut according to the first scale value area to obtain a character image. Based on the recognition model, the character image is recognized to obtain the scale value data corresponding to the first scale value area. The steps of obtaining one of the scale value data as the first scale value data include:[[]]
[0097] A scale value region is obtained in the scale ruler image after image processing according to the first scale value appearance feature condition, a single character region is obtained in the first scale value region according to the single character appearance feature condition, and the scale ruler image after image processing is cut according to the single character region to obtain a single character image; image processing is performed on the single character image, and the single character image after image processing is recognized by using a convolutional neural network model to obtain single character data corresponding to the single character image, and the single character data is combined, sorted, and verified to obtain scale value data corresponding to the first scale value region; when there is one scale value data, the scale value data is used as the first scale value data, and when there are multiple scale value data, the scale value data with the largest value is used as the first scale value data.
[0098] The steps of performing image processing on the single character image, recognizing the single character image after image processing using a convolutional neural network model to obtain single character data corresponding to the single character image, and combining, sorting, and verifying the single character data to obtain scale value data corresponding to the first scale value area include:
[0099] The single character image is filtered, grayed, and scaled to a size of 64*32, and converted into data in a neural network input format and saved in imgdataArr; a convolutional neural network model is established; a template library is established, and the library is a single character image of 10 numbers from 0 to 9; the training library has a total of 17,000 character images, and the training steps are 20,000; imgdataArr is obtained, and the s1 training result model1 is obtained, and imgdataArr is imported into the convolutional neural network model to identify the corresponding number, and the number is saved in numberArr; a network is established, and the pre-trained network model and parameter mode are read in. l1; Import character data imgdataArr, identify the result, and save it to numberArr; Get the number numberArr, perform combination, sorting, verification and other operations, and output the coordinates and position of the largest number; Combine the identified numbers. The principle is that the three numbers in the same area are sorted from small to large according to the X coordinate, which are hundreds, tens, and units respectively; Then sort the combined numbers from small to large according to the Y coordinate, that is, sort the numbers from small to large; According to the number rule of the measuring ruler, the difference between the two numbers is 5. If the number of numbers is more than two, the final maximum value is verified. If it is correct, the maximum value and its position are output.
[0100] The process of obtaining a scale value region according to the first scale value shape feature condition in the scale image after image processing, obtaining a single character region according to the single character shape feature condition in the first scale value region, and cutting the scale image after image processing according to the single character region to obtain a single character image includes:
[0101] Multiple regions are obtained from the scale image after image processing based on connected components, and the area Area1' of each region and the aspect ratio w1h1' of the minimum bounding rectangle corresponding to each region are calculated;
[0102] The first single-character region satisfying the first single-character shape feature condition is obtained, and the first single-character shape feature condition is: (0.15 < wlh1'[i] < 0.8) ∧ (700 < Area2'[i] < 10000);
[0103] That is, it is necessary to satisfy the above two conditions at the same time. In the formula, Area1'[i] represents the area corresponding to the i-th region, and w1h1'[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th region; other interference factors other than the first single-character region are removed, and the first single-character region is subjected to dilation and erosion processing, where the kernel size is 15 * 7, and adjacent first single-character regions are combined to obtain a string region; as Fig. 9 Shown is the effect display diagram obtained after removing other interference factors other than the first single-character region after obtaining the first single-character region.
[0104] Multiple regions are obtained from the string region based on connected components, and the area Area2 of each region, the aspect ratio w1h2 of the minimum bounding rectangle corresponding to each region, the tilt angle angle2' of the minimum bounding rectangle corresponding to each digital region, and the area ratio A1wh2 of the area of the same digital region and the area of the minimum bounding rectangle are calculated;
[0105] The first scale value region satisfying the first scale value shape feature condition is obtained in the string region, and the first scale value shape feature condition is: (1.0 < w1h2[i] < 2.5) ∧ (0.5 < A1wh2[i]) ∧ (5000 < Area2[i] < 35000) ∧ (15 > angle2[i]), that is, it is necessary to satisfy the above four conditions at the same time. In the formula, Area2[i] represents the area corresponding to the i-th region, w1h2[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th region, angle2[i] represents the tilt angle of the minimum bounding rectangle corresponding to the i-th region, and A1wh2[i] represents the area ratio of the area corresponding to the i-th region and the area of the minimum bounding rectangle; (1.0 < w1h[i] < 2.5) is to limit the aspect ratio range of the first scale value region, (A1wh[i] > 0.5) is the ratio of the area of the first scale value region and the area of the minimum circumscribed rectangle of the digital connected component, (5000 < Area[i] < 35000) is to limit the area range of the first scale value region, and (angle[i] < 15) means that the tilt angle of the first scale value region does not exceed 15 degrees. As Fig.10 and Fig.11 The figure shows the effect of identifying and obtaining the first scale value area.
[0106] After further screening under the above conditions, what remains is a digital area with a digital string as the whole. Digital recognition requires a single character image, so the position of a single digital character will be accurately located in the digital area, and then a single character image will be obtained. The specific process is as follows:
[0107] In the first scale value area, the number of single character areas is identified according to the second single character shape feature condition, and it is determined whether the number of single character areas in the scale value area meets the predetermined number condition. If it is less than the predetermined number, the scale value area is abandoned. If it is equal to the predetermined number, each single character area therein is obtained. If it is greater than the predetermined number, the single character areas with the closest adjacent predetermined number are obtained, and the numbers and coordinates are recorded; Fig.12 The figure shows the effect of obtaining a single character area, in which the single characters are all numbers.
[0108] For example, in the present embodiment, the numbers in the first scale value area are all three-digit numbers, so a) if the number of single character areas rectNum is less than 3, then the first scale value area is abandoned; b) if the number of single character areas rectNum is equal to 3, then these three areas are determined to be single character areas, and their positions are recorded; c) if the number of single characters rectNum is greater than 3, then the three single character areas closest to the first scale value area are selected and their positions are recorded; in this step, the distance calculation uses the city block distance.
[0109] The scale image after image processing is cut according to the acquired single character regions equal to a predetermined number to obtain single character images.
[0110] The steps of obtaining second scale line areas according to the second scale line predetermined conditions in the scale image after image processing, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent scale line areas according to the position information corresponding to each second scale line area specifically include:
[0111] Based on the connected domain, multiple regions are obtained in the height image to be measured after image processing, and the area Area2' of each region, the aspect ratio w1h2' of the minimum outer rectangle corresponding to each region, the inclination angle angle2' of the minimum outer rectangle corresponding to each region, and the area ratio A1wh2' of the same region and the minimum outer rectangle are calculated;
[0112] A second scale line region that satisfies a second scale line shape characteristic condition is obtained, wherein the second scale line shape characteristic condition is:
[0113] (angle2’[i] < 10) ∧ (6 < w1h2’[i] < 18) ∧ (A1wh2’[i] > 0.55) ∧ (200 < Area2’[i] < 2000), that is, the above four conditions need to be satisfied simultaneously. In the formula, Area2’[i] represents the area corresponding to the i-th region, w1h2’[i] represents the aspect ratio of the minimum external rectangle corresponding to the i-th region, angle2’[i] represents the inclination angle of the minimum external rectangle corresponding to the i-th region, and A1wh2’[i] represents the ratio of the area of the i-th region to the area of the minimum external rectangle;
[0114] Establish a coordinate system according to the second scale line, obtain the Y coordinate corresponding to each second scale line region, and calculate the distance value between adjacent second scale line regions according to the Y coordinate corresponding to each second scale line region; Arrange the distance values between the adjacent second scale line regions in descending order to form an array, obtain the distance values after removing the positions in the first one-third and the last one-third of the array, and calculate the average distance value. The calculation formula is:
[0115] In the formula, averageLine represents the average distance value, and LineDistArr[j] represents the Y-axis distance value between the i-th second scale line region and the (i + 1)-th second scale line region.
[0116] Obtain the position information of the height line, the position information of the first scale value data, and the position information of the second scale line region. The calculation method for obtaining the scale value data corresponding to the height line according to the average distance value, the position information of the height line, the first scale value data, the corresponding position information, and the position information corresponding to the second scale line region includes:
[0117] Establish a coordinate system according to the second scale line, with the upper left vertex of the scale image as the origin of the coordinate axis, the length direction of the second scale line region as the X-axis, and the direction in which the scale value data corresponding to the second scale line increases as the positive direction of the Y-axis. Obtain the Y-axis coordinate value corresponding to the height line, the Y-axis coordinate value corresponding to the first scale value data, and the Y-axis coordinate value corresponding to the first scale line region, and use them as the position information endResultY of the height line, the position information MaxPositionY corresponding to the first scale value data, and the position information MaxYLineY corresponding to the first scale line region, respectively;
[0118] When MaxYLineY>MaxPositionY, the scale value data ResultValue corresponding to the height line = MaxNum + (MaxYLineY-MaxPositionY) / averageLine + (endResultY-MaxYLineY) / averageLine, wherein MaxNum represents the first scale value data, MaxYLineY is the position information corresponding to the second scale line, MaxPositionY is the position information corresponding to the first scale value data, endResultY represents the position information corresponding to the height line, and averageLine represents the distance average;
[0119] When MaxYLineY≤MaxPositionY, the scale value data ResultValue corresponding to the height line is MaxNum+(endResultY–MaxPositionY) / averageLine, wherein MaxNum represents the first scale value data, MaxPositionY is the position information corresponding to the first scale value data, endResultY represents the position information corresponding to the height line, and averageLine represents the average distance.
[0120] The method for obtaining the height line is that, since the reference area where the height line is located is displayed in black and the area above the reference area is displayed in white, scanning is performed downward from the second scale line area until a black and white boundary appears in the image, that is, the position of the black and white boundary is the position of the height line, and the position information of the black and white boundary obtained according to the coordinate axis is the position information of the height line.
[0121] The present invention applies digital image processing technology to the measurement of corn plant height and ear height in the field of corn trait measurement, replacing manual data recording and statistical analysis data, saving labor costs, overcoming the shortcomings of slow statistical data speed, easy errors, and cumbersomeness of traditional measurements, and also making up for the shortcomings of not being able to measure ear height when the camera collects pictures to predict corn growth and not being able to measure corn ear height in dense corn fields, thereby improving work efficiency.
[0122] The present invention successfully applies image recognition technology to the field of crop trait measurement, and has the advantages of fast speed, high accuracy, strong stability, and repeatable batch processing, and has promoted the application of image recognition in crop trait measurement. The present invention has been tested and applied in the measurement and analysis of corn traits, and has achieved good results. This invention can also be extended to the height measurement of other crops, providing strong technical support for crop height measurement, and has the advantages of convenient and accurate data statistics.
[0123] Based on the same inventive concept, an embodiment of the present invention also provides a method for identifying plant height and ear height, comprising the following steps:
[0124] Acquire a height image to be measured of the measurement target, wherein the height image to be measured includes a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, the reference area includes a height line, and the scale value data corresponding to the height line is the plant height or ear height to be measured;
[0125] Performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image;
[0126] Performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data;
[0127] Obtaining second scale line areas in the scale image after image processing according to the second scale line predetermined conditions, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculating the position information corresponding to the second scale line area closest to the height line according to the mean distance;
[0128] Obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area.
[0129] Based on the same inventive concept, an embodiment of the present invention further provides a scale recognition system, and regarding the components, reference can be made to the above-mentioned related descriptions, and the repeated parts will not be repeated, and the system includes the following modules:
[0130] An acquisition module: acquires a height image to be measured of a measurement target, wherein the height image to be measured includes a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, the reference area includes a height line, wherein the scale value data corresponding to the height line is the height to be measured;
[0131] A scale cutting module: performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the corrected height image to be measured according to the scale area to obtain a scale image;
[0132] A first scale value recognition module: performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data;
[0133] The second scale line recognition module: obtains the second scale line area in the scale ruler image after image processing according to the second scale line predetermined condition, obtains the position information corresponding to each second scale line area, calculates the average distance between adjacent scale line areas according to the position information corresponding to each second scale line area; calculates the position information corresponding to the second scale line area closest to the height line according to the average distance between adjacent second scale line areas;
[0134] Calculation module: obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area.
[0135] Based on the same inventive concept, an embodiment of the present invention also provides an electronic device. Regarding the components, please refer to the above-mentioned related descriptions, and the repeated parts will not be repeated here. It includes: at least one processor, and a memory communicatively connected to the at least one processor; the at least one processor is used to read the program in the memory to execute the method described above.
[0136] Although the present invention has been disclosed as above in the form of a preferred embodiment, it is not intended to limit the present invention. Any person skilled in the art may make possible changes and modifications to the technical solution of the present invention by using the methods and technical contents disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the protection scope of the technical solution of the present invention.
Claims
1. A scale recognition method, characterized in that: The following steps are involved: Acquire a height image to be measured of the measurement target, wherein the height image to be measured contains a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, and the reference area includes a height line; Performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image; Performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data; Obtaining second scale line areas in the scale image after image processing according to the second scale line predetermined conditions, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculating the position information corresponding to the second scale line area closest to the height line according to the mean distance; Acquire the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area; The steps of obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image include: In the height image to be measured after image processing, a plurality of first short-line areas are obtained according to the first scale line shape characteristic conditions, and a plurality of first scale line areas are obtained according to the first scale line angle conditions in the first short-line areas, and the inclination of each first scale line area is calculated, and the inclination average is calculated according to the inclinations of all the first scale line areas, and the inclination of the height image to be measured is corrected by using the inclination average as the inclination of the height image to be measured to obtain a corrected height image to be measured; A coordinate system is established according to the first scale line area, the X-axis coordinate values on the left and right sides of the first scale line area are calculated, and 20 pixels are added to the X-axis coordinate values on the left and right sides as a clipping area to clip the corrected height image to be measured, so as to obtain a scale image.
2. The scale recognition method according to claim 1, characterized in that: The calculation process of performing image processing on the height image to be measured, obtaining multiple first short line regions in the processed height image to be measured according to the first scale line shape feature condition, obtaining multiple first scale line regions in the first short line regions according to the first scale line included angle condition, calculating the inclination of each first scale line region, calculating the average inclination according to the inclinations of all the first scale line regions, and using the average inclination as the inclination of the height image to be measured to perform inclination correction on the height image to be measured to obtain the corrected height image to be measured includes: Performing graying, smoothing, binarization, and morphological processing on the height image to be measured, obtaining multiple regions in the processed height image to be measured based on connected components, calculating the area Area1 corresponding to each region, the aspect ratio w1h1 of the minimum circumscribed rectangle corresponding to each region, the inclination angle angle1 of the minimum circumscribed rectangle corresponding to each region, and the area ratio A1wh1 of the area of the same region to the area of the minimum circumscribed rectangle; Obtaining the first short line regions that meet the first scale line shape feature condition, where the first scale line shape feature condition is: (angle1[i] < 45) ∧ (6 < w1h1[i] < 18) ∧ (A1wh1[i] > 0.55) ∧ (200 < Area1[i] < 2000), where Area1[i] represents the area corresponding to the i-th region, w1h1[i] represents the aspect ratio of the minimum circumscribed rectangle corresponding to the i-th region, angle1[i] represents the inclination angle of the minimum circumscribed rectangle corresponding to the i-th region, and A1wh1[i] represents the area ratio of the area corresponding to the i-th region to the area of the minimum circumscribed rectangle; Calculating the inclination angle angles1 of each first short line region, calculating the included angle parallelAcngle1 between any two first short line regions and the included angle verticalAngle1 between the line connecting the center points of any two first short line regions and one of the two first short line regions according to the inclination angle angles1 of the first short line, and the calculation process is: parallelAngle1 = |angles1[i] - angles1[j]|, verticalAngle1 = |angles1[i] - vertAngles1[k]|, where angles1[i] represents the inclination angle of the i-th first short line region, angles1[j] represents the inclination angle of the j-th first short line region, and vertAngles1[k] represents the inclination angle of the line connecting the center points of the i-th first short line region and the j-th first short line region; Obtaining the first scale line regions that meet the first scale line included angle condition in the first short line regions, where the first scale line included angle condition is: (parallelAcngle1 < 12) ∧ (80 < verticalAngle1 < 100); In the formula, the two first scale line regions that satisfy the condition (parallelAcngle1 < 12) are parallel to each other, and the connecting lines of the center points of the two first scale line regions that satisfy the condition (80 < verticalAngle3 < 100) are respectively perpendicular to the two first scale line regions; Calculate the inclination angle angles1’ of the first scale line region, and calculate the average inclination angle averageAnglee1’ according to the inclination angles angles1’ of all the first scale line regions. The calculation formula is as follows: Where angles'[i] represents the inclination of the i-th first scale line area; Use the average inclination angle averageAngle1’ as the inclination angle of the height image to be measured, and perform inclination correction on the height image to be measured to obtain the corrected height image to be measured.
3. The scale recognition method according to claim 1, characterized in that: In the processed scale image, obtain the first scale value region according to the first scale value preset condition, cut the processed scale image according to the first scale value region to obtain a character image, and perform recognition on the character image based on the recognition model to obtain the scale value data corresponding to the first scale value region. The step of obtaining one of the scale value data as the first scale value data includes: In the processed scale image, obtain the scale value region according to the first scale value shape feature condition, obtain the single character region according to the single character shape feature condition in the first scale value region, and cut the processed scale image according to the single character region to obtain a single character image; Perform image processing on the single character image, use the convolutional neural network model to recognize the processed single character image to obtain the single character data corresponding to the single character image, and perform combination, sorting, and verification processing on the single character data to obtain the scale value data corresponding to the first scale value region; when there is one scale value data, use the scale value data as the first scale value data, and when there are multiple scale value data, use the largest scale value data as the first scale value data.
4. The scale recognition method according to claim 3, characterized in that: In the processed scale image, obtain the scale value region according to the first scale value shape feature condition, obtain the single character region according to the single character shape feature condition in the first scale value region, and cut the processed scale image according to the single character region to obtain a single character image. The calculation process includes: Based on the connected domain, obtain multiple regions in the processed scale image, and calculate the area Area1’ of each region and the aspect ratio w1h1’ of the minimum circumscribed rectangle corresponding to each region; Obtain the first single character region that satisfies the first single character shape feature condition. The first single character shape feature condition is: (0.15 < wlh1’[i] < 0.8) ∧ (700 < Area2’[i] < 10000); where Area1’[i] represents the area corresponding to the i-th region, and w1h1’[i] represents the aspect ratio of the minimum circumscribed rectangle corresponding to the i-th region; Perform dilation and erosion processing on the first single character region, and combine adjacent first single character regions to obtain a string region; Based on the connected components, multiple regions are obtained in the string region, and the area Area2 of each region, the aspect ratio w1h2 of the minimum bounding rectangle corresponding to each region, the tilt angle angle2' of the minimum bounding rectangle corresponding to each digit region, and the area ratio A1wh2 of the area of the same digit region to the area of the minimum bounding rectangle are calculated; In the string region, a first scale value region that meets the first scale value shape feature condition is obtained. The first scale value shape feature condition is: (1.0 < w1h2[i] < 2.5) ∧ (0.5 < A1wh2[i]) ∧ (5000 < Area2[i] < 35000) ∧ (15 > angle2[i]), where Area2[i] represents the area corresponding to the i-th region, w1h2[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th region, angle2[i] represents the tilt angle of the minimum bounding rectangle corresponding to the i-th region, and A1wh2[i] represents the area ratio of the area corresponding to the i-th region to the area of the minimum bounding rectangle; In the first scale value region, the number of single character regions is identified according to the second single character shape feature condition, and it is determined whether the number of single character regions in the scale value region meets the predetermined number condition. If it is less than the predetermined number, the scale value region is abandoned. If it is equal to the predetermined number, each single character region is obtained. If it is greater than the predetermined number, the predetermined number of single character regions with the closest adjacent distance is obtained; The processed scale image is cut according to the obtained single character regions equal to the predetermined number to obtain single character images.
5. The scale recognition method according to claim 1, characterized in that: The steps of obtaining the second scale line region according to the second scale line predetermined condition in the processed scale image, obtaining the position information corresponding to each second scale line region, and calculating the average distance between adjacent scale line regions according to the position information corresponding to each second scale line region specifically include: Based on the connected components, multiple regions are obtained in the processed image of the height to be measured, and the area Area2' of each region, the aspect ratio w1h2' of the minimum bounding rectangle corresponding to each region, the tilt angle angle2' of the minimum bounding rectangle corresponding to each region, and the area ratio A1wh2' of the area of the same region to the area of the minimum bounding rectangle are calculated; Obtain the second scale line region that simultaneously meets the second scale line shape feature condition. The second scale line shape feature condition is: (angle2’[i] < 10) ∧ (6 < w1h2’[i] < 18) ∧ (A1wh2’[i] > 0.55) ∧ (200 < Area2’[i] < 2000), where Area2’[i] represents the area corresponding to the i-th region, w1h2’[i] represents the aspect ratio of the minimum bounding rectangle corresponding to the i-th region, angle2’[i] represents the tilt angle of the minimum bounding rectangle corresponding to the i-th region, and A1wh2’[i] represents the area ratio of the area corresponding to the i-th region to the area of the minimum bounding rectangle; Establish a coordinate system according to the second scale line, obtain the Y coordinate corresponding to each second scale line area, and calculate the distance value of the adjacent second scale line area according to the Y coordinate corresponding to each second scale line area; arrange the distance values of the adjacent second scale line areas from large to small to form an array, obtain the distance values after removing the first third of the array and the last third of the array, and calculate the distance mean. The calculation formula is: In the formula, averageLine represents the distance average, and LineDistArr[j] represents the Y-axis distance value between the i-th second scale line area and the i+1-th second scale line area.
6. The scale recognition method according to claim 1, characterized in that: The method of obtaining the position information of the height line, the position information of the first scale value data and the position information of the second scale line area, and calculating the corresponding scale value data of the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information and the corresponding position information of the second scale line area includes: A coordinate system is established according to the second scale line, with the upper left vertex of the scale ruler image as the origin of the coordinate axis, the length direction of the second scale line area is the X axis, the direction in which the scale value data corresponding to the second scale line increases is the positive direction of the Y axis, and the Y axis coordinate value corresponding to the height line, the Y axis coordinate value corresponding to the first scale value data, and the Y axis coordinate value corresponding to the first scale line area are obtained, which are respectively used as the position information endResultY of the height line, the position information MaxPositionY corresponding to the first scale value data, and the position information MaxYLineY corresponding to the first scale line area; When MaxYLineY>MaxPositionY, the scale value data ResultValue corresponding to the height line = MaxNum + (MaxYLineY-MaxPositionY) / averageLine + (endResultY-MaxYLineY) / averageLine, wherein MaxNum represents the first scale value data, MaxYLineY is the position information corresponding to the second scale line, MaxPositionY is the position information corresponding to the first scale value data, endResultY represents the position information corresponding to the height line, and averageLine represents the distance average; When MaxYLineY≤MaxPositionY, the scale value data ResultValue corresponding to the height line is MaxNum+(endResultY–MaxPositionY) / averageLine, wherein MaxNum represents the first scale value data, MaxPositionY is the position information corresponding to the first scale value data, endResultY represents the position information corresponding to the height line, and averageLine represents the average distance.
7. A method for identifying plant height and ear height, characterized in that: The following steps are involved: Acquire a height image to be measured of the measurement target, wherein the height image to be measured includes a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, the reference area includes a height line, and the scale value data corresponding to the height line is the plant height or ear height to be measured; Performing image processing on the height image to be measured, obtaining a first scale line area in the height image to be measured after image processing according to a predetermined condition of the first scale line, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image; Performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data; Obtaining second scale line areas in the scale image after image processing according to the second scale line predetermined conditions, obtaining position information corresponding to each second scale line area, and calculating the mean distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculating the position information corresponding to the second scale line area closest to the height line according to the mean distance; Acquire the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area; The steps of obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image include: In the height image to be measured after image processing, a plurality of first short-line areas are obtained according to the first scale line shape characteristic conditions, and a plurality of first scale line areas are obtained according to the first scale line angle conditions in the first short-line areas, and the inclination of each first scale line area is calculated, and the inclination average is calculated according to the inclinations of all the first scale line areas, and the inclination of the height image to be measured is corrected by using the inclination average as the inclination of the height image to be measured to obtain a corrected height image to be measured; A coordinate system is established according to the first scale line area, the X-axis coordinate values on the left and right sides of the first scale line area are calculated, and 20 pixels are added to the X-axis coordinate values on the left and right sides as a clipping area to clip the corrected height image to be measured, so as to obtain a scale image.
8. A scale recognition system, characterized in that: Includes the following modules: An acquisition module: acquires a height image to be measured of a measurement target, wherein the height image to be measured contains a partial scale, the partial scale includes a scale area and a reference area, the scale area includes a plurality of scale lines and at least one scale line is marked with a scale value, and the reference area includes a height line; A scale cutting module: performing image processing on the height image to be measured, obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image; A first scale value recognition module: performing image processing on the scale image, obtaining a first scale value region in the scale image after image processing according to a first scale value predetermined condition, cutting the scale image after image processing according to the first scale value region to obtain a character image, recognizing the character image based on a recognition model to obtain scale value data corresponding to the first scale value region, and obtaining one of the scale value data as the first scale value data; The second scale line recognition module: obtains the second scale line area in the scale image after image processing according to the second scale line predetermined condition, obtains the position information corresponding to each second scale line area, calculates the average distance between adjacent second scale line areas according to the position information corresponding to each second scale line area; calculates the position information corresponding to the second scale line area closest to the height line according to the distance average; Calculation module: obtain the position information of the height line and the position information corresponding to the first scale value data, and calculate the scale value data corresponding to the height line according to the distance mean, the position information of the height line, the first scale value data and the corresponding position information, and the position information corresponding to the second scale line area; The steps of obtaining a first scale line area according to a predetermined condition of a first scale line in the height image to be measured after image processing, obtaining a scale area according to the first scale line area, and cutting the height image to be measured according to the scale area to obtain a scale image include: In the height image to be measured after image processing, a plurality of first short-line areas are obtained according to the first scale line shape characteristic conditions, and a plurality of first scale line areas are obtained according to the first scale line angle conditions in the first short-line areas, and the inclination of each first scale line area is calculated, and the inclination average is calculated according to the inclinations of all the first scale line areas, and the inclination of the height image to be measured is corrected by using the inclination average as the inclination of the height image to be measured to obtain a corrected height image to be measured; A coordinate system is established according to the first scale line area, the X-axis coordinate values on the left and right sides of the first scale line area are calculated, and 20 pixels are added to the X-axis coordinate values on the left and right sides as a clipping area to clip the corrected height image to be measured, so as to obtain a scale image.
9. An electronic device, characterized in that: include: at least one processor, and a memory communicatively coupled to at least one of the processors; At least one of the processors is used to read the program in the memory to execute the method as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Apparatus for semi-automatically measuring object size based on digital image processing
CN109029203A
Automatic reading method and automatic reader for analog meter
JP2004133560A