Tree breast diameter measurement method based on halcon binocular stereo vision
By utilizing Halcon binocular stereo vision technology and deep learning, automated, efficient, and accurate measurement of tree diameter at breast height (DBH) has been achieved, solving the problems of low efficiency and poor accuracy in traditional manual measurement. This technology is suitable for the efficient development of the plantation forestry industry.
Patent Information
- Application Number
- CN202211014079.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2042-08-23
AI Technical Summary
Traditional methods for collecting diameter at breast height (DBH) data from planted forest trees are inefficient, labor-intensive, and inaccurate, making it difficult to meet the needs for rapid, efficient, and automated measurement.
A tree diameter at breast height (DBH) measurement method based on Halcon binocular stereo vision is adopted. Through binocular camera calibration, deep learning and model training, the DBH of forest trees is automatically obtained, including image preprocessing, stereo matching, disparity map calculation and DBH statistics.
It reduces labor costs, improves measurement efficiency and accuracy, avoids measurement errors, can handle large amounts of forest tree diameter at breast height measurements, and reduces misidentification and mismeasurement.
Smart Images

Figure CN115439526B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of artificial intelligence automated dimension measurement, and in particular to a method for measuring tree diameter at breast height based on halcon binocular stereo vision. Background Art
[0002] In the process of artificial forest planting, it is very necessary to fully and timely grasp the information of tree breast diameter. The data information can directly reflect the growth rate and tree volume of the forest. It is an important forest resource inventory attribute to measure the value of a single tree, and it is also an important indicator to judge whether the forest group is growing normally.
[0003] Traditionally, the collection of tree DBH data in plantations mostly relies on manual work, mainly using callipers, calipers, diameter tape measures and other instruments for manual measurement and recording, which is extremely inefficient, labor-intensive and has poor accuracy. The use of deep learning and computer vision technology in the field of forest DBH data information collection has positive significance. It can not only meet the needs of fast, efficient, accurate and automated collection at the technical level, improve the efficiency of tree DBH measurement, but also has significant practical significance for promoting the efficient development and high-quality production of the plantation industry, further liberating labor and reducing labor costs. Summary of the invention
[0004] The technical problem to be solved by the present invention is: to overcome the shortcomings of the prior art and provide a method for measuring the tree diameter at breast height based on halcon binocular stereo vision, which can collect images of trees through a binocular camera, and automatically obtain the size of the tree diameter at breast height after image processing and deep learning, thereby reducing the workload and cost of manual labor, while improving measurement efficiency and accuracy, and avoiding losses due to measurement errors.
[0005] To achieve the above purpose, a tree diameter at breast height measurement method based on halcon binocular stereo vision is provided, including:
[0006] S1. Binocular camera calibration
[0007] The internal and external parameters of the binocular camera are calibrated by a dot-type calibration plate, and the calibration parameters are obtained based on the halcon nonlinear model handle calibration method. The image is corrected according to the calibration parameters, and the Block Matching algorithm is used for stereo matching and disparity map calculation;
[0008] S2. Deep learning and model training
[0009] (1) Preprocess the images collected by the binocular camera, including using the gen_rectangle operator to segment the left and right images, smoothing the images with smooth or mean operators, removing noise, and enhancing the images with invert_image, scale_image and other operators. Image annotation is performed to complete the construction of the deep learning image dataset.
[0010] (2) Tree target detection training is performed based on the halcon deep learning network framework, and the optimal model is obtained by adjusting parameters;
[0011] S3. Statistics of tree diameter at breast height
[0012] (1) Use the read_cam_par and read_pose operators to read the internal camera parameters of the left and right cameras and the position of the right camera relative to the left camera obtained by binocular stereo vision calibration;
[0013] (2) Use the gen_binocular_rectification_map operator to obtain the transformation matrix between the non-standard outer limit image and the standard outer limit image, that is, the mapping image. Perform image correction on the left and right camera images according to the transformation matrix;
[0014] (3) Use the read_dl_model operator to introduce the trained tree DBH detection model, and use the set_dl_model_param operator to set the corresponding parameters;
[0015] (4) Use list_files and tuple_regexp_select operators to open the camera or read the image. The image reading type can be set to various types such as bmp, gif, jpg, etc.
[0016] (5) Use the gen_dl_samples_from_images and preprocess_dl_samples operators to detect the left and right images respectively. Through the morphological processing method, obtain the boundary area below the tree diameter at breast height after threshold segmentation, select the coordinate positions of the upper left and upper right target points of the boundary, and define the difference of their horizontal coordinates as the size of the diameter at breast height;
[0017] The tree image target is detected, specifically:
[0018] The gray_features(RectangleR,V,“mean”,ValueR) operator is used to calculate the gray feature value of the specified area. Its input is a set of regions, and the features of each region are stored in a set of value arrays, so as to obtain the gray value of the read image area. According to the threshold(B,RegionB,L1,255) and threshold(H,RegionH,L2,255) operators, the gray value information is obtained. Then, the two boundary thresholds of the trunk diameter at breast height and the area below are determined: L1:=ValueR / 1.3, L2:=ValueR / 1.7. Finally, the two channels are segmented and the union is taken to obtain the target detection area.
[0019] (6) Using the open_framegrabber operator, in the loop body, the forest images are read in sequence from the image data. At the beginning, the first two frames of images are selected; each time thereafter, an image with a later time frame is retained, and a new image is read in to cover the image with an earlier time frame;
[0020] (7) Calculation of mean DBH
[0021] The tuple_mean and disp_message operators are used, and All:=[All,Mean] is defined to count the number of identifications. If the number of identifications meets the specified requirements, the mean DBH value of the trees is calculated. Otherwise, the identification is considered invalid and the DBH value is not counted.
[0022] (8) Detecting effectively identified trees. When the target tree disappears at the edge of the field of view and a valid DBH value is obtained, the corresponding tree number counting counter is incremented by 1;
[0023] (9) Use the open_file and fwrite_string operators to export statistical values into Excel tables, mainly including the tree count counter value and the corresponding tree breast diameter mean.
[0024] Preferably, the step S1 comprises the following steps:
[0025] The halcon calibration data model is used for binocular camera calibration. During the acquisition process, after the last calibration image is acquired, the direction of the acquired image is rotated, and then the next calibration image is acquired until the entire calibration image set is obtained. During the acquisition of a single calibration image, the control is kept stationary to ensure that there is no movement to avoid blur and synchronization problems.
[0026] Preferably, the step S2 comprises the following steps:
[0027] Step (1), the image enhancement is mainly to adjust the contrast and brightness, and the image annotation uses the MVTec Deep Learning Tool annotation tool, and the annotation method is mainly to annotate the rectangular frame for the area below the breast diameter;
[0028] In step (2), the model network is SqueezeNet, its corresponding operator is pretrained_dl_classifier_compact.hdl, and the main parameters adjusted are batch-size, iterations, and learning_rate.
[0029] Preferably, the step S3 comprises the following steps:
[0030] In steps (1), (2) and (3), the parameters, transformation matrix and tree diameter at breast height detection model need to be placed in a fixed position on the computer for reading;
[0031] In step (4), the image read is a color image;
[0032] In step (5), a rectangular frame of the tree diameter at breast height is obtained according to the marking method, and a detection area is obtained according to the gray value information and the two boundary threshold settings.
[0033] In step (7) of step S3 of the present invention, the number of tree recognitions is counted to prevent misidentification. The same tree may be photographed ten times. If the number of recognitions is less than six, then the image is generally not the main body of the tree.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] 1. Use binocular cameras to collect images of artificial forest trees, and use deep learning and binocular vision technology to obtain the size of the tree's diameter at breast height, which reduces manual workload, improves measurement accuracy, and avoids losses caused by measurement errors;
[0036] 2. Using the deep learning convolutional neural network model, while ensuring no loss of accuracy, it can more efficiently and quickly achieve the target detection task and obtain the target rectangular frame area;
[0037] 3. Determine the two boundary thresholds of the trunk diameter at breast height and the area below by obtaining the regional grayscale value, and finally segment the two channels and take the union, which can make the edge contour to be extracted more obvious, enhance the image distinction, and minimize the impact of other background environmental factors on the measured object;
[0038] 4. Using binocular stereo vision technology for distance measurement has no recognition rate limit compared to monocular vision, because in principle, there is no need to identify and then measure, but to directly measure the target object. Binocular stereo vision is more accurate than monocular vision and directly uses parallax to calculate distance;
[0039] 5. When measuring the DBH of tree images, it can process a large amount of data and automatically obtain statistical results. For some non-tree targets such as shrubs and obstacles, the number of recognitions is insufficient and actual statistics and DBH measurements are not performed, thus avoiding misidentification and mismeasurement.
[0040] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] By reading the detailed description of the preferred embodiment below, various other advantages and benefits will become clear to those of ordinary skill in the art. The accompanying drawings are only used for the purpose of illustrating the preferred embodiment and are not to be considered as limiting the present invention. In addition, the same reference symbols are used throughout the accompanying drawings to represent the same platform parts.
[0042] Figure 1 This is a hardware schematic diagram of a tree breast diameter measurement method based on halcon binocular stereo vision described in the present invention.
[0043] Figure 2 This is a flow chart of a tree diameter at breast height measurement method based on Halcon binocular stereo vision described in the present invention. DETAILED DESCRIPTION
[0044] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0045] See also Figure 1This embodiment provides a schematic diagram of a tree diameter measurement method based on halcon binocular stereo vision, including a forest image acquisition platform, a forest image processing platform and a forest diameter measurement display platform. The forest image acquisition platform is responsible for image acquisition and is connected to an industrial computer; the forest image processing platform is embedded with halcon processing software to process the collected image data to solve the diameter data of the collected image; the forest diameter measurement display platform is mainly responsible for real-time monitoring of image acquisition and image processing to perform human-computer interaction and display results, which mainly includes a display screen and is connected to an industrial computer.
[0046] The forest image acquisition platform provided in this embodiment can realize the combination of infrared sensors and binocular cameras for real-time image acquisition through the development board program setting, set the acquisition time according to the interval between trees, and collect a specified number of images for each tree, and then automatically create a folder on the industrial computer through halcon, input the collected forest images, and name and distinguish them. Among them, the infrared sensor 1 transmits instructions to the industrial computer after being triggered by the perception of the trees, and the binocular camera takes images at this time. When the infrared sensor 2 is sensed and triggered, the binocular camera ends shooting. Specifically, when the infrared sensor 1 senses that the measured target passes, the signal is transmitted to the industrial computer through the transmission line, and the binocular camera is started after being processed by the industrial computer. When the binocular camera starts to take pictures and collect photos and starts to store them by number, the acquisition frequency and time interval are controlled by the touch display screen and the industrial computer. After the infrared sensor 2 is sensed and triggered, it transmits a signal to the industrial computer, and the industrial computer controls the binocular camera to end collecting photos after processing.
[0047] The core algorithm of the industrial computer in the forest image processing platform given in this embodiment is the SqueezeNet convolutional neural network model based on the halcon target detection framework, which is used to obtain the target detection and recognition rectangular frame, thereby obtaining the tree trunk position area below the tree diameter at breast height, and combining the gray_features and threshold operators to obtain the standard tree diameter at breast height and the boundary contour of the area below.
[0048] The display screen in the tree diameter at breast height measurement display platform provided in this embodiment is mainly used for result display and image processing for real-time monitoring.
[0049] See also Figure 2 The implementation of tree breast diameter measurement and statistics mainly consists of four parts: binocular camera calibration, deep learning and model training, tree image recognition and collection, and tree breast diameter measurement and statistics.
[0050] The specific implementation steps are:
[0051] 1. Binocular camera calibration;
[0052] The internal and external parameters of the binocular camera are calibrated by a dot-shaped calibration plate, and the calibration parameters are obtained based on the halcon nonlinear model handle calibration method. The image is corrected according to the calibration parameters to obtain the corrected image, and the BlockMatching algorithm is used to perform stereo matching and disparity map calculation on the corrected image.
[0053] In a complete camera imaging model, it is composed of a camera and a lens. In the present invention, a combination of an array camera and an ordinary lens is used. To complete the measurement of the breast diameter of the tree image, it is necessary to determine the relationship between the three-dimensional geometric position of the breast diameter of the tree and its corresponding position in the captured image, mainly the mutual conversion between the world coordinate system and the camera coordinate system, the camera coordinate system and the imaging plane coordinate system, and the imaging plane coordinate system and the image coordinate system. After three transformations between the four coordinate systems, the three-dimensional space point is converted from the world coordinate system to the image coordinate system. Due to reasons such as lens processing technology, the collected image will produce different degrees of distortion. In practical applications, the distortion of industrial lenses is mainly radial distortion, which will cause the point (u, v) of the imaging plane coordinate system to be T Changes:
[0054]
[0055] Where k is the radial distortion coefficient of the lens, is the coordinate of the projection point shifted on the imaging plane due to lens distortion.
[0056] Therefore, radial distortion will cause the actual coordinates of the target point in the image to shift, and the accuracy of the spatial image positioning algorithm is closely related to the coordinate information. The camera needs to be calibrated to obtain six parameters: the width and height of a single pixel in the camera, the focal length of the camera, the vertical projection of the lens optical center on the imaging plane, and the lens distortion coefficient, and the image needs to be distorted.
[0057] (1) Select a 160×160mm dot-shaped calibration plate for camera calibration. The diameter of the circle is 10mm, the center distance is 20mm, and the black triangle in the upper left corner is its direction mark. Through the Halcon calibration assistant window, according to the camera parameters, set the camera model to the surface scanning type, and determine the focal length and the width and height of a single pixel;
[0058] (2) The calibration plate position was continuously changed in the camera field of view and 16 calibration images were collected using the left and right cameras respectively. The camera was calibrated using the calibration plate images to obtain the camera internal parameters. The camera calibration accuracy was calculated using the back-projection error method to obtain the average calibration error of the left and right cameras.
[0059] (3) The gen_radial_distortion_map operator is used to establish the camera intrinsic parameter mapping relationship with and without distortion, and the Block Matching algorithm is used to perform stereo matching and disparity map calculation to correct image distortion and improve the accuracy of spatial positioning of the target point.
[0060] 2. Forest image recognition and collection;
[0061] The signal line of infrared sensor 1 is connected to the corresponding pin of the development board to give an infrared judgment signal; the development board is connected to the industrial computer via a USB data cable, and a logic judgment signal is sent to the industrial computer to determine whether to save the image; if the above judgment is yes, the binocular camera is connected to the industrial computer via a USB cable, and the collected image is transmitted to the industrial computer. When the infrared sensor 2 gives an infrared judgment signal, the image collection of a single tree is completed, and the program loops until the program is closed;
[0062] 3. Deep learning and model training;
[0063] (1) Dataset construction. First, the collected images are preprocessed. Since the collected images are binocular images, the gen_rectangle operator is used to evenly divide the left and right images along the vertical axis. After segmentation, the smooth operator or mean operator is used to smooth the image and remove noise to ensure that the image is free of background interference before training. Operators such as invert_image and scale_image are used for image enhancement, mainly image flipping, contrast and brightness changes, etc., so as to increase the image data set and improve the robustness of the model. Finally, the image is annotated and the MVTecDeep Learning Tool annotation tool is used to annotate the breast diameter rectangular box to complete the construction of the deep learning image dataset.
[0064] (2) Model training and optimization. Based on the halcon deep learning network framework, the tree target detection training is carried out. The SqueezeNet network model is introduced through the operator pretrained_dl_classifier_compact.hdl. The model is continuously optimized by adjusting the three parameters of batch-size, iterations and learning_rate. The optimal training model is determined by determining the average precision, accuracy and recall rate.
[0065] (3) Best model export: During training, specify the best model best_dl_model_detection.hdl save path to ensure the application of the best model in training.
[0066] 4. Measurement and statistics of tree diameter at breast height;
[0067] (1) The read_cam_par and read_pose operators are used to read the internal camera parameters of the left and right cameras obtained by binocular stereo vision calibration and the position of the right camera relative to the left camera to ensure that the binocular image is corrected in real time in the next step; the gen_binocular_rectification_map operator is used to obtain the transformation matrix between the non-standard outer limit image and the standard outer limit image, that is, the mapping image, and the left and right camera imaging is corrected according to the transformation matrix to obtain the corrected left and right camera image interfaces; the read_dl_model operator is used to introduce the trained tree diameter at breast height detection model, and the parameter setting set_dl_model_param operator is used to set the corresponding parameters to meet the requirements of real-time measurement of the diameter at breast height;
[0068] (2) Real-time image interface reading: when the binocular camera recognizes but does not save the image, the program performs the tree DBH measurement process and uses the list_files and tuple_regexp_select operators to open the binocular camera to read the image data in real time. The image reading type can be set to various types such as bmp, gif, jpg, etc.
[0069] (3) Set the corresponding recognition time. When the forest image is recognized within the recognition time, the image detection phase is performed. First, operators such as invert_image and scale_image are used for image enhancement to ensure the robustness of the detection process. Then, the left and right cameras are corrected according to the transformation matrix. Then, the gray_features operator is used to calculate the gray feature value of the specified area, thereby obtaining the gray value of the read image area.
[0070] (4) The gen_dl_samples_from_images and preprocess_dl_samples operators are used to detect the left and right images respectively. The grayscale value information is obtained according to the threshold(B,RegionB,L1,255) and threshold(H,RegionH,L2,255) operators. Then, the two boundary thresholds of the trunk diameter at breast height and the area below are determined: L1: = ValueR / 1.3, L2: = ValueR / 1.7. Finally, the two channels are segmented and then the union is taken to finally obtain the target detection area.
[0071] (5) Through morphological processing methods, get_dict_tuple and gen_circle are used to obtain the boundary area below the tree diameter at breast height after threshold segmentation and the coordinate positions of the two target points in the upper left and upper right of the boundary.
[0072] (6) Using the open_framegrabber operator, in the loop body, the forest images are read in sequence from the image data. At the beginning, the first two frames of images are selected; each time thereafter, an image with a later time frame is retained, and a new image is read in to cover the image with an earlier time frame;
[0073] (7) Calculation of the mean DBH. Use the tuple_mean and disp_message operators and define All:=[All,Mean] to count the number of identifications. If the number of identifications meets the specified requirements, the mean DBH of the trees is calculated. Otherwise, the identification is considered invalid and the DBH value is not counted.
[0074] (8) Detecting effectively identified trees. When the target tree disappears at the edge of the field of view and a valid DBH value is obtained, the corresponding tree number counting counter is incremented by 1;
[0075] (9) Use the open_file and fwrite_string operators to export statistical values into Excel tables, mainly including the tree count counter value and the corresponding tree breast diameter mean.
[0076] Compared with the prior art, the present invention has the following beneficial effects:
[0077] 1. Use binocular cameras to collect images of artificial forest trees, and use deep learning and binocular vision technology to obtain the size of the tree's diameter at breast height, which reduces manual workload, improves measurement accuracy, and avoids losses caused by measurement errors;
[0078] 2. The deep learning convolutional neural network model SqueezeNet is used to compress the size of the original AlexNet model to 1 / 50 of the original size while ensuring no loss of accuracy. Its parameters are 50 times less than those of AlexNet, which can achieve target detection tasks more efficiently and quickly and obtain the target rectangular frame area;
[0079] 3. Determine the two boundary thresholds of the trunk diameter at breast height and the area below by obtaining the regional grayscale value, and finally segment the two channels and take the union, which can make the edge contour to be extracted more obvious, enhance the image distinction, and minimize the impact of other background environmental factors on the measured object;
[0080] 4. Using binocular stereo vision technology for distance measurement has no recognition rate limit compared to monocular vision, because in principle, there is no need to identify and then measure, but to directly measure the target object. Binocular stereo vision is more accurate than monocular vision and directly uses parallax to calculate distance;
[0081] 5. When measuring the DBH of tree images, it can process a large amount of data and automatically obtain statistical results. For some non-tree targets such as shrubs and obstacles, the number of recognitions is insufficient and actual statistics and DBH measurements are not performed, thus avoiding misidentification and mismeasurement.
[0082] In this embodiment, a computer-readable storage medium is also provided, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the described method is implemented.
[0083] In this embodiment, an electronic device is further provided, wherein the electronic device includes:
[0084] processor; and,
[0085] A memory arranged to store computer executable instructions which, when executed, cause a processor to perform the method described.
[0086] It should be noted that:
[0087] The method used in this embodiment can be converted into program steps and devices that can be stored in a computer storage medium, and implemented by being called and executed by a controller, wherein the device should be understood as a functional module implemented by a computer program.
[0088] The algorithm and display provided herein are not inherently related to any particular computer, virtual device or other equipment. Various general-purpose devices can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of device. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for the purpose of disclosing the best mode of the present invention.
[0089] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0090] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0091] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0092] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0093] The various component embodiments of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0094] It should be noted that the embodiments are illustrative rather than limiting of the invention, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation of the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
Claims
1. A method for measuring tree diameter at breast height based on halcon binocular stereo vision, characterized in that: include: Step S1, binocular camera calibration; Step S2, using binocular camera to collect images to build a deep learning image dataset, performing tree target detection training based on the halcon deep learning network framework, and obtaining the optimal model by adjusting parameters; Step S3, (1) using the read_cam_par and read_pose operators to read the internal camera parameters of the left and right cameras and the position of the right camera relative to the left camera obtained by binocular stereo vision calibration; (2) using the gen_binocular_rectification_map operator to obtain the transformation matrix between the non-standard outer limit image and the standard outer limit image, and perform image correction on the left and right camera imaging according to the transformation matrix; (3) using the read_dl_model operator to introduce the trained tree diameter at breast height detection model, and use the parameter setting set_dl_model_param operator to set the corresponding parameters; (4) using the list_files and tuple_regexp_select operators to open the camera or read the image; (5) using the gen_dl_samples_from_images and preprocess_dl_samples operators to detect the left and right images respectively, obtain the boundary area below the tree diameter at breast height after threshold segmentation, select the coordinate positions of the upper left and upper right target points on the boundary, and define their horizontal coordinates The difference is the size of the diameter at breast height. The gray_features operator is used to calculate the gray feature value of the specified area, so as to obtain the gray value of the read image area. The gray value information is obtained according to the threshold(B,RegionB,L1,255) and threshold(H,RegionH,L2,255) operators. Then, the two boundary thresholds of the trunk diameter at breast height and the area below are determined: L1:=ValueR / 1.3, L2:=ValueR / 1.
7. Finally, the two channels are segmented and the union is taken to obtain the target detection (6) Using the open_framegrabber operator, in the loop body, the tree images are read in from the image data in sequence. At the beginning, the first two frames are selected, and each time the image with the later time is retained, the new image is read in, and the image with the earlier time is covered; (7) Using the tuple_mean and disp_message operators, and defining All:=[All,Mean] to count the number of recognition times, if the number of recognition times meets the specified setting requirements, the mean value of the tree diameter at breast height is calculated, otherwise the recognition is considered invalid and the diameter at breast height value statistics are not performed; (8) Detect effectively identified trees. When the target tree disappears at the edge of the field of view and a valid DBH value is obtained, the corresponding tree quantity statistical counter is incremented by 1. (9) Use open_file and fwrite_string operators to export statistical values, including the tree quantity counter value and the corresponding tree DBH mean value.
2. The method for measuring the tree diameter at breast height according to claim 1, characterized in that: The binocular camera calibration method of step S1 further includes: The internal and external parameters of the binocular camera are calibrated using a dot-type calibration plate. The calibration parameters are obtained based on the halcon nonlinear model handle calibration method. The image is corrected according to the calibration parameters, and the Block Matching algorithm is used for stereo matching and disparity map calculation.
3. The method for measuring the tree diameter at breast height according to claim 2, characterized in that: In step S1, the binocular camera calibration adopts the halcon calibration data model to collect multiple calibration images. During the collection process, after the previous calibration image is collected, the direction of the collected image is rotated, and then the next calibration image is collected until the entire calibration image set is obtained. During the collection of a single calibration image, the control is kept stationary.
4. The method for measuring the tree diameter at breast height according to claim 2, characterized in that: The method further comprises: calibrating the internal and external parameters of the binocular camera by a dot-type calibration plate, obtaining calibration parameters based on the halcon nonlinear model handle calibration method, correcting the image according to the calibration parameters, and using the Block Matching algorithm for stereo matching and disparity map calculation, and further comprising: Select the dot-type calibration plate for camera calibration. Through the Halcon calibration assistant window, set the camera model to the surface scanning type according to the camera parameters, and determine the focal length and the width and height of a single pixel. The calibration plate posture is continuously changed in the camera field of view, and multiple calibration images are collected using the left and right cameras. The camera is calibrated using the calibration plate images, the camera internal parameters are obtained, and the camera calibration accuracy is calculated using the back-projection error method to obtain the average calibration error of the left and right cameras. The gen_radial_distortion_map operator is used to establish the camera intrinsic parameter mapping relationship with and without distortion, and the Block Matching algorithm is used to perform stereo matching and disparity map calculation.
5. The method for measuring the tree diameter at breast height according to claim 1, characterized in that: Before constructing the deep learning image dataset, step S2 further includes: The gen_rectangle operator is used to evenly divide the left and right images along the vertical axis; After segmentation, the image is smoothed using a smooth operator or a mean operator; Use invert_image and scale_image operators to enhance the image and perform image annotation.
6. The method for measuring the tree diameter at breast height according to claim 5, characterized in that: The image enhancement is performed by adjusting contrast and brightness; and / or The image annotation further includes using the MVTec Deep Learning Tool annotation tool to annotate the DBH and the area below with a rectangular frame.
7. The method for measuring the tree diameter at breast height according to claim 1, characterized in that: The step S2 of performing tree target detection training based on the halcon deep learning network framework and obtaining the optimal model by adjusting parameters further includes: The model network is configured as SqueezeNet and its corresponding operator is configured as pretrained_dl_classifier_compact.hdl; and / or The parameters to be adjusted are configured to include at least batch-size, iterations, and learning_rate.
8. The method for measuring the tree diameter at breast height according to claim 1, characterized in that: In the step S3, the step of obtaining the boundary area below the tree diameter at breast height after the threshold segmentation, selecting the coordinate positions of the two target points at the upper left and upper right of the boundary, and defining the horizontal coordinate difference as the size of the diameter at breast height, further comprises: Through morphological processing methods, get_dict_tuple and gen_circle are used to obtain the boundary area below the tree's diameter at breast height after threshold segmentation and the coordinates of the two target points in the upper left and upper right of the boundary.
9. The method for measuring the tree diameter at breast height according to claim 1, characterized in that: In the step S3, before using the gray_features operator to calculate the gray feature value of the specified area, the method further includes: Use invert_image and scale_image operators for image enhancement; Image correction is performed on the left and right cameras respectively according to the transformation matrix.
10. The method for measuring the tree diameter at breast height according to claim 1, characterized in that: The step S3 further comprises: In steps (1), (2) and (3), the camera internal parameters, transformation matrix and tree diameter at breast height detection model are placed in a fixed position on a computer for reading; and / or In step (4), the read image is configured as a color image; and / or In step (5), a rectangular frame of the tree diameter at breast height is obtained according to the marking method, and a detection area is obtained according to the gray value information and the two boundary threshold settings.
Citation Information
Patent Citations
Standing tree determination method based on binocular vision
CN111179335A
KR20220004491A