Large-leaf plant length measuring method
Through computer vision methods, large-leaf plants are image processing, and the central curve is extracted and fitted, which solves the problem of low efficiency and large errors caused by straightening measurements in the prior art, and achieves high-precision and rapid measurement.
Patent Information
- Application Number
- CN202510447080.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-07-29
AI Technical Summary
In the prior art, the measurement of the length of large-leaf plants requires straightening and measurement, resulting in low efficiency and large errors, especially inaccurate measurements for curled plants.
Through computer vision methods, the camera is fixed to the large-leaf plants and calibrated, and is debackgrounded, grayscaled and binarized. The outermost contour is extracted, the center curve is sliced and fitted, and the actual length is calculated based on the pixel length and physical size.
It enables accurate measurement of the length of large-leaf plants without straightening, with small errors, fast speed and high efficiency.
Smart Images

Figure CN120388064A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to a method for measuring the length of large-leaf plants, and more particularly to a method for calculating the length of large-leaf plants through computer vision. Background Art
[0002] The length of a large-leaf plant refers to the linear measurement from the base to the tip of the large-leaf plant, mainly the practical length measurement along the main vein from the petiole end, with centimeters as the measurement unit.
[0003] Regarding the problem that manual stretching of large-leaf plants to measure length is labor-intensive and inefficient, using mechanical automatic stretching is likely to damage large-leaf plants, and the measurement efficiency will still be reduced due to the stretching process. Therefore, it is necessary to improve the measurement method and computer vision algorithm to directly measure the length of curled large-leaf plants through the collected images without straightening.
[0004] In the current technology, when evaluating the grade of large-leaf plants, the length of large-leaf plants is an important indicator that can reflect the quality of large-leaf plants. Currently, whether manually or automatically measuring the length of large-leaf plants, the large-leaf plants need to be straightened to measure. Just because large-leaf plants have obvious curling after baking or drying, there are various current measurement methods for the length of straightened large-leaf plants using computer vision. For example, the method of circumscribing an ellipse, where the major axis of the ellipse is used as the pixel length of the large-leaf plant; the method of circumscribing a rectangle, where the length of the rectangle is used as the pixel length of the large-leaf plant; and the method of extracting the central axis of the large-leaf plant using a skeleton extraction and thinning algorithm as the pixel length of the large-leaf plant.
[0005] These methods first measure the pixel length of the large-leaf plant and then multiply it by an empirical value as the actual length of the large-leaf plant. At the same time, this method of measuring length is an approximation of measuring the length of straightened large-leaf plants, with a large error, and the error for measuring the length of curled large-leaf plants will be even greater. Moreover, some methods have a long operation time. Summary of the Invention
[0006] To solve one of the above technical problems, the present disclosure provides a method for measuring the length of large-leaf plants.
[0007] According to one aspect of the present disclosure, there is provided a method for measuring the length of large-leaf plants, which includes:
[0008] Fix the distance from the camera to the large-leaf plant, calibrate the camera, and obtain a picture of the large-leaf plant through the camera;
[0009] Remove the background from the picture of the large-leaf plant;
[0010] Gray-scale and then binaryize the picture of the large-leaf plant after background removal;
[0011] Extract the outermost contour of the large-leaf plant, where the outermost contour is the set of pixel points on the outermost circle of the large-leaf plant;
[0012] Slice the large-leaf plant image after background removal. The slicing is to select a rectangular frame according to the outermost contour for slicing, and take the centroid point of the slice as the central curve point of the large-leaf plant;
[0013] Based on all the central curve points of the large-leaf plant, fit the large-leaf plant curve by the least squares method, and calculate the pixel length of the large-leaf plant curve by the integral method as the pixel length of the large-leaf plant; and
[0014] Calculate the actual length of the large-leaf plant according to the pixel length of the large-leaf plant and the physical sizes of a single pixel in the U-axis and V-axis directions.
[0015] According to the large-leaf plant length measurement method of at least one embodiment of the present disclosure, when acquiring the image of the large-leaf plant, keep the optical axis of the camera perpendicular or substantially perpendicular to the large-leaf plant plane.
[0016] According to the large-leaf plant length measurement method of at least one embodiment of the present disclosure, calibrate the camera before shooting the large-leaf plant. Among them, camera calibration includes calibrating the internal and external parameters and distortion coefficients of the camera, and performing image correction. In some embodiments, the Zhang's calibration method is used for the calibration.
[0017] According to the large-leaf plant length measurement method of at least one embodiment of the present disclosure, background removal of the large-leaf plant image includes:
[0018] In the large-leaf plant image, keep the pixel values of the pixel points occupied by the large-leaf plant unchanged, and set the pixel values of the pixel points other than the pixel points occupied by the large-leaf plant to 0.
[0019] According to the large-leaf plant length measurement method of at least one embodiment of the present disclosure, after grayscale conversion and binarization of the background-removed large-leaf plant image, it includes:
[0020] Draw the histogram of the large-leaf plant image. There are two peaks on the histogram. Select the gray value of the trough between these two peaks as the threshold, and perform binarization on the background-removed large-leaf plant image.
[0021] According to the large-leaf plant length measurement method of at least one embodiment of the present disclosure, slicing the background-removed large-leaf plant image includes:
[0022] When slicing a large-leaf plant, establish a two-dimensional pixel coordinate system, calculate the deflection angle of the large-leaf plant, determine whether to slice along the U-axis or the V-axis of the pixel coordinate system according to the deflection angle of the large-leaf plant, set the slicing step size, and perform sequential slicing along the positive direction of the determined U-axis or V-axis of the pixel coordinate system. After slicing, select the centroid point of each slice as the center curve point of the large-leaf plant.
[0023] Further, establishing a two-dimensional pixel coordinate system, calculating the deflection angle of the large-leaf plant, and determining whether to slice along the U-axis or the V-axis of the pixel coordinate system according to the deflection angle of the large-leaf plant includes:
[0024] Perform adaptive rectangular box fitting on the large-leaf plant. One of the long sides of the fitted rectangular box is used as the angle calculation axis, the U-axis is used as the other angle calculation axis, and the angle formed by the long side and the positive direction of the U-axis is used as the deflection angle θ of the large-leaf plant. If 45° ≤ θ ≤ 135°, slice along the V-axis direction of the pixel coordinate system; if 0° ≤ θ < 45° or 135° < θ ≤ 180°, slice along the U-axis direction of the pixel coordinate system.
[0025] Even further, the adaptive rectangular box fitting includes:
[0026] Establish a two-dimensional coordinate system, i.e., a pixel coordinate system, at the uppermost left corner of the large-leaf plant picture after background removal. The positive direction of the U-axis is horizontally to the right, and the positive direction of the V-axis is vertically downward;
[0027] Calculate the geometric center of the set of pixel points on the outermost circle of the large-leaf plant;
[0028] Translate all the pixel points in the set of pixel points to the coordinate system with the geometric center as the origin to obtain the coordinates of each translated pixel point;
[0029] Select an initial rectangular box, where the initial rectangular box is the smallest rectangular box in which the entire set of translated pixel points is located;
[0030] Iteratively optimize the position and size of the rectangular box until the position and size of the rectangular box converge or reach the maximum number of iterations, and use it as the final rectangular box, and obtain the included angle between the long side of the rectangular box and the positive direction of the U-axis, that is, the deflection angle of the large-leaf plant.
[0031] According to the large-leaf plant length measurement method according to at least one embodiment of the present disclosure, calculate the actual length of the large-leaf plant according to the pixel length of the large-leaf plant and the physical sizes of a single pixel in the U-axis and V-axis directions, including:
[0032]
[0033] Wherein, dx and dy are the physical sizes of a single pixel in the U-axis and V-axis directions.
[0034] Advantageous effects: The method for measuring the length of large-leaf plants according to the present disclosure can solve the technical problem in the prior art that the large-leaf plants must be straightened to measure their lengths, and it is impossible to directly measure the lengths of large-leaf plants with certain curls to obtain more accurate lengths; it has the advantages of small error, high precision, fast speed, and high efficiency. Description of the Drawings
[0035] The drawings illustrate exemplary embodiments of the present disclosure and, together with their description, are used to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are included in this specification and form a part of this specification.
[0036] Figure 1 is a flowchart of the method for measuring the length of large-leaf plants according to an embodiment of the present disclosure.
[0037] Figure 2 is a diagram of extracting the outline of the large-leaf plant picture of the method for measuring the length of large-leaf plants according to an embodiment of the present disclosure.
[0038] Figure 3 is a diagram of fitting the central axis of the large-leaf plant of the method for measuring the length of large-leaf plants according to an embodiment of the present disclosure.
[0039] Figure 4 is a schematic diagram of the slicing principle of the method for measuring the length of large-leaf plants according to an embodiment of the present disclosure. Detailed Embodiments
[0040] The present disclosure will be further described in detail below in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the relevant content and do not limit the present disclosure. Additionally, it should be noted that only parts related to the present disclosure are shown in the drawings for the convenience of description.
[0041] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The technical solutions of the present disclosure will be described in detail below with reference to the drawings and embodiments.
[0042] Unless otherwise specified, the exemplary embodiments / Examples shown will be understood to provide exemplary features of various details of some ways that can implement the technical concept of the present disclosure in practice. Therefore, unless otherwise specified, without departing from the technical concept of the present disclosure, the features of various embodiments / Examples can be additionally combined, separated, interchanged, and / or rearranged.
[0043] In the drawings, hatching and / or shading are generally used to make the boundaries between adjacent components clear. Thus, unless otherwise stated, the presence or absence of hatching or shading does not convey or imply any preference or requirement for the specific material, material properties, dimensions, proportions, commonality between the components shown, and / or any other characteristics, attributes, properties, etc. of the components. In addition, in the drawings, for clarity and / or descriptive purposes, the dimensions and relative dimensions of components may be exaggerated. When an exemplary embodiment can be implemented differently, the specific process order may be performed in a different order than that described. For example, two consecutively described processes may be performed substantially simultaneously or in an order opposite to that described. In addition, the same reference numerals denote the same components.
[0044] When a component is referred to as being "on" or "above" another component, "connected to" or "coupled to" another component, the component can be directly on the other component, directly connected to or directly coupled to the other component, or there may be intervening components. However, when a component is referred to as being "directly on" another component, "directly connected to" or "directly coupled to" another component, there are no intervening components. For this reason, the term "connected" can refer to a physical connection, an electrical connection, etc., and can have or not have intervening components.
[0045] For descriptive purposes, the present disclosure may use spatial relative terms such as "under", "below", "beneath", "down", "above", "on", "over", "upper", and "side (e.g., as in "side wall")" to describe the relationship of one component to another (other) component as shown in the drawings. In addition to the orientation depicted in the drawings, the spatial relative terms are also intended to encompass different orientations of the device during use, operation, and / or manufacturing. For example, if the device in the drawings is flipped, a component described as being "under" or "beneath" another component or feature will then be positioned "above" the other component or feature. Thus, the exemplary term "under" can encompass both the "above" and "below" orientations. In addition, the device may be otherwise positioned (e.g., rotated 90 degrees or at other orientations), and accordingly, the spatial relative descriptors used herein are to be interpreted.
[0046] The terms used herein are for the purpose of describing particular embodiments and are not intended to be limiting. As used herein, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are also intended to include the plural forms. In addition, when the terms "comprise" and / or "include" and their variants are used in this specification, it is stated that there are the stated features, integers, steps, operations, components, assemblies and / or groups thereof, but does not preclude the presence or addition of one or more other features, integers, steps, operations, components, assemblies and / or groups thereof. It should also be noted that, as used herein, the terms "substantially", "about" and other similar terms are used as approximate terms and not as terms of degree, so they are used to explain the inherent deviations of measured values, calculated values and / or provided values that would be recognized by those of ordinary skill in the art.
[0047] Figure 1 is a flowchart of a method for measuring the length of large-leaf plants according to an embodiment of the present disclosure.
[0048] As Figure 1 shown, the method for measuring the length of large-leaf plants of the present disclosure includes: fixing the distance from the camera to the large-leaf plants and calibrating the camera, and obtaining a picture of the large-leaf plants through the camera (abbreviation "obtaining an image and preprocessing"); performing background removal on the picture of the large-leaf plants; graying and then binarizing the picture of the large-leaf plants after background removal; extracting the outermost contour of the large-leaf plants, where the outermost contour is a set of pixel points on the outermost circle of the large-leaf plants; performing slicing on the picture of the large-leaf plants after background removal, where the slice is to select a rectangular frame according to the outermost contour, and taking the centroid point of the slice as the center curve point of the large-leaf plants; fitting a curve by fitting the center curve points of the large-leaf plants using the least squares method, and calculating the pixel length of the curve of the large-leaf plants as the pixel length of the large-leaf plants using the integral method; and converting the pixel length of the large-leaf plants and the physical dimensions of a single pixel in the U-axis and V-axis directions into the actual length of the large-leaf plants.
[0049] Thus, the method for measuring the length of large-leaf plants of the present disclosure can solve the technical problem in the prior art that the large-leaf plants must be straightened to measure the length of the large-leaf plants, and it is impossible to directly measure and obtain a more accurate length for large-leaf plants with a certain degree of curl; it has the advantages of small error, high precision, fast speed, high efficiency, etc.
[0050] The above steps will be described in detail below in conjunction with specific implementation forms.
[0051] 1. Obtaining an image and preprocessing includes:
[0052] When photographing a large-leaf plant image with a camera, a white light source can be used to provide ambient light, that is, the image of the large-leaf plant is collected under a standard white light source; in the present disclosure, the camera can obtain an image of a large-leaf plant by taking a photo, or can shoot a video and select a frame from the video as the image of the large-leaf plant. Among them, the camera is a three-channel RGB camera.
[0053] Before obtaining the large-leaf plant image, place large-leaf plants of different grades on a black background (the black background can be a black curtain or a black floor), set the distance between the white light source and the large-leaf plant to be measured to 20-60 cm, and the design position of the white light source is based on evenly distributing the light generated by the white light source on the large-leaf plant, so as to ensure that the brightness distribution of the obtained large-leaf plant image is uniform and facilitate the subsequent processing of the large-leaf plant image. When photographing the large-leaf plant image, it is necessary to ensure that the camera captures a complete image of the large-leaf plant to be measured.
[0054] Before photographing the large-leaf plant, fix the distance from the camera to the leaves of the large-leaf plant and calibrate the camera. Camera calibration refers to the process of determining the internal parameters and external parameters of the camera, so as to map the pixel coordinates in the camera image to the world coordinate system. Internal parameters (Intrinsic Parameters): The internal parameters of the camera include focal length, principal point position, distortion, etc. The focal length determines the zoom ratio of the camera, the principal point position represents the offset of the imaging plane relative to the center position of the image sensor, and the distortion is the shape distortion generated when light passes through the lens. External parameters (Extrinsic Parameters): The external parameters of the camera include the position and orientation of the camera. The position and attitude of the camera in the three-dimensional world coordinate system can be solved through the corresponding relationship between the position and attitude of the reference object and its projection in the image. In this embodiment, the calibration algorithm uses Zhang's calibration method.
[0055] Principle of Zhang's calibration method:
[0056] 1. Conversion from world coordinate system to camera coordinate system:
[0057]
[0058] Among them: x c 、y c 、z c are the coordinates of the point on the X-axis, Y-axis, and Z-axis in the camera coordinate system, x w 、y w 、z w are the coordinates of the point on the X-axis, Y-axis, and Z-axis in the world coordinate system, R is the rotation matrix, and t is the translation vector.
[0059] 2. Conversion from camera coordinate system to image coordinate system:
[0060]
[0061] Wherein: 、 are the X-axis and Y-axis coordinates of the point in the image coordinate system, which are two-dimensional coordinates and have no Z-axis component;
[0062] The scale factor S = Z c , the distance between the imaging plane and the optical center is the focal length f. It should be noted here that the transformation from the camera coordinate system to the image coordinate system will introduce a scale factor, and this scale factor is related to Z c is related.
[0063] 3. Conversion from the image coordinate system to the pixel coordinate system:
[0064]
[0065] Wherein: u and v are the coordinates of the point on the U-axis and V-axis in the pixel coordinate system; dx and dy are the physical sizes of a single pixel in the U-axis and V-axis directions (such as l0.005mm / pixel); 、 are the X-axis and Y-axis coordinates of the point in the image coordinate system; u0 and v0 are the principal point offsets (the coordinates of the image origin on the U-axis and V-axis in the pixel coordinate system).
[0066] 4. Reprojection error optimization
[0067] Using a calibration board, by minimizing the reprojection error, the internal and external parameters of the camera can be optimized so that the actually observed two-dimensional corner points are as close as possible to the reprojected three-dimensional points.
[0068] 5. Three-dimensional distance calculation
[0069] The actual distance of the length pixels of the large-leaf plant is calculated through the distance between the corresponding three-dimensional points of two adjacent pixels.
[0070] Substituting the internal and external parameters, for simplicity of calculation, assuming that the leaf is on a plane, the simplified calculation formula is obtained as:
[0071]
[0072] Actual length = length of the large-leaf plant (i.e., the number of pixels) * physical size corresponding to each pixel;
[0073] When obtaining pictures of large-leaf plants, keep the optical axis of the camera perpendicular or approximately perpendicular to the plane of the large-leaf plant to obtain qualified pictures of large-leaf plants. Among them, the optical axis of the camera is the axis formed by the light passing through the center of the light passing port; the plane of the large-leaf plant is the plane formed by the large-leaf plant spread out on a black background.
[0074] 2. Background removal of large-leaf plant images includes:
[0075] In the large-leaf plant image, keep the pixel values of the pixel points occupied by the large-leaf plant unchanged, and set the pixel values of other pixel points except those occupied by the large-leaf plant to 0.
[0076] More specifically, in the specific background removal steps, use the opencv framework to perform image sharpening, image grayscaling, and then perform image threshold segmentation to obtain at least one closed region; calculate the area of each closed region, and take the closed region with the largest area as the closed region where the large-leaf plant is located, and set the pixel points of the closed region where the large-leaf plant is located to 0 to obtain an intermediate image.
[0077] By subtracting the original large-leaf plant image before background removal from this intermediate image, the background removal of the original large-leaf plant image is completed.
[0078] 3. Grayscaling and then binarizing the background-removed large-leaf plant image includes:
[0079] After background removal of the large-leaf plant image, perform grayscaling and then binarization on the background-removed large-leaf plant image. Specifically, draw the histogram of the large-leaf plant image. There are two peaks on the histogram. Select the gray value of the trough between these two peaks as the threshold to perform binarization on the background-removed large-leaf plant image.
[0080] 4. Extracting the outermost contour of the large-leaf plant includes:
[0081] Extract the outermost contour of the large-leaf plant through morphological operations. The outermost contour is a set of pixel points on the outermost circle of the large-leaf plant, such as ( , ), ( , ),..., ( , ), is the total number of pixel points of the outermost contour, as shown in Figure 2 .
[0082] 5. Slicing the large-leaf plant in the background-removed large-leaf plant image includes:
[0083] Establish a two-dimensional pixel coordinate system, create an adaptive rotated rectangle box fitting, and calculate the deflection angle θ of the large-leaf plant. Determine whether to slice along the U-axis or the V-axis of the pixel coordinate system according to the deflection angle θ of the large-leaf plant, set the slice step size, and perform sequential slicing along the positive direction of the U-axis or the V-axis of the pixel coordinate system. After slicing, select the centroid point of each slice as the center curve point of the large-leaf plant, as shown in Figure 3 .
[0084] 1. Adaptive Rotating Rectangle Fitting
[0085] A two - dimensional coordinate system, i.e., a pixel coordinate system, is established with the top - left corner of the de - backgrounded large - leaf plant image as the origin. The positive direction of the U - axis is horizontal to the right, and the positive direction of the V - axis is vertical downwards, as Figure 4 shown.
[0086] Perform adaptive rectangle fitting on the large - leaf plant, and calculate the geometric center ( , ) of the set of pixel points on the outermost circle of the large - leaf plant, that is, the average value of the coordinates of all pixel points on the outermost contour
[0087] Geometric center calculation formula:
[0088]
[0089]
[0090] Where: is the total number of pixel points on the outermost contour, , The U - axis and V - axis coordinates of the i - th pixel point on the outermost contour;
[0091] Translate all pixel points in the pixel point set to a coordinate system with the geometric center as the origin, and obtain the coordinates of each translated pixel point ( , );
[0092] ( , )=( − − )
[0093] Select an initial rectangle, where the initial rectangle is the smallest rectangle enclosing the entire translated pixel point set;
[0094] Length length = max( )−min( ),
[0095] Width weight = max( )−min( ),
[0096] Iteratively optimize the position and size of the rectangle:
[0097] Traverse each pixel point for the translated coordinates du i 、dv i, for each point, calculate its internal position relative to the rectangle, i.e., the coordinates (pu i , pv i ) of the point in the coordinate system of the rectangle, where:
[0098] pu i = du i * cos(θ) + dv i * sin(θ),
[0099] pv i = - du i * sin(θ) + dv i * cos(θ),
[0100] where pu i , pv i are the coordinates of pixel point i in the coordinate system of the rectangle, du i , dv i are the coordinates of pixel point i after translation; θ is the angle between the long side of the rectangle and the positive direction of the U axis; θ is the angle between the long side of the rectangle and the positive direction of the U axis, i.e., the rotation angle of the rectangle (the initial value is set to 0),
[0101] Update the position and size of the rectangle:
[0102] Calculate the minimum rectangle of the point in the coordinate system of the rectangle
[0103] ( , , , )
[0104] where , , , are the minimum and maximum U - axis and V - axis coordinates of the pixel points in the pixel point set in the coordinate system of the rectangle;
[0105] Update the center position of the rectangle to:
[0106] ( ) = , ,
[0107] Update the size of the rectangle to:
[0108] length = - , weight = - ,
[0109] where, The U-axis and V-axis coordinates of the center of the rectangular box; length and width are the length and width of the rectangular box.
[0110] Update the rotation angle of the rectangular box, and repeat the steps to iteratively optimize the position and size of the rectangular box until the position and size of the rectangular box converge or reach the maximum number of iterations, which is used as the final rectangular box, and obtain the angle θ formed by the long side of the rectangular box and the positive direction of the U-axis.
[0111] 2. Direction Adaptive Slicing
[0112] (1) Angle Judgment:
[0113] Extract the long side of the rectangular box. The angle formed by the long side and the positive direction of the U-axis is θ, and the range is from 0° to 180°. If 45° ≤ θ ≤ 135°, slice along the V-axis direction of the pixel coordinate system, and the slice step size is the difference in U-axis pixel coordinates; if 0° ≤ θ < 45° or 135° < θ ≤ 180°, slice along the U-axis direction of the pixel coordinate system, and the slice step size is the difference in V-axis pixel coordinates.
[0114] (2) Slice Parameter Setting
[0115] Set the slice step size according to the specific situation. After slicing, select the center point of each slice as the center curve point of the large-leaf plant. Here, taking the slicing along the V-axis direction as an example, the slice step size is the pixel distance between pixel points, and then in the pixel point set of the outermost contour of the large-leaf plant that has been extracted, that is, the pixel points of the outermost contour in one circle ( , ), ( , ),..., ( , ), the minimum U coordinate in the pixel point set is used as the start coordinate of the large-leaf plant slice, and the maximum U coordinate in the pixel point set is used as the end coordinate of the large-leaf plant slice.
[0116] The slice step size a = , N is the number of slices;
[0117] All the large-leaf plant contour points between the U-axis start coordinate value and the coordinate value of the U-axis start coordinate plus the slice step size value are taken as ([[]] , ), ( , ), ( , ), ( , ) as an example. Average all the U-axis coordinate values among all the contour points found in one slice. The slice centroid point ( , )
[0118] = ,
[0119] = ,
[0120] For the next iteration with the slicing step a, the outline points of the large-leaf plant are:
[0121] ( +a, ), ( +a, ),( +a, ),( +a, ):
[0122] = ,
[0123] = ,
[0124] And so on, to find the coordinates of all the central curve points of the large-leaf plant.
[0125] Use the least squares method to fit the central curve points to obtain a curve. The fitted curve can be a polynomial fit, and the highest power of the polynomial is determined by the actual situation. The highest power will affect the fitting accuracy. After obtaining the fitted curve equation, use the u, v relationship in the equation and the integral method to calculate the pixel length of the large-leaf plant curve as the pixel length of the large-leaf plant; after calculating the pixel length of the large-leaf plant, convert it to the actual length of the large-leaf plant.
[0126] In this disclosure, the large-leaf plants selected when measuring the length of large-leaf plants should be relatively complete and have few deficiencies. In actual use, according to the national grading standard for large-leaf plants, large-leaf plants can be divided into 42 grades.
[0127] In the description of this specification, the descriptions referring to terms such as "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples", etc., mean that the specific features, structures, materials, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of this application. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments / ways or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.
[0128] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" can explicitly or implicitly include at least one of such features. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically and clearly defined.
[0129] Those skilled in the art should understand that the above embodiments are only for clearly explaining the present disclosure and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications can be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A method for measuring the length of a large-leaf plant, characterized in that, Including: Fix the distance between the camera and the large-leaf plant, calibrate the camera, and obtain images of the large-leaf plant through the camera; Remove the background from the images of the large-leaf plant; Convert the background-removed images of the large-leaf plant to grayscale and then binarize them; Extract the outermost contour of the large-leaf plant, where the outermost contour is the set of pixel points on the outermost circle of the large-leaf plant; Slice the background-removed images of the large-leaf plant. The slicing is to select a rectangular frame according to the outermost contour for slicing, and take the centroid point of the slice as the central curve point of the large-leaf plant; Based on all the central curve points of the large-leaf plant, fit the curve of the large-leaf plant by the least squares method, and calculate the pixel length of the curve of the large-leaf plant by the integral method as the pixel length of the large-leaf plant; and Calculate the actual length of the large-leaf plant according to the pixel length of the large-leaf plant and the physical sizes of a single pixel in the U-axis and V-axis directions.
2. The method for measuring the length of large-leaf plants according to claim 1, characterized in that, When obtaining images of the large-leaf plant, keep the optical axis of the camera perpendicular or approximately perpendicular to the plane of the large-leaf plant.
3. The method for measuring the length of large-leaf plants according to claim 1, wherein Before shooting the large-leaf plant, calibrate the camera. Among them, camera calibration includes calibrating the internal and external parameters and distortion coefficients of the camera, and performing image correction.
4. The method for measuring the length of large-leaf plants according to claim 1, wherein, Removing the background from the images of the large-leaf plant includes: In the images of the large-leaf plant, keep the pixel values of the pixel points occupied by the large-leaf plant unchanged, and set the pixel values of the pixel points other than those occupied by the large-leaf plant to 0.
5. The method for measuring the length of large-leaf plants according to claim 1, wherein Converting the background-removed images of the large-leaf plant to grayscale and then binarizing them includes: Draw the histogram of the images of the large-leaf plant. There are two peaks on the histogram. Select the gray value of the trough between these two peaks as the threshold, and binarize the background-removed images of the large-leaf plant.
6. The method for measuring the length of large-leaf plants according to claim 1, characterized in that, Slicing the background-removed images of the large-leaf plant includes: When slicing the large-leaf plant, establish a two-dimensional pixel coordinate system, calculate the deflection angle of the large-leaf plant, determine to slice along the U-axis or V-axis of the pixel coordinate system according to the deflection angle of the large-leaf plant, set the slicing step size, and perform sequential slicing along the positive direction of the determined U-axis or V-axis of the pixel coordinate system. After slicing, select the centroid point of each slice as the central curve point of the large-leaf plant.
7. The method for measuring the length of large-leaf plants according to claim 6, characterized in that, Establishing a two-dimensional pixel coordinate system, calculating the deflection angle of the large-leaf plant, and determining to slice along the U-axis or V-axis of the pixel coordinate system according to the deflection angle of the large-leaf plant includes: Perform adaptive rectangular frame fitting on the large-leaf plant. One long side of the fitted rectangular frame is used as the angle calculation axis, the U-axis is used as the other angle calculation axis, and the angle formed by the long side and the positive direction of the U-axis is used as the deflection angle θ of the large-leaf plant. If 45° ≤ θ ≤ 135°, slice along the V-axis direction of the pixel coordinate system; if 0° ≤ θ < 45° or 135° < θ ≤ 180°, slice along the U-axis direction of the pixel coordinate system.
8. The method for measuring the length of large-leaf plants according to claim 7, characterized in that, Adaptive rectangular frame fitting includes: Establish a two-dimensional coordinate system, i.e., a pixel coordinate system, at the upper left corner of the background-removed images of the large-leaf plant. The positive direction of the U-axis is horizontal to the right, and the positive direction of the V-axis is vertical downward; Calculate the geometric center of the set of pixel points on the outermost circle of the large-leaf plant; Translate all the pixel points in the set of pixel points to the coordinate system with the geometric center as the origin to obtain the coordinates of the translated pixel points; Select the initial rectangular box, where the initial rectangular box is the smallest rectangular box where the entire set of pixel points is located after translation; Iteratively optimize the position and size of the rectangular box until the position and size of the rectangular box converge or reach the maximum number of iterations, and use it as the final rectangular box, and obtain the angle formed by the long side of the rectangular box and the positive direction of the U axis, that is, the deflection angle of the large-leaf plant.
9. The method for measuring the length of large-leaf plants according to claim 8, characterized in that, Iteratively optimizing the position and size of the rectangular box includes: Traverse the coordinates of each pixel point after translation, and calculate the internal position of each pixel point relative to the rectangular box, that is, the coordinates of the pixel point in the coordinate system of the rectangular box; pu i =du i *cos(θ)+dv i *sin(θ), pv i =-du i *sin(θ)+dv i *cos(θ), Among them, pu i and pv i are the coordinates of pixel point i in the rectangular frame coordinate system, du i and dv i are the coordinates of pixel point i after translation; θ is the angle formed by the long side of the rectangular frame and the positive direction of the U axis; Update the position and size of the rectangular box: Calculate the smallest rectangular box of the point in the coordinate system of the rectangular box ( , , , ); Among them and , , are the minimum and maximum U-axis and V-axis coordinates of the pixel points in the pixel point set under the rectangular frame coordinate system; Update the center position of the rectangular box to: ( )= , , Update the size of the rectangular box to: length= - ,weight= - , Among them, The center U-axis and V-axis coordinates of the rectangular frame; length and weight are the length and width of the rectangular frame.
10. The method for measuring the length of large-leaf plants according to claim 1, characterized in that, Calculate the actual length of the large-leaf plant according to the pixel length of the large-leaf plant and the physical size of a single pixel in the U-axis and V-axis directions, including: , Where dx and dy are the physical sizes of a single pixel in the U-axis and V-axis directions.