Automatic spraying control method, system and equipment based on image recognition and medium
Through the automatic spray control method based on image recognition, the characteristics of dairy cows are identified and screened, and the spray head is accurately selected for spraying, which solves the problems of low spray accuracy and waste of water resources in the existing technology, and improves the intelligence level of ranch management.
Patent Information
- Application Number
- CN202411349104.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-28
AI Technical Summary
The existing spray system cannot accurately locate the cow's location, resulting in low spray accuracy and serious waste of water resources, which increases the cost of ranch management.
Using an automatic spray control method based on image recognition, by acquiring pasture images, the characteristics of the cattle body parts, such as the characteristics of the cow's head, buttocks and trunk, the characteristics of the target cattle body parts are screened out, the positions of the cattle are determined and the corresponding spray head is selected for spraying.
Accurate spraying of dairy cows has been achieved, significantly reducing waste of water resources and improving the intelligent level of ranch management.
Smart Images

Figure CN119540843A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition, and in particular to an automatic spray control method, system, equipment and medium based on image recognition. Background Art
[0002] In modern ranch management, the health and comfort of dairy cows have an important impact on milk production and quality. Especially in hot weather conditions, dairy cows are prone to heat stress due to high temperatures, which leads to decreased appetite, reduced milk production, and even disease. In the prior art, a combination of spraying and fans is usually used to cool down dairy cows. A spray system is installed in the cowshed, and water is sprayed by timing or manually controlling the sprinkler heads to cool down the cows. However, this method cannot accurately locate the position of each cow, resulting in low spray accuracy, and because the spraying area cannot be accurately controlled, a large amount of water resources will be wasted, resulting in high ranch management costs. Therefore, it is necessary to provide an automatic spray control method, system, equipment and medium based on image recognition. Summary of the invention
[0003] The present invention provides an automatic spraying control method based on image recognition, which improves the problem of low accuracy of spraying cows in the prior art.
[0004] The present invention provides an automatic sprinkler control method based on image recognition, comprising: obtaining a pasture image taken from a preset position; wherein the preset position is the side, back or front of a railing in the pasture; according to the preset position, inputting the pasture image into a corresponding image recognition model, and correspondingly identifying cow body part features from the pasture image; wherein the cow body part features include cow head features, cow hip features and / or cow trunk features; according to the preset position, screening the cow body part features to determine target cow body part features; determining the position of the cow according to the target cow body part features, and selecting and opening the corresponding sprinkler head for spraying.
[0005] In one embodiment of the present invention, the pasture image is input into a corresponding image recognition model according to the preset position, and corresponding features of the cow body parts are identified from the pasture image, including: when the preset position is the side of the railing in the pasture, the pasture image is input into a first image recognition model, and at least the features of the cow's trunk are identified from the pasture image; when the preset position is the back of the railing in the pasture, the pasture image is input into a second image recognition model, and at least the features of the cow's buttocks and the cow's trunk are identified from the pasture image; when the preset position is the front of the railing in the pasture, the pasture image is input into a third image recognition model, and the features of the cow's head are identified from the pasture image.
[0006] In one embodiment of the present invention, the cow body part features are screened according to the preset position to determine the target cow body part features, including: when the preset position is the side of the railing, the cow body part features at least include the cow trunk features; determine whether the cow body part features only include the cow trunk features: if so, calculate the intersection and union ratio of the cow trunk features and the preset railing features, and determine the target cow body part features based on the intersection and union ratio; otherwise, extract the cow head features from the cow body part features, update the cow trunk features according to the cow head features, calculate the intersection and union ratio of the cow trunk features and the preset railing features, and determine the target cow body part features based on the intersection and union ratio.
[0007] In one embodiment of the present invention, the calculation of the intersection-and-union ratio of the cow trunk feature and the preset rail feature, and determining the target cow body part feature based on the intersection-and-union ratio, includes: calculating the intersection-and-union ratio of the cow trunk feature and the rail feature, and determining whether the intersection-and-union ratio is greater than a preset first threshold: if so, determining that the cow trunk feature is the target cow body part feature; otherwise, continuing to detect the next pasture image.
[0008] In one embodiment of the present invention, the cow head feature is extracted from the cow body part features, the cow trunk feature is updated according to the cow head feature, the intersection and union ratio of the cow trunk feature and the preset railing feature is calculated, and the target cow body part feature is determined based on the intersection and union ratio, including: extracting the cow head feature from the cow body part features; when the cow head is close to the railing, calculating the intersection and union ratio of the cow head feature and the cow trunk feature, and judging whether the intersection and union ratio is greater than a preset second threshold: if so, removing the cow head feature from the cow trunk feature and updating the cow trunk feature; otherwise, keeping the cow trunk feature unchanged; calculating the intersection and union ratio of the cow trunk feature and the railing feature, and determining the target cow body part feature based on the intersection and union ratio.
[0009] In one embodiment of the present invention, the process of determining whether the cow's head is close to the railing is as follows: calculating the intersection-and-union ratio of the cow's head feature and the railing feature, and determining whether the intersection-and-union ratio is greater than a preset third threshold: if so, the cow's head is close to the railing; otherwise, the cow's head is not close to the railing, and continuing to detect the next pasture image.
[0010] In one embodiment of the present invention, the cow body part features are screened according to the preset position to determine the target cow body part features, including: when the preset position is the back of the railing, the cow body part features at least include the cow buttocks features and the cow trunk features; determine whether the cow body part features only include the cow buttocks features and the cow trunk features: if so, determine that the cow buttocks features are the target cow body part features; otherwise, continue to detect the next pasture image.
[0011] In one embodiment of the present invention, the cow body part features are screened according to the preset position to determine the target cow body part features, including: when the preset position is the front view of the railing, the cow body part features include cow head features; judging whether the cow head features are at the preset railing bottom line position: if so, determining that the cow head features are the target cow body part features; otherwise, continuing to detect the next pasture image.
[0012] In one embodiment of the present invention, determining the position of the cow based on the target cow body part feature, selecting and turning on the corresponding sprinkler for spraying, includes: extracting the coordinates of the center point of the cow body part feature in the pasture image; converting the coordinates of the center point into actual coordinates based on a preset conversion rule, and calculating the deviation angle of the center point relative to the camera in combination with a preset camera viewing angle; based on the deviation angle, selecting and turning on the corresponding sprinkler for spraying based on a preset mapping rule.
[0013] In one embodiment of the present invention, an automatic sprinkler control system based on image recognition is also provided, and the system includes: a data acquisition module, used to acquire a pasture image taken from a preset position; wherein the preset position is the side, back or front of a railing in the pasture; a feature extraction module, used to input the pasture image into a corresponding image recognition model according to the preset position, and correspondingly identify the features of the cow's body parts from the pasture image; wherein the features of the cow's body parts include features of the cow's head, cow's buttocks and / or cow's trunk; a part feature determination module, used to screen the features of the cow's body parts according to the preset position, and determine the target cow's body part features; a spraying module, used to determine the position of the cow according to the target cow's body part features, and select and open the corresponding sprinkler for spraying.
[0014] In one embodiment of the present invention, an electronic device is also provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements any of the above-mentioned automatic sprinkler control methods based on image recognition.
[0015] In one embodiment of the present invention, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes any of the above-mentioned automatic sprinkler control methods based on image recognition.
[0016] The present invention proposes an automatic spray control method, system, device and medium based on image recognition. A pasture image is obtained from a preset position and input into a corresponding image recognition model to identify the characteristics of the cattle body parts. Since different preset positions correspond to different image recognition models, it is ensured that the characteristics of the cattle can be accurately identified under different viewing angles for subsequent discrimination. According to the preset position of the camera, the detected cattle body part characteristics are screened to determine the target cattle body part characteristics, thereby ensuring that only when the cattle body part characteristics meet the preset conditions will they be selected as target characteristics, reducing false alarms and invalid detections. The specific position of the cattle can be determined by the target cattle body part characteristics, so as to select the corresponding nozzle for spraying. Through intelligent nozzle selection and control, accurate and efficient spraying operation is achieved. Compared with the indiscriminate spraying in the prior art, this method of the present invention greatly reduces the waste of water resources and improves the intelligent level of pasture management. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A pasture image provided by an embodiment of the present invention;
[0018] Figure 2 A schematic flow chart of an automatic sprinkler control method based on image recognition provided by an embodiment of the present invention;
[0019] Figure 3 An overall schematic diagram of a ranch provided by an embodiment of the present invention;
[0020] Figure 4 Shown is a structural block diagram of an automatic sprinkler control system based on image recognition provided by an embodiment of the present invention;
[0021] Figure 5 Shown is a structural schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0023] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0024] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0025] The inventors have found that dairy cows are cold-resistant but not heat-resistant. Generally, the most suitable temperature for dairy cows is 12℃~14℃, and the most suitable temperature for pregnant cows and lactating cows is 16℃~20℃; if the temperature in the house of lactating dairy cows is higher than 24℃ or lower than -4℃, the milk production will decrease; the most suitable temperature for calves is 35℃~38℃. When the ambient temperature in the cattle farm is above 26 degrees, turn on the spray device to cool the cows. The normal body temperature of a cow is 38℃~39℃, and the rumen temperature of a cow is 39~41℃. Therefore, the requirement for spraying is to wet the front half of the cow's trunk, and the water must pass through the hair to reach the skin. After spraying for a period of time, stop spraying when the water flows to the ground in streams. Turn on the fan to dry the water on the cow. Figure 1 As shown in the figure, the requirements for the installation position of the spraying device in the cattle pen are that the spraying water can only be sprayed on the cattle walking channel (A in the figure), and cannot be sprayed on the grass (C in the figure), nor can it be sprayed on the cattle's bed (B in the figure). A large fan is installed in the cattle pen, and it is always open for ventilation in summer, so the nozzle cannot be installed very high to prevent the water column from being blown to the cattle bed or the feeding channel by the wind. The spraying device is generally installed on the feeding railing. The cow's head passes through the neck yoke to eat grass, and the spraying water is sprayed on the cow's back. The nozzle setting requires that water cannot be sprayed on the cattle bed or the cattle eating grass channel, so the nozzle setting can only spray on the cattle channel, and the distance is controlled within 0.5 meters to 1.0 meters. The action habit of cattle eating grass is to lower their heads for 20-30 seconds to eat grass, raise their heads to chew for 10-20 seconds, swallow, and then lower their heads to eat grass. According to the habit of cattle eating grass, the present invention proposes a corresponding processing method, so as to intelligently identify the position of the cattle and spray.
[0026] The present invention provides an automatic spray control method based on image recognition, which obtains a pasture image from a preset position and inputs it into a corresponding image recognition model to identify the characteristics of cattle body parts. Since different preset positions correspond to different image recognition models, it is ensured that the characteristics of cattle can be accurately identified under different viewing angles for subsequent discrimination. According to the preset position of the camera, the detected characteristics of cattle body parts are screened to determine the target characteristics of cattle body parts, thereby ensuring that only when the characteristics of cattle body parts meet the preset conditions will they be selected as target characteristics, reducing false alarms and invalid detections. The specific position of the cattle can be determined by the characteristics of the target cattle body parts, so as to select the corresponding nozzle for spraying. Through intelligent nozzle selection and control, accurate and efficient spraying operation is achieved. Compared with the indiscriminate spraying in the prior art, this method of the present invention greatly reduces the waste of water resources and improves the intelligent level of pasture management.
[0027] See also Figure 2 , the automatic sprinkler control method based on image recognition includes the following steps:
[0028] S1. Acquire a pasture image taken from a preset position; wherein the preset position is the side, back or front of a railing in the pasture.
[0029] In a pasture, cameras can be mounted on the side, back, or front of a fence. The camera captures images at regular intervals to create an image of the pasture at the current moment. Figure 3 As shown, the side of the rail refers to the position of shooting from the side of the cow while the cow is eating, so that the trunk features of the cow can be clearly captured during the feeding period. The back of the rail refers to the position of shooting from the back of the cow while the cow is eating, so that the cow's hips and trunk features can be captured. The front of the rail refers to the position of shooting from the front of the cow while the cow is eating, so that the head features of the cow can be captured.
[0030] S2. According to the preset position, the pasture image is input into a corresponding image recognition model, and the corresponding features of the cattle body parts are identified from the pasture image; wherein the features of the cattle body parts include features of the cattle head, features of the cattle buttocks and / or features of the cattle trunk.
[0031] The pasture image is input into the corresponding pre-trained image recognition model to identify the corresponding cattle body part features, wherein the image recognition model is a YOLO series model, including but not limited to Yolov8, Yolov9, Yolov10, etc. In order to improve the image quality, the pasture image is preprocessed before being input into the image recognition model. The preprocessing process includes but is not limited to image graying, denoising, and normalization. After the preprocessed pasture image is input into the corresponding image recognition model, the image recognition model detects the cattle body part features from the input pasture image and generates the corresponding detection frame.
[0032] In one embodiment of the present invention, the step of inputting the pasture image into a corresponding image recognition model according to the preset position, and correspondingly identifying the features of the cow body parts from the pasture image includes: When the preset position is a side of a fence in a pasture, inputting the pasture image into a first image recognition model, and recognizing at least a cow trunk feature from the pasture image; When the preset position is the back of a fence in a pasture, the pasture image is input into a second image recognition model, and at least a cow buttock feature and a cow trunk feature are recognized from the pasture image; When the preset position is the front of a fence in a pasture, the pasture image is input into a third image recognition model, and the features of a cow's head are recognized from the pasture image.
[0033] According to the preset position of the camera, the corresponding image recognition model is selected for processing. Specifically, when the preset position is the side of the railing, the image captured at this time is mainly the side view of the cow for the situation of cattle eating. These images are input into the trained first image recognition model, and by analyzing the image, at least the trunk features of the cow are identified and marked, and the corresponding detection frame is generated. When the preset position is the back of the railing, the captured image mainly includes the back view of the cow. These images are input into the trained second image recognition model, which is used to identify and mark the buttocks and trunk features of the cow, and obtain the corresponding detection frame. By analyzing the input image, at least the trunk and buttocks features of the cow are identified. When the preset position is the front of the railing, the captured image mainly includes the front view of the cow. These images are input into the trained third image recognition model, which is used to identify the head features of the cow. By analyzing the input image, the head position of the cow is identified and marked with a detection frame. It can be understood that for each of the above-mentioned image recognition models, if the corresponding cow body part features cannot be identified from the pasture image, the next pasture image is selected. Exemplarily, for the first image recognition model, if the cow trunk feature cannot be identified from the pasture image (ie, the detection frame does not contain the cow trunk feature), the next pasture image is selected for recognition.
[0034] S3. Screening the characteristics of the cattle body parts according to the preset positions to determine the characteristics of the target cattle body parts.
[0035] In the present invention, when the cow is eating, that is, when the cow's head sticks out of the railing, the cow's body will be sprayed. Considering the camera's directional angle, the cow captured is not only eating, but there may also be cows walking in the aisle, lying down, etc., in which case there is no need for spraying. If spraying is performed only after the characteristics of the cow's body parts are identified, unnecessary spraying operations will result, resulting in a large waste of water resources. In order to improve the recognition accuracy, it is necessary to determine the corresponding screening criteria according to the preset position, and the detection frame corresponding to the characteristics of the cow's body parts identified by the above-mentioned image recognition model is screened according to the screening criteria, so as to reduce the false alarm rate, thereby improving the recognition accuracy and recognition rate.
[0036] Specifically, in an embodiment of the present invention, screening the characteristics of the cattle body parts according to the preset position to determine the characteristics of the target cattle body parts includes: When the preset position is the side of the railing, the cow body part features at least include cow trunk features; Determine whether the cow body part features only include the cow trunk features: If yes, then the intersection-and-union ratio of the cow trunk feature and the preset railing feature is calculated, and the target cow body part feature is determined based on the intersection-and-union ratio; Otherwise, the cow head feature is extracted from the cow body part feature, the cow trunk feature is updated according to the cow head feature, the intersection and union ratio of the cow trunk feature and the preset railing feature is calculated, and the target cow body part feature is determined based on the intersection and union ratio.
[0037] When the preset position is the side of the railing, the image captured by the camera is preprocessed and input into the trained first image recognition model. For each input image, the first image recognition model will detect and mark a detection frame that at least includes the cow trunk feature. The detected cow body part features are judged to check whether these features only include the cow trunk feature: if the feature only includes the cow trunk feature (that is, the detection frame of the cow body part feature is the detection frame of the cow trunk feature), the intersection and union ratio between the detection frame of the cow trunk feature and the detection frame of the preset railing feature is calculated, and the target cow body part feature is determined based on the calculated intersection and union ratio. If the detected cow body part features do not only include the cow trunk feature (that is, the detection frame of the cow body part features includes the detection frame of the cow trunk feature and the detection frame of the cow head feature), it means that the cow body part features also include the cow head feature. At this time, the position and size of the detection frame of the cow trunk feature will be updated according to the detection frame of the cow head feature, and the intersection and union ratio between the updated detection frame of the cow trunk feature and the detection frame of the preset railing feature will be calculated. The detection frame of the cow body features is determined based on the calculated intersection-over-union ratio. By refining the detection results, the detection frame of the cow trunk features is retained or the updated detection frame of the cow trunk features is updated, which reduces the false positives caused by the diversity of the cow's positions and greatly improves the accuracy of recognition.
[0038] In one embodiment of the present invention, the calculating of the intersection-and-union ratio of the cow trunk feature and the preset railing feature, and determining the target cow body part feature based on the intersection-and-union ratio, includes: Calculate the intersection-and-union ratio of the cow trunk feature and the railing feature, and determine whether the intersection-and-union ratio is greater than a preset first threshold: If yes, then determining the cattle trunk feature as the target cattle body part feature; Otherwise, continue to detect the next pasture image.
[0039] Considering that when the cow is eating, it will move its trunk close to the railing so that the cow's head can stick out of the railing to eat. At this time, the cow's trunk is close to the railing, so the overlap between the two is large. Therefore, by calculating the intersection and union ratio between the detection frame of the cow's trunk feature and the detection frame of the railing feature, it can be determined whether the cow is in the eating state, and then determine whether the cow needs to be sprayed. Specifically, if the intersection and union ratio between the detection frame of the cow's trunk feature and the detection frame of the railing feature is greater than the first threshold, it means that the overlap between the cow's trunk and the railing is large, and it can be considered that the cow's head sticks out of the railing, and the cow's trunk is close to the railing, and it is in the eating state at this time. Therefore, the cow's trunk feature is determined as the target cow body part feature. On the contrary, if the intersection and union ratio is less than or equal to the first threshold, it means that the overlap between the cow's trunk and the railing is small, and it can be considered that the cow is not in the eating state. At this time, the next pasture image will continue to be analyzed.
[0040] In one embodiment of the present invention, extracting the cow head feature from the cow body part feature, updating the cow trunk feature according to the cow head feature, calculating the intersection-and-union ratio of the cow trunk feature and the preset railing feature, and determining the target cow body part feature based on the intersection-and-union ratio, includes: Extracting cow head features from the cow body part features; When the cow's head approaches the railing, the intersection-and-union ratio of the cow's head feature and the cow's trunk feature is calculated, and it is determined whether the intersection-and-union ratio is greater than a preset second threshold: If yes, then remove the cow head feature from the cow trunk feature and update the cow trunk feature; Otherwise, keep the bovine trunk characteristics unchanged; The intersection-and-union ratio of the cow trunk feature and the rail feature is calculated, and the target cow body part feature is determined based on the intersection-and-union ratio.
[0041] In the case where the cow body part feature also includes the cow head feature, it is first necessary to determine whether the cow head is close to the railing. If the cow head is not close to the railing, it means that the cow is not in a state of eating. At this time, the next pasture image can be detected directly. If the cow head is close to the railing, the intersection and union ratio between the detection frame of the cow head feature and the detection frame of the cow trunk feature needs to be calculated. If the intersection and union ratio is greater than the second threshold, it means that the overlap between the cow head and the cow trunk is high, indicating that there is a false detection in the detection of the cow trunk, and the cow head part is included. At this time, it is necessary to subtract the detection frame of the cow head feature from the detection frame of the cow trunk feature to update the original detection frame of the cow trunk feature. On the contrary, if the intersection and union ratio is less than or equal to the second threshold, it means that the overlap between the cow head and the cow trunk is small, and no false detection occurs. At this time, the original detection frame of the cow trunk feature remains unchanged. Then, the intersection and union ratio between the detection frame of the cow trunk feature and the detection frame of the railing feature is calculated in the above manner, and when the intersection and union ratio is greater than the first threshold, the cow trunk feature is used as the target cow body feature for selecting the corresponding nozzle.
[0042] In one embodiment of the present invention, the process of determining whether the bull head is close to the railing is as follows: Calculate the intersection-and-union ratio of the bull head feature and the railing feature, and determine whether the intersection-and-union ratio is greater than a preset third threshold: If so, the bull's head is close to the railing; Otherwise, if the cow head is not close to the fence, the next pasture image will be detected.
[0043] In order to determine whether the cow's head is close to the railing (i.e., whether the cow is in a feeding state), it is necessary to calculate the intersection-and-union ratio between the detection frame of the cow's head feature and the detection frame of the railing feature. If the intersection-and-union ratio is greater than the third threshold, it means that the cow's head and the railing overlap more, indicating that the cow's head is close to the railing and stretches out of the railing to eat. On the contrary, if the intersection-and-union ratio of the two is less than or equal to the third threshold, it means that the cow's head and the railing overlap less, indicating that the cow's head is not close to the railing, that is, the cow is not in a feeding state, and the next pasture image can be detected.
[0044] In an embodiment of the present invention, screening the characteristics of the cattle body parts according to the preset position to determine the characteristics of the target cattle body parts includes: When the preset position is the back of the railing, the cow body part features at least include the cow buttocks features and the cow trunk features; Determine whether the cow body part features only include the cow buttocks features and the cow trunk features: If yes, then determining the cow buttocks feature as the target cow body part feature; Otherwise, continue to detect the next pasture image.
[0045] When the preset position is the back of the railing, when the cow is eating, the shooting angle is the back of the cow, so the cow body part features generated by the second image recognition model include at least the cow buttocks features and the cow trunk features. Considering that the camera is installed at a high height, more content is captured, and the cow's buttocks and trunk will all be captured in the image. In this case, it can be considered that the cow is in the eating state. Since the buttocks have a large area and obvious features, the cow buttocks features are used as the target cow body features. On the contrary, if the cow body part features do not all include the cow buttocks features and the cow trunk features at this shooting position, it means that the cow is not in the eating state, and the detection of the next image can be continued.
[0046] In an embodiment of the present invention, screening the characteristics of the cattle body parts according to the preset position to determine the characteristics of the target cattle body parts includes: When the preset position is the front view of the railing, the cow body part features include cow head features; Determine whether the bull head feature is at the preset railing bottom line position: If yes, then the cow head feature is determined to be the target cow body part feature; Otherwise, continue to detect the next pasture image.
[0047] When the preset position is the front view of the railing, it means that the camera shoots from the front of the cow when it is eating. At this time, the image is input into the third image recognition model, the cow head feature is detected, and a detection frame of the cow head feature is generated. Check whether the center of the detection frame of the cow head feature is located at the preset railing bottom line position. If so, it means that the cow is eating, and the cow head feature is the target cow body part feature. Otherwise, it means that the cow is not in a state of eating, and the next pasture image is detected. In the present invention, considering that when the cow eats, the head will move up and down within a preset height range, the range is determined by the first railing bottom line position (that is, the head is raised) and the second railing bottom line position (the head is lowered). When the detection frame of the cow head feature is between these two positions, it is considered that the cow is eating. Specifically, checking whether the center of the detection frame of the cow head feature is located at the preset railing bottom line position includes: determining whether the center of the detection frame of the cow head feature is located between the preset first railing bottom line position and the preset second railing bottom line position, if so, the center of the detection frame of the cow head feature is located at the preset railing bottom line position, otherwise, the center of the detection frame of the cow head feature is not located at the preset railing bottom line position, indicating that the cow is doing other activities (such as turning its head or walking, etc.), and the next pasture image can be detected at this time. Among them, the first railing bottom line position is higher than the second railing bottom line position, the first railing bottom line position is the reference position when the cow's head is raised, and the second railing bottom line position is the reference position when the cow's head is lowered.
[0048] S4. Determine the position of the cow according to the characteristics of the target cow body part, and select and open the corresponding nozzle for spraying.
[0049] After determining the target cow body part features through the image recognition model corresponding to the preset position and the screening criteria corresponding to the position, the actual position of the cow in the camera's field of view is determined based on the detection frame position of the target cow body part features, so as to select the corresponding nozzle for spraying according to the actual position of the cow.
[0050] In one embodiment of the present invention, the step of determining the position of the cow according to the characteristics of the target cow body part, and selecting and opening the corresponding nozzle for spraying includes: Extract the coordinates of the center point of the cattle body part feature in the pasture image; According to a preset conversion rule, the coordinates of the center point are converted into actual coordinates, and the deviation angle of the center point relative to the camera is calculated in combination with a preset camera viewing angle; Based on the deviation angle, the corresponding nozzle is selected and opened for spraying according to a preset mapping rule.
[0051] The center point coordinates are extracted from the detection frame of the features of the cow's body parts, and the center point coordinates are converted into actual space coordinates according to the conversion rules preset by the camera's installation position and viewing angle. According to the actual space coordinates and the position of the camera, the deviation angle of the center point relative to the camera can be calculated. According to the deviation angle and the preset mapping rules, the corresponding nozzle is selected for spraying, wherein the mapping rules are nozzle identifications corresponding to different angle ranges. For example, when the deviation angle is [15-30) degrees, it corresponds to the second nozzle, and when the angle is [30-45) degrees, it corresponds to the third nozzle.
[0052] It should be noted that, in order to improve the accuracy of detection, the present invention uses multiple consecutive frames (i.e., a preset number of consecutive frames) of pasture images for detection. When the cows in the multiple consecutive frames of pasture images are all under the sprinkler, spraying is performed. Exemplarily, when the preset position is the side of the railing, when the target cow body features of the cow are detected to be under the corresponding sprinkler for multiple consecutive frames, the sprinkler is turned on for spraying. At this stage, the cow will still be detected. If the intersection and union ratio of the detection frame of the cow trunk feature and the detection frame of the railing feature is less than the first threshold and lasts for a preset time (such as 10 seconds), it means that the cow has left the railing, and the spraying will be stopped at this time. When the preset position is the front of the railing, when the target cow body features of the cow are detected to be under the corresponding sprinkler for multiple consecutive frames, the sprinkler is turned on for spraying. At this stage, the cow will still be detected. If the detection frame of the cow head feature is not close to the railing for a preset time (such as 20 seconds), it means that the cow has left the railing, and the spraying will be stopped at this time. In addition, when the same cow is detected in multiple consecutive frames, the present invention can determine whether these detection frames belong to the same cow based on the fact that the intersection-and-union ratio of the cow head detection frame and the cow trunk detection frame in the multiple consecutive frames is continuously greater than the preset intersection-and-union ratio threshold. If multiple cows appear in the same pasture image, their respective detection frames can be determined by this method. The judgment rules for the cow buttocks detection frame are similar and will not be repeated here.
[0053] See also Figure 4 , the automatic sprinkler control system 100 based on image recognition includes: a data acquisition module 110, a feature extraction module 120, a part feature determination module 130 and a spray module 140. The data acquisition module 110 is used to obtain a pasture image taken from a preset position; wherein the preset position is the side, back or front of the railing in the pasture. The feature extraction module 120 is used to input the pasture image into the corresponding image recognition model according to the preset position, and identify the cow body part features from the pasture image; wherein the cow body part features include cow head features, cow hip features and / or cow trunk features. The part feature determination module 130 is used to screen the cow body part features according to the preset position and determine the target cow body part features. The spray module 140 is used to determine the position of the cow according to the target cow body part features, select and open the corresponding sprinkler for spraying.
[0054] For the specific definition of the automatic sprinkler control system based on image recognition, please refer to the definition of the automatic sprinkler control method based on image recognition above, which will not be repeated here. Each module in the above-mentioned automatic sprinkler control system based on image recognition can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware format, or can be stored in the memory in the computer device in software format, so that the processor can call the operations corresponding to the above modules.
[0055] It should be noted that, in order to highlight the innovative part of the present invention, the present embodiment does not introduce modules that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other modules in the present embodiment.
[0056] See also Figure 5 The electronic device 1 may include a memory 12, a processor 13 and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13, such as an automatic sprinkler control program based on image recognition.
[0057] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The memory 12 can be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 12 can also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 12 can also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the electronic device 1, such as the code of automatic sprinkler control based on image recognition, but also can be used to temporarily store data that has been output or is to be output.
[0058] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the electronic device 1, and uses various interfaces and lines to connect various components of the entire electronic device 1, and executes or executes programs or modules stored in the memory 12 (such as an automatic spray control program based on image recognition, etc.), and calls data stored in the memory 12 to execute various functions of the electronic device 1 and process data.
[0059] The processor 13 executes the operating system and various installed application programs of the electronic device 1. The processor 13 executes the application programs to implement the steps in the above-mentioned automatic sprinkler control method based on image recognition.
[0060] Exemplarily, the computer program may be divided into one or more modules, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into a data acquisition module 110, a feature extraction module 120, a part feature determination module 130, and a spray module 140.
[0061] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium, and the computer-readable storage medium can be non-volatile or volatile. The above-mentioned software function module is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to perform part of the functions of the automatic sprinkler control method based on image recognition described in various embodiments of the present application.
[0062] In summary, the present invention discloses an automatic spray control method, system, device and medium based on image recognition, which obtains a pasture image from a preset position and inputs it into a corresponding image recognition model to identify the characteristics of the cattle body parts. Since different preset positions correspond to different image recognition models, it is ensured that the characteristics of the cattle can be accurately identified at different viewing angles for subsequent discrimination. According to the preset position of the camera, the detected cattle body part characteristics are screened to determine the target cattle body part characteristics, thereby ensuring that only when the cattle body part characteristics meet the preset conditions, they will be selected as target characteristics, reducing false alarms and invalid detections. The specific position of the cattle can be determined by the target cattle body part characteristics, so as to select the corresponding nozzle for spraying. Through intelligent nozzle selection and control, accurate and efficient spraying operation is achieved. Compared with the indiscriminate spraying of the prior art, this method of the present invention greatly reduces the waste of water resources and improves the intelligent level of pasture management. Therefore, the present invention effectively overcomes the various shortcomings of the prior art and has a high industrial utilization value.
[0063] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. An automatic sprinkler control method based on image recognition, characterized in that: The method comprises: Acquire a pasture image taken from a preset position; wherein the preset position is the side, back or front of a fence in the pasture; According to the preset position, the pasture image is input into a corresponding image recognition model, and the features of the cattle body parts are correspondingly identified from the pasture image; wherein the features of the cattle body parts include features of the cattle head, features of the cattle buttocks and / or features of the cattle trunk; According to the preset position, the characteristics of the cow body part are screened to determine the characteristics of the target cow body part; the position of the cow is determined according to the characteristics of the target cow body part, and the corresponding nozzle is selected and opened for spraying.
2. The automatic sprinkler control method based on image recognition according to claim 1, characterized in that: According to the preset position, the pasture image is input into a corresponding image recognition model, and corresponding features of the cow body parts are identified from the pasture image, including: When the preset position is a side of a fence in a pasture, inputting the pasture image into a first image recognition model, and recognizing at least a cow trunk feature from the pasture image; When the preset position is the back of a fence in a pasture, the pasture image is input into a second image recognition model, and at least a cow buttock feature and a cow trunk feature are recognized from the pasture image; When the preset position is the front of a fence in a pasture, the pasture image is input into a third image recognition model, and the features of a cow's head are recognized from the pasture image.
3. The automatic sprinkler control method based on image recognition according to claim 1, characterized in that: The step of screening the characteristics of the cattle body parts according to the preset positions to determine the characteristics of the target cattle body parts includes: When the preset position is the side of the railing, the cow body part features at least include cow trunk features; Determine whether the cow body part features only include the cow trunk features: If yes, then the intersection-and-union ratio of the cow trunk feature and the preset railing feature is calculated, and the target cow body part feature is determined based on the intersection-and-union ratio; Otherwise, the cow head feature is extracted from the cow body part feature, the cow trunk feature is updated according to the cow head feature, the intersection and union ratio of the cow trunk feature and the preset railing feature is calculated, and the target cow body part feature is determined based on the intersection and union ratio.
4. The automatic sprinkler control method based on image recognition according to claim 3 is characterized in that: The calculating the intersection-and-union ratio of the cow trunk feature and the preset railing feature, and determining the target cow body part feature based on the intersection-and-union ratio, includes: Calculate the intersection-and-union ratio of the cow trunk feature and the railing feature, and determine whether the intersection-and-union ratio is greater than a preset first threshold: If yes, then determining the cattle trunk feature as the target cattle body part feature; Otherwise, continue to detect the next pasture image.
5. The automatic sprinkler control method based on image recognition according to claim 3 is characterized in that: The step of extracting a cow head feature from the cow body part feature, updating the cow trunk feature according to the cow head feature, calculating an intersection-and-union ratio of the cow trunk feature and a preset railing feature, and determining a target cow body part feature based on the intersection-and-union ratio includes: Extracting cow head features from the cow body part features; When the cow's head approaches the railing, the intersection-and-union ratio of the cow's head feature and the cow's trunk feature is calculated, and it is determined whether the intersection-and-union ratio is greater than a preset second threshold: If yes, then remove the cow head feature from the cow trunk feature and update the cow trunk feature; Otherwise, keep the bovine trunk characteristics unchanged; The intersection-and-union ratio of the cow trunk feature and the rail feature is calculated, and the target cow body part feature is determined based on the intersection-and-union ratio.
6. The automatic spray control method based on image recognition according to claim 5 is characterized in that: The process of judging whether the bull head is close to the railing is as follows: Calculate the intersection-and-union ratio of the bull head feature and the railing feature, and determine whether the intersection-and-union ratio is greater than a preset third threshold: If so, the bull's head is close to the railing; Otherwise, if the cow head is not close to the fence, the next pasture image will be detected.
7. The automatic sprinkler control method based on image recognition according to claim 1, characterized in that: The step of screening the characteristics of the cattle body parts according to the preset positions to determine the characteristics of the target cattle body parts includes: When the preset position is the back of the railing, the cow body part features at least include the cow buttocks features and the cow trunk features; Determine whether the cow body part features only include the cow buttocks features and the cow trunk features: If yes, then determining the cow buttocks feature as the target cow body part feature; Otherwise, continue to detect the next pasture image.
8. The automatic sprinkler control method based on image recognition according to claim 1, characterized in that: The step of screening the characteristics of the cattle body parts according to the preset positions to determine the characteristics of the target cattle body parts includes: When the preset position is the front view of the railing, the cow body part features include cow head features; Determine whether the bull head feature is at the preset railing bottom line position: If yes, then the cow head feature is determined to be the target cow body part feature; Otherwise, continue to detect the next pasture image.
9. The automatic sprinkler control method based on image recognition according to claim 1, characterized in that: The method of determining the position of the cow according to the characteristics of the target cow body part, and selecting and opening the corresponding nozzle for spraying includes: Extract the coordinates of the center point of the cattle body part feature in the pasture image; According to a preset conversion rule, the coordinates of the center point are converted into actual coordinates, and the deviation angle of the center point relative to the camera is calculated in combination with a preset camera viewing angle; Based on the deviation angle, the corresponding nozzle is selected and opened for spraying according to a preset mapping rule.
10. An automatic sprinkler control system based on image recognition, characterized in that: The system comprises: A data acquisition module, used to acquire a pasture image taken from a preset position; wherein the preset position is the side, back or front of a fence in the pasture; A feature extraction module is used to input the pasture image into a corresponding image recognition model according to the preset position, and identify the features of the cattle body parts from the pasture image; wherein the features of the cattle body parts include features of the cattle head, features of the cattle buttocks and / or features of the cattle trunk; A part feature determination module, used to screen the cattle body part features according to the preset position to determine the target cattle body part features; The spray module is used to determine the position of the cow according to the characteristics of the target cow body part, and select and open the corresponding spray head for spraying.
11. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the automatic sprinkler control method based on image recognition as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer is enabled to execute the automatic sprinkler control method based on image recognition as described in any one of claims 1 to 9.
Citation Information
Cited By
Non-contact cattle rumen filling degree detection device and detection method
CN119908709A