Crop height measuring and calculating method, device and medium
By setting up cameras and markers in farmland to automatically calculate crop heights, it solves the problem of increased costs caused by manual judgment in traditional methods, realizes automated measurement of crop heights, and supports agricultural automation and accurate prediction of growth rates.
Patent Information
- Application Number
- CN202410665141.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-08-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional methods require manual observation or photography to judge the growth status of crops, which increases labor costs and makes it difficult to realize automated management and control of crops.
By setting up a camera in the farmland, adjusting its shooting range to include the highest point of the ground and crops, setting multiple markers to establish a conversion relationship between actual coordinates and image coordinates, performing edge detection and noise filtering, and automatically calculating crop height.
It realizes automatic collection and judgment of crop height, saves labor costs, supports agricultural automation, provides accurate growth rate prediction and planting optimization suggestions, and improves production efficiency.
Smart Images

Figure CN118570278A
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart agriculture, and specifically to a method, device and medium for measuring the height of crops. Background Art
[0002] With the advancement of science and technology, more and more intelligent means are used in agricultural life, thus gradually forming smart agriculture and helping farmers achieve scientific agricultural planting.
[0003] When judging the growth status of some crops, it is necessary to combine the height of the crops for judgment. In traditional solutions, people usually need to go to the fields to observe the height of the crops, or take pictures of the crops and then hand them over to manual judgment, which not only increases labor costs, but also makes it difficult to achieve automated crop management and control processes. Summary of the invention
[0004] In order to solve the above problems, this application proposes a method for measuring the height of crops, including:
[0005] Determine the cameras that have been set up in the farmland, and adjust the shooting range of the cameras so that the shooting range at least includes the ground and the highest point of the crops;
[0006] Determining a plurality of markers pre-set in the farmland, wherein the plurality of markers are located on the same side as the photographing plane of the crops and the plurality of markers are not collinear;
[0007] By means of the marker, a conversion relationship between actual coordinates and image coordinates is established, wherein the image coordinates correspond to the image captured by the camera;
[0008] Acquiring an actual frame image of the crop through the camera;
[0009] Performing edge detection based on the actual frame image to obtain the top edge position of the crop, and performing noise filtering on the top edge position to obtain a top line segment;
[0010] Based on the conversion relationship, the first image coordinates corresponding to the top line segment are converted to obtain the corresponding first actual coordinates, and the corresponding crop height is obtained according to the first actual coordinates of the top line segment.
[0011] On the other hand, the present application also proposes a crop height measurement device, comprising:
[0012] at least one processor; and,
[0013] a memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: the crop height measurement method described in the above example.
[0015] On the other hand, the present application also proposes a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as: the crop height measurement method described in the above example.
[0016] The crop height measurement method proposed in this application can bring the following beneficial effects:
[0017] It can automatically collect images of crops and automatically determine the height of crops, saving labor costs and facilitating the realization of agricultural automation. It provides an accurate basis for predicting the growth rate of agricultural operations, and provides precise data support for optimizing planting methods and determining harvesting time, so as to achieve the goal of increasing production and income.
[0018] By dynamically monitoring the height of crops, as the amount of monitoring data increases, a curve chart of the crop growth rate can be displayed, so that the reasons for the growth rate can be analyzed by combining weather and planting methods to improve planting methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 This is a flow chart of a method for calculating the height of crops in an embodiment of the present application;
[0021] Figure 2 This is a schematic diagram of the crop shooting surface in the embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of a crop height measuring device in an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0024] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0025] like Figure 1 As shown, the embodiment of the present application provides a method for measuring the height of crops, comprising:
[0026] S101: Determine a camera that has been set up in a farmland, and adjust the shooting range of the camera so that the shooting range at least includes the ground and the highest point of the crops.
[0027] A camera is set up on one side of the farmland to keep the camera's captured image fixed and include the height variation range between the highest peak and the bottom of the crop growth. Different crops have different highest points, so the camera parameters can be set based on actual conditions.
[0028] S102: Determine a plurality of markers pre-set in the farmland, wherein the plurality of markers are located on the same side as the photographing plane of the crops and the plurality of markers are not collinear.
[0029] The part of a crop that is photographed on one side can be considered as a plane, which is called a side. At this time, a marker point is placed close to the side of the crop, such as Figure 2 As shown, at least 4 non-collinear points can be placed, namely P1 to P4, which belong to the same plane.
[0030] S103: Establishing a conversion relationship between actual coordinates and image coordinates through the marker, wherein the image coordinates correspond to the image captured by the camera.
[0031] Since the marker has corresponding image coordinates in the captured image and also has corresponding actual coordinates in the actual space (mainly referring to the horizontal and vertical coordinates of the side where it is located, and does not include depth coordinates), the conversion relationship can be confirmed based on the marker.
[0032] Specifically, the image captured by the camera is obtained. Figure 2 As shown, the P plane is the side corresponding to the captured image, and the Q plane is the ground. At this time, in the captured image, the intersection line between the captured surface of the crop and the ground is used as the reference line for height measurement, that is, the OX line is used as the reference line, which is also the horizontal axis of the rectangular coordinate system.
[0033] At this time, a point is selected on the baseline as the origin to establish a rectangular coordinate system corresponding to the shooting surface. The origin is usually set on one side of all reference objects to ensure that the coordinates of the reference objects have the same positive and negative values in subsequent calculations, which is convenient for calculation.
[0034] At this time, determine the second image coordinates of the marker in the rectangular coordinate system, and determine the second actual coordinates of the marker in the actual space. In order to facilitate the description of the coordinates of the top line segment, the coordinates of the marker are again referred to as the second image coordinates and the second actual coordinates. The second image coordinates can be obtained by shooting an image, and the second actual coordinates can be determined based on the setting and measurement in the actual space. The second actual coordinates are two-dimensional coordinates, including the horizontal coordinates and the vertical coordinates of the side, and do not include the depth coordinates. The conversion relationship between the actual coordinates and the image coordinates can be established based on the second image coordinates and the second actual coordinates.
[0035] Furthermore, based on the formula Establish a transformation matrix between actual coordinates and image coordinates; where, is a 3*3 transformation matrix, H 11 ~H 33 Respectively represent the parameters at the corresponding positions, x i v represents the actual horizontal coordinate of the i-th marker, y i ′ represents the actual ordinate of the i-th marker, x i Represents the image horizontal coordinate of the i-th marker, y i Represents the image ordinate of the i-th marker.
[0036] The transformation matrix can be used to represent the transformation relationship. After obtaining the image coordinates of one party, The actual coordinates can be obtained by multiplying it with the transformation matrix.
[0037] At this time, after simplification, the formula as well as shown.
[0038] S104: Acquire an actual frame image of the crop through the camera.
[0039] Generally speaking, crops can be continuously photographed by a camera, and images can be captured therefrom as actual frame images.
[0040] S105: Perform edge detection based on the actual frame image to obtain the top edge position of the crop, and perform noise filtering on the top edge position to obtain a top line segment.
[0041] In the actual frame image, the crop has obvious edge features on the plane, and it can be considered that the crop is on the same plane as the top and bottom, so the image coordinates of the top and bottom of the crop in the image are obtained through edge detection. Among them, the image coordinates of the bottom are on the baseline, and its height is 0, so only the image coordinates of the top need to be considered.
[0042] Specifically, the actual frame image is blurred by using a median filter through a filter, thereby reducing the amount of data processing. At this time, the actual frame image after blurring is edge detected by a canny edge detection operator, and the top edge line corresponding to the crop is extracted as the top edge position.
[0043] At this time, there may be some noise in the top edge line, for example, some small edge lines are not conducive to calculating the height, so the top edge line corresponding to the top edge position can be pre-operated to filter out the small line segments whose length is less than the preset length; wherein the pre-operation includes: at least one of scaling, taking absolute value, and pixel format conversion. Scaling can adjust the size of the image to the required size, taking absolute value can convert the values of all pixels in the image to positive numbers, and pixel format conversion can be converted to unsigned 8-bit numbers to limit the pixel value to the range of 0 to 255, thereby saving memory.
[0044] Based on the characteristics of the top edge line in the Hough space, the required candidate line segments are detected by probabilistic Hough transform (which can be used to detect straight line shapes).
[0045] The top line of the crop is in the extracted candidate line segments (which are straight line segments), which are also mixed with interference line segments, and filtering is required to obtain the top of the crop. Generally speaking, it is believed that the top edge line of the crop should be horizontal when the growth rate is consistent. Therefore, based on the conversion relationship, the first image coordinates corresponding to the candidate line segment are converted to obtain the corresponding first actual coordinates. If the slope corresponding to the first actual coordinate is less than the preset threshold (for example, 0.1), it is considered that the actual coordinates corresponding to the candidate line segment are close to horizontal and meet the requirements, and it is used as the top line segment corresponding to the top edge position.
[0046] S106: Based on the conversion relationship, convert the first image coordinates corresponding to the top line segment to obtain the corresponding first actual coordinates, and obtain the corresponding crop height according to the first actual coordinates of the top line segment.
[0047] When the top line segment is obtained, if the slope has not been filtered, the coordinate conversion can be performed to obtain the first actual coordinate. If the slope has been filtered, the first actual coordinate has been obtained and there is no need to repeat the calculation.
[0048] And because the vertical coordinate in the first actual coordinate of the bottom is usually 0, it is only necessary to determine the first actual coordinate of the top line segment to serve as the height value of the crop.
[0049] Furthermore, when the top line segments are determined by probabilistic Hough transform, multiple top line segments corresponding to the top edge positions are usually obtained. At this time, among the multiple top line segments, the top line segments corresponding to the maximum and minimum values of the vertical coordinates are removed (referring to the line segment heights with the largest and smallest average values), and among the remaining top line segments, the average value of the vertical coordinates in the first actual coordinate is used as the corresponding crop height.
[0050] It can automatically collect images of crops and automatically determine the height of crops, saving labor costs and facilitating the realization of agricultural automation. It provides an accurate basis for predicting the growth rate of agricultural operations, and provides precise data support for optimizing planting methods and determining harvesting time, so as to achieve the goal of increasing production and income.
[0051] By dynamically monitoring the height of crops, as the amount of monitoring data increases, a curve chart of the crop growth rate can be displayed, so that the reasons for the growth rate can be analyzed by combining weather and planting methods to improve planting methods.
[0052] In one embodiment, since the height from the vertex to the ground will change when there is a breeze, multiple actual frame images corresponding to the crops within a preset time length are obtained. After the corresponding crop height is obtained for each actual frame image, the highest crop height is considered to be the actual height when there is no wind, which is used as the final height of the crop.
[0053] In one embodiment, on the time axis, due to measurement and calculation errors, the actual height of the measured crops has slight changes. In order to eliminate the noise caused by the errors, the crop height is smoothed through a low-pass filter so that multiple height data obtained in different time periods during the growth of the crops form a smooth curve.
[0054] like Figure 3 As shown, the embodiment of the present application also provides a crop height measurement device, including:
[0055] at least one processor; and,
[0056] a memory communicatively connected to the at least one processor; wherein,
[0057] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: perform the crop height measurement method described in any of the above embodiments.
[0058] An embodiment of the present application further provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as the crop height measurement method described in any of the above embodiments.
[0059] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0060] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0061] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0062] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0063] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0064] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0065] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0066] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0067] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0068] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0069] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for measuring the height of crops, characterized in that: include: Determine the cameras that have been set up in the farmland, and adjust the shooting range of the cameras so that the shooting range at least includes the ground and the highest point of the crops; Determining a plurality of markers pre-set in the farmland, wherein the plurality of markers are located on the same side as the photographing plane of the crops and the plurality of markers are not collinear; By means of the marker, a conversion relationship between actual coordinates and image coordinates is established, wherein the image coordinates correspond to the image captured by the camera; Acquiring an actual frame image of the crop through the camera; Performing edge detection based on the actual frame image to obtain the top edge position of the crop, and performing noise filtering on the top edge position to obtain a top line segment; Based on the conversion relationship, the first image coordinates corresponding to the top line segment are converted to obtain the corresponding first actual coordinates, and the corresponding crop height is obtained according to the first actual coordinates of the top line segment.
2. The method according to claim 1, characterized in that By using the marker, a conversion relationship between the actual coordinates and the image coordinates is established, specifically including: Acquire an image captured by the camera; In the captured image, the intersection line between the captured surface of the crop and the ground is used as a reference line for height measurement; Select a point on the reference line as the origin to establish a rectangular coordinate system corresponding to the shooting surface; Determine a second image coordinate of the marker in the rectangular coordinate system, and determine a second actual coordinate of the marker in the actual space; A conversion relationship between actual coordinates and image coordinates is established according to the second image coordinates and the second actual coordinates.
3. The method according to claim 2, characterized in that Establishing a conversion relationship between the actual coordinate and the image coordinate according to the second image coordinate and the second actual coordinate specifically includes: Based on the formula Establish a transformation matrix between actual coordinates and image coordinates; where H is a 3*3 transformation matrix, x′ i represents the actual horizontal coordinate of the i-th marker, y′ i represents the actual ordinate of the i-th marker, x i Represents the image horizontal coordinate of the i-th marker, y i Represents the image ordinate of the i-th marker.
4. The method according to claim 1, characterized in that: Performing edge detection based on the actual frame image to obtain the top edge position of the crop specifically includes: Through a filter, the actual frame image is blurred by using a median filter; The canny edge detection operator is used to perform edge detection on the actual frame image after blurring, and the top edge line corresponding to the crop is extracted as the top edge position.
5. The method according to claim 1, characterized in that Noise filtering is performed on the top edge position to obtain a top line segment, specifically including: After pre-operation is performed on the top edge line corresponding to the top edge position, thin line segments whose length is less than a preset length are filtered out; wherein the pre-operation includes: at least one of scaling, taking absolute value, and pixel format conversion; Based on the characteristics of the top edge line in the Hough space, the required candidate line segments are obtained by probabilistic Hough transform detection; Based on the conversion relationship, the first image coordinates corresponding to the candidate line segment are converted to obtain the first actual coordinates corresponding thereto; If the slope corresponding to the first actual coordinate is less than a preset threshold, the candidate line segment is considered to meet the requirements and is used as the top line segment corresponding to the top edge position.
6. The method according to claim 5, characterized in that Obtaining the corresponding crop height according to the first actual coordinate of the top line segment specifically includes: Determine a plurality of top line segments corresponding to the top edge position; Among the multiple top line segments, the top line segments corresponding to the maximum and minimum values of the ordinates are removed, and among the remaining top line segments, the average value of the ordinates in the first actual coordinates is used as the corresponding crop height.
7. The method according to claim 1, characterized in that Acquiring the actual frame image of the crop through the camera specifically includes: Acquire a plurality of actual frame images corresponding to the crop within a preset time period; For each actual frame image, after the corresponding crop height is obtained, the highest crop height is used as the final height of the crop.
8. The method according to claim 1, characterized in that: The method further comprises: The crop height is subjected to data smoothing processing by means of a low-pass filter.
9. A crop height measuring device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: the crop height measurement method as described in any one of claims 1 to 8.
10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured as: the crop height measurement method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Crop plant height measurement method based on monocular depth estimation
CN116051537A
Crop plant height telemetering method and system based on machine vision
CN117128874A
