Method, device and electronic equipment for recognizing a cow teat

By performing preliminary identification and preprocessing on the initial image of cow teats, target detection boxes that meet the conditions are selected, and the neighborhood gray-level gradient of pixels is calculated and matched with the shape of the teat. This solves the problem of inaccurate cow teat identification and improves the accuracy and efficiency of identification.

CN122157300APending Publication Date: 2026-06-05BEIJING UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING UNIV OF TECH
Filing Date
2026-01-12
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies often fail to accurately identify cow teats, increasing the difficulty of automatic cup application and reducing work efficiency.

Method used

By performing preliminary identification on the initial image of the target part of the cow, a detection box is generated to mark the suspected nipple. Target detection boxes that meet the preset conditions are selected, the neighborhood gray-level gradient of the pixel is calculated and matched with the nipple shape, and interference is removed to improve the recognition accuracy.

Benefits of technology

It improves the accuracy of cow teat identification, reduces the difficulty of automatic cup application, and increases work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122157300A_ABST
    Figure CN122157300A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of target recognition, and in particular to a dairy cow teat recognition method, device and electronic equipment, which solves the technical problem of inaccurate dairy cow teat recognition in the prior art, increases the difficulty of automatic cupping, and reduces work efficiency. The present application provides a dairy cow teat recognition method, which preliminarily recognizes an initial image including a target part of a dairy cow, marks the detected suspected teat part with a detection frame; then determines a target detection frame in which the target meets a preset condition in the detection frame according to a preset condition, to eliminate interference such as suspected teat tumors and dirt; finally, edge pixel points in the target detection frame are recognized, and then the shape formed by the edge pixel points is matched with a preset shape of a teat. If the matching is successful, it is determined that the dairy cow's teat is recognized in the target image, the accuracy of the recognition result is improved, the difficulty of automatic cupping is reduced, and the work efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of target recognition technology, and more specifically, to a method, apparatus, and electronic device for recognizing cow teats. Background Technology

[0002] Milking is a labor-intensive and demanding task in dairy farming. Manual milking is inefficient and costly. Introducing automatic teat-setting equipment can improve efficiency, as accurate teat identification reduces the time required for automatic teat setting. However, the complex environment of dairy farms, the presence of protruding areas such as nodules or blood vessels in the udder, the distinctive markings on the cow's body, and dirt can all interfere with teat identification, leading to inaccurate teat recognition, increasing the difficulty of automatic teat setting, and ultimately reducing efficiency. Summary of the Invention

[0003] The purpose of this invention is to provide a method, device, and electronic device for identifying cow teats, which solves the technical problem in the prior art that the identification of cow teats is inaccurate, which increases the difficulty of automatic teat application and thus reduces work efficiency.

[0004] As a first aspect of the present invention, the present invention provides a method for identifying cow teats, comprising: An initial image including the target part of the cow is initially identified to generate a preliminary identification image. The preliminary identification image includes a target image surrounded by multiple detection boxes, and the target image includes a suspected nipple. Target detection boxes are selected from multiple detection boxes based on preset conditions; Calculate the neighborhood grayscale gradient of the pixels in the target image enclosed by the target detection box, and determine the pixels whose neighborhood grayscale gradient is greater than a preset gradient as edge pixels; When the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's teat is greater than or equal to the preset matching degree, it is determined that the target image contains the cow's teat.

[0005] In one embodiment of the present invention, the step of filtering out a target detection box from multiple detection boxes according to preset conditions includes: When the size of the detection frame meets the preset size condition, the detection frame is determined to be the target detection frame; and / or When the number of pixels included within the detection box is greater than a preset number, the detection box is determined to be a target detection box; and / or The number of target detection boxes is less than or equal to 4.

[0006] In one embodiment of the present invention, the preset size condition includes: the ratio of length to width is greater than 1.3 and less than 3.5. In one embodiment of the present invention, the preset quantity is greater than or equal to 60.

[0007] In one embodiment of the present invention, the identification method further includes: Preprocess the initial image, including the target parts of the cow; The process involves preliminary identification of the initial image, including target parts of the cow, based on a preset detection bounding box, including: Based on a preset detection box, the initial image after preprocessing, including the target parts of the cow, is initially identified.

[0008] In one embodiment of the present invention, the preprocessing of the initial image including the target part of the cow includes: Extract the pixel grayscale values ​​of the pixels in the initial image; Perform a logarithmic transformation on the pixel grayscale values.

[0009] In one embodiment of the present invention, the preprocessing of the initial image including the target part of the cow includes: The initial image is subjected to dynamic exponential filtering and median filtering.

[0010] As a second aspect of the present invention, the present invention also provides a device for identifying cow teats, comprising: An initial identification module is used to perform preliminary identification on an initial image including target parts of a cow and generate a preliminary identification image. The preliminary identification image includes a target image surrounded by multiple detection boxes, and the target image includes a suspected nipple. The feature recognition module is used to filter out target detection boxes from multiple detection boxes according to preset conditions; calculate the neighborhood gray-level gradient of the pixels in the target image surrounded by the target detection box, and determine the pixels whose neighborhood gray-level gradient is greater than the preset gradient as edge pixels; and determine that there is a cow's nipple in the image when the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's nipple is greater than or equal to the preset matching degree.

[0011] In one embodiment of the present invention, the identification device further includes: The preprocessing module is used to preprocess the initial image, including the target parts of the cow.

[0012] As a third aspect of the present invention, the present invention also provides an electronic device, comprising: The processor and memory, wherein the memory stores a computer program, and when the processor executes the computer program, it performs the aforementioned method for identifying cow teats.

[0013] This invention provides a method for identifying cow teats. First, an initial image including the target area of ​​the cow is preliminarily identified, and suspected teats are marked with detection boxes. Then, a target detection box matching the preset conditions is determined within the detection box to remove interference such as nodules and dirt. Finally, edge pixels are identified within the target detection box, and the shape formed by these edge pixels is matched with a preset shape of the teat. If the match is successful, the cow teat is identified in the target image within the target detection box. This method improves the accuracy of the identification results, reduces the difficulty of automatic teat placement, and increases work efficiency. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0015] Figure 1 The diagram shown is a flowchart illustrating a method for identifying cow teats according to an embodiment of the present invention.

[0016] Figure 2 The diagram shown is a flowchart illustrating a method for identifying cow teats according to another embodiment of the present invention.

[0017] Figure 3 The diagram shown is a working block diagram of a cow's teat recognition device according to an embodiment of the present invention.

[0018] Figure 4 The diagram shown is a working block diagram of a cow's nipple recognition device according to another embodiment.

[0019] Figure 5 The diagram shown is a block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0020] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] In the description of this invention, it should be noted that the terms "upper", "lower", "front", "horizontal", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0022] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the term "installation" should be interpreted broadly. For example, it can refer to a fixed connection, a detachable connection, or an integral connection; it can refer to a mechanical connection or an electrical connection; it can refer to a direct connection or an indirect connection through an intermediate medium; it can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0023] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings.

[0024] As a first aspect of the present invention, the present invention provides a method for identifying cow teats. Figure 1 The diagram shown is a flowchart illustrating a method for identifying cow teats according to an embodiment of the present invention. Figure 1 As shown, a method for identifying cow teats includes the following steps S100-S400: S100: Perform preliminary identification on an initial image including the target part of the cow and generate a preliminary identification image. The preliminary identification image includes the target image surrounded by multiple detection boxes, and the target image includes a suspected nipple. Specifically, the initial image is a depth map, which reflects the actual physical distance from each point in the captured scene to the camera. Correspondingly, the camera used in this invention is a depth camera capable of outputting a depth map, such as a binocular camera (which simultaneously captures the same object using two cameras, then uses computer algorithms to calculate the parallax between the two cameras to obtain the object's depth information), a structured light camera (which actively emits a light source, such as an infrared laser, through a projector to illuminate the object's surface, and captures the reflected light through the camera lens), and a TOF (Time-of-Flight) camera (which emits a processed beam of light that reflects back after hitting an object; the time of the round trip is captured, and the distance to the object is calculated based on the known speed of light and the wavelength of the modulated light).

[0025] After initial images of the target areas, including the cow's nipples, are captured using a depth camera, these images are input into a pre-built preliminary recognition model to generate a preliminary recognition image. The preliminary recognition model performs initial identification on the initial image and marks suspected nipple areas with bounding boxes. The preliminary recognition image output by the model includes multiple bounding boxes, each enclosing a portion of the target image, which contains the suspected nipples. In other words, all suspected nipple areas in the preliminary recognition image output by the model are marked.

[0026] Specifically, during the initial identification of the initial image, as long as a suspected nipple is detected, the detected suspected nipple can be marked with a detection box. Therefore, the size of each detection box included in the output initial identification image may be the same or different.

[0027] S200: Select the target detection box from multiple detection boxes according to preset conditions; Because dairy cows may have protruding areas such as tumors or protruding blood vessels in their udder area, and their bodies may have patterns and dirt, tumors, protruding blood vessels, patterns, dirt, etc., can all be identified and marked by detection boxes when performing preliminary identification on the initial image.

[0028] Therefore, step S200 involves further selecting the target detection box from multiple detection boxes based on preset conditions, thus further filtering.

[0029] Optionally, the preset conditions include at least one of the following three conditions: (1) When the size of the detection frame meets the preset size conditions, the detection frame is determined as the target detection frame; Specifically, the preset size conditions can be achieved by taking images of multiple target parts of the cows with a camera, manually marking the images, and determining the reference size for each reference detection box. Then, the preset size is determined based on multiple reference sizes.

[0030] Therefore, by using a detection frame size that meets the preset size to further filter target detection frames, detection frames that do not meet the preset size conditions can be removed, such as suspected nipple dirt.

[0031] Optionally, the length-to-width ratio is greater than 1.3 and less than 3.5. (2) When the number of pixels included in the detection box is greater than the preset number, the detection box is determined to be the target detection box; Specifically, multiple images of target areas of the cow can be captured by a camera, and the images can be manually marked to determine the reference size of each reference detection box. Then, a preset size can be determined based on multiple reference sizes.

[0032] Optional, the preset quantity is greater than or equal to 60.

[0033] A detection box is considered a target detection box if it contains more than 60 pixels. If the number of pixels within the detection box is less than or equal to 60, it indicates a small number of pixels, such as a tumor.

[0034] (3) The number of target detection boxes is less than or equal to 4.

[0035] Since a cow can have a maximum of four teats, the number of object detection boxes is limited to four or less.

[0036] S300: Calculate the neighborhood gray-level gradient of the pixels in the target image enclosed by the target detection box, and determine the pixels whose neighborhood gray-level gradient is greater than the preset gradient as edge pixels. After the target detection box is selected, the target image within the target detection box may not include the cow's teat. Therefore, it is necessary to further identify the target image within the target detection box, i.e., to execute S300 and S400.

[0037] Specifically, a neighborhood refers to a small window such as a 3x3 or 5x5 window centered on a pixel.

[0038] The gray-level gradient refers to the gradient of the image function I(x, y) at the point (x, y). The gray-level gradient is a vector.

[0039] The neighborhood grayscale gradient of a pixel refers to the rate of change (i.e., the degree and direction of change) of the grayscale value of a pixel relative to its surrounding pixels.

[0040] A tiny "detector" (convolution kernel) can be used to measure the changes in the horizontal and vertical directions in the neighborhood of a pixel to obtain the gray-level gradient of the pixel's neighborhood.

[0041] Once the neighborhood grayscale gradient of a pixel is determined, the edge pixels can be determined based on the neighborhood grayscale gradient of each pixel.

[0042] Specifically, edge pixels are determined as follows: pixels whose grayscale gradient in the neighborhood is greater than a preset gradient are identified as edge pixels.

[0043] By determining the edge pixels, the shape of the object included in the target image within the target detection box is determined, and the shape of the object is formed by connecting multiple edge pixels.

[0044] S400: When the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's teat is greater than or equal to the preset matching degree, it is determined that the cow's teat exists in the image.

[0045] When the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's nipple is greater than or equal to the preset matching degree, it means that the shape of the object in the target image in the target detection box is the same as the preset shape of the cow's nipple, and it can be determined that there is a cow's nipple in the target image.

[0046] This invention provides a method for identifying cow teats. First, an initial image including the target area of ​​the cow is preliminarily identified, and suspected teats are marked with detection boxes. Then, a target detection box matching the preset conditions is determined within the detection box to remove interference such as nodules and dirt. Finally, edge pixels are identified within the target detection box, and the shape formed by these edge pixels is matched with a preset shape of the teat. If the match is successful, the cow teat is identified in the target image within the target detection box. This method improves the accuracy of the identification results, reduces the difficulty of automatic teat placement, and increases work efficiency.

[0047] In another embodiment of the invention, such as Figure 2 As shown, before S100 (performing preliminary identification of the initial image including the target part of the cow and generating a preliminary identification image), the identification method further includes the following step S110: S110: Preprocess the initial image including the target parts of the cow; Correspondingly, S100 (performing preliminary identification of the initial image including the target parts of the cow and generating a preliminary identification image) includes: Preliminary identification is performed on the preprocessed images, including the target parts of the cow, to generate preliminary identification images.

[0048] Preprocessing the initial image can further remove cluttered point clouds, reducing the computational load and accuracy in subsequent recognition processes.

[0049] Optionally, S110 (preprocessing the initial image including the target parts of the cow) specifically includes the following steps S111-S112: S111: Extract the pixel grayscale values ​​of pixels in the initial image; Specifically, you can directly read the pixel grayscale values ​​of the pixels in the initial image stored in the camera. S112: Perform logarithmic transformation on pixel grayscale values; Specifically, the formula for the logarithmic transformation of pixel grayscale values ​​is as follows: Formula 1: Formula 1 In Formula 1, These are the pixel grayscale values ​​before logarithmic transformation. represents the pixel grayscale value after logarithmic transformation, k and b are the brightness gain and grayscale fine-tuning offset parameters, respectively, and α is the normalization coefficient used to map the logarithmic output to the range of 0~255.

[0050] The formula for calculating α is Formula 2: Formula 2 After performing a logarithmic transformation on the pixel grayscale value, the transformed pixel grayscale value can be calculated. Then, based on the changed pixel grayscale values... Determine the output pixel grayscale value. The output pixel grayscale value is:

[0051] in, This is for outputting pixel grayscale values.

[0052] After performing a logarithmic transformation on the pixel grayscale values, the image dark areas are significantly stretched, and the bright areas are also compressed, making it less prone to overexposure. This reduces the difference in grayscale values ​​of the nipple at different distances, allowing for clear display. Even images taken from a distance remain relatively dark, without affecting recognition and detection.

[0053] It should be noted that by shortening the camera's default exposure time, pixels with excessive depth values ​​(too far away) can be removed (for example, in the working condition, all data points within 1m of the nipple and beyond 1m are filtered out) and artifacts (a large number of cluttered point clouds formed due to the obstruction of objects in front and behind).

[0054] Optionally, S110 (preprocessing the initial image including the target parts of the cow) specifically includes the following steps S113-S114: S113: Perform dynamic exponential filtering on the initial image to generate the first image; Specifically, methods for performing dynamic exponential filtering on the initial image include: (1) Calculate the local features (e.g., gradient or variance) of each pixel in the initial image. (2) Obtain the pixel value of the pixel after the previous filtering. (3) Calculate and output the new pixel value of the pixel based on the current pixel value, the smoothing factor and the pixel value of the pixel after the last filtering.

[0055] The calculation formula is:

[0056] In the formula, α is the smoothing factor. The new pixel value for the pixel. The current pixel value of the pixel. This represents the pixel value of the pixel after the previous filtering.

[0057] Dynamic exponential filtering can be used to filter out outliers that fluctuate significantly over time, thereby improving the information quality of the image.

[0058] S114: Perform median filtering on the first image.

[0059] Specifically, the median filtering process includes the following steps: (1) Define the second sliding window; Specifically, the second sliding window can be an odd number of sizes such as 3×3 or 5×5.

[0060] (2) Sort the pixel values ​​in the window by size.

[0061] Sort the pixel values ​​in the window by size and take the middle pixel value in the sort.

[0062] (3) Take the middle value after sorting as the new pixel value of the center pixel of the window.

[0063] The new pixel value of the center pixel in the window is determined as the middle pixel value in the sorting obtained in (2).

[0064] (4) Slide the window to the entire image.

[0065] The second image is generated after the window is slid across the entire first image. Median filtering can be used to eliminate abnormally high or low noise effects.

[0066] Exemplary identification device As a second aspect of the invention, the invention also provides a device for identifying cow teats. Figure 3 The diagram shown is a working block diagram of a cow teat identification device according to an embodiment of the present invention. Figure 3 As shown, a cow teat identification device 1 includes: The initial recognition module 10 is used to perform preliminary recognition on an initial image including the target part of the cow and generate a preliminary recognition image. The preliminary recognition image includes a target image surrounded by multiple detection boxes, and the target image includes a suspected nipple. Specifically, the initial identification module 10 is used to perform S100 in the above-described method for identifying cow teats (to perform preliminary identification on an initial image including the target part of the cow, and generate a preliminary identification image, which includes a target image surrounded by multiple detection boxes, and the target image includes a suspected teat).

[0067] The feature recognition module 20 is used to filter out target detection boxes from multiple detection boxes according to preset conditions; calculate the neighborhood gray-level gradient of the pixels in the target image surrounded by the target detection box, and determine the pixels whose neighborhood gray-level gradient is greater than the preset gradient as edge pixels; and determine that there is a cow's nipple in the image when the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's nipple is greater than or equal to the preset matching degree.

[0068] Specifically, the feature recognition module 20 is used to execute S200 (selecting target detection boxes from multiple detection boxes according to preset conditions), S300 (calculating the neighborhood gray-level gradient of the pixels in the target image surrounded by the target detection box, and determining the pixels with a neighborhood gray-level gradient greater than the preset gradient as edge pixels) and S400 (determining that there is a cow's nipple in the image when the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's nipple is greater than or equal to the preset matching degree).

[0069] This invention provides a device for identifying cow teats. First, an initial image including the target area of ​​the cow is preliminarily identified, and suspected teats are marked with detection boxes. Then, a target detection box matching the preset conditions is determined within the detection box to remove interference such as nodules and dirt. Finally, edge pixels are identified within the target detection box, and the shape formed by these edge pixels is matched with a preset shape of the teat. If the match is successful, the cow teat is identified in the target image within the target detection box. This improves the accuracy of the identification results, thereby reducing the difficulty of automatic teat placement and increasing work efficiency.

[0070] Optional, such as Figure 4 As shown, the cow teat identification device also includes: The preprocessing module 30 is used to preprocess the initial image, including the target parts of the cow.

[0071] The present invention preprocesses the initial image through the preprocessing module 30, which can further remove the cluttered point cloud in the initial image and reduce the amount of computation and the accuracy of computation in the subsequent recognition process.

[0072] Exemplary electronic devices As a third aspect of the present invention, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the processor executes the computer program, it executes the above-described method for identifying cow teats.

[0073] Specifically, the internal structure of electronic devices can be as follows: Figure 5As shown, the electronic device includes a processor, a memory, a network interface, and an input device connected via a device bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores operating devices and computer programs. The internal memory provides an environment for the operation of the operating devices and computer programs stored in the non-volatile storage medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it follows the steps of the method for identifying cow teats according to various embodiments of this specification as described in the above embodiments.

[0074] The processor may include the main processor, as well as baseband chips, modems, etc.

[0075] The memory stores a program that executes the technical solution of this invention, and may also store operating devices and other key business functions. Specifically, the program may include program code, which includes computer operation instructions. More specifically, the memory may include read-only memory (ROM), other types of static storage devices capable of storing static information and instructions, random access memory (RAM), other types of dynamic storage devices capable of storing information and instructions, disk storage, flash memory, etc.

[0076] The processor can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0077] Input devices may include devices that receive data and information input by the user, such as keyboards, mice, cameras, scanners, light pens, voice input devices, touch screens, pedometers, or gravity sensors.

[0078] Output devices may include devices that allow information to be output to the user, such as displays, printers, speakers, etc.

[0079] The communication interface may include any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.

[0080] The processor executes the program stored in the memory and calls other devices, which can be used to implement the various steps of the arbitrary cow teat identification method provided in the above embodiments of this specification.

[0081] The electronic device may also include a display component and a voice component. The display component may be a liquid crystal display screen or an e-ink display screen. The input device of the electronic device may be a touch layer covering the display component, or a button, trackball or touchpad set on the casing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0082] Those skilled in the art will understand that Figure 5 The structures shown are merely block diagrams of some structures related to the solutions in this specification and do not constitute a limitation on the electronic devices to which the solutions in this specification are applied. Specific electronic devices may include more or fewer components than those shown in the figures, or may combine certain components, or may have different component arrangements.

[0083] Exemplary computer program products and storage media In addition to the methods and devices described above, the ion implantation control method provided in the embodiments of this specification can also be a computer program product, which includes computer program instructions that, when executed by a processor, cause the processor to perform the steps in the method for identifying cow teats according to various embodiments of this specification as described in the "Exemplary Methods" section above.

[0084] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0085] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this specification. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages.

[0086] Furthermore, embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor of the steps in the method for identifying cow teats according to various embodiments of this specification as described in the "Exemplary Methods" section above.

[0087] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this specification can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0088] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0089] The embodiments described above are merely illustrative of several implementation methods outlined in this specification. While the descriptions are specific and detailed, they should not be construed as limiting the scope of the solutions provided in this specification. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this specification, and these all fall within the scope of protection of this specification. Therefore, the scope of protection for this patent should be determined by the appended claims.

Claims

1. A method for identifying cow teats, characterized in that, include: An initial image including the target part of the cow is initially identified to generate a preliminary identification image. The preliminary identification image includes a target image surrounded by multiple detection boxes, and the target image includes a suspected nipple. Target detection boxes are selected from multiple detection boxes based on preset conditions; Calculate the neighborhood grayscale gradient of the pixels in the target image enclosed by the target detection box, and determine the pixels whose neighborhood grayscale gradient is greater than a preset gradient as edge pixels; When the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's teat is greater than or equal to the preset matching degree, it is determined that the target image contains the cow's teat.

2. The identification method according to claim 1, characterized in that, The step of filtering target detection boxes from multiple detection boxes according to preset conditions includes: When the size of the detection frame meets the preset size condition, the detection frame is determined to be the target detection frame; and / or When the number of pixels included within the detection box is greater than a preset number, the detection box is determined to be a target detection box; and / or The number of target detection boxes is less than or equal to 4.

3. The identification method according to claim 2, characterized in that, The preset size conditions include: the ratio of length to width is greater than 1.3 and less than 3.

5.

4. The identification method according to claim 1, characterized in that, The preset quantity is greater than or equal to 60.

5. The identification method according to claim 1, characterized in that, Also includes: Preprocess the initial image, including the target parts of the cow; The process involves preliminary identification of the initial image, including target parts of the cow, based on a preset detection bounding box, including: Based on a preset detection box, the initial image after preprocessing, including the target parts of the cow, is initially identified.

6. The identification method according to claim 5, characterized in that, The preprocessing of the initial image, including the target parts of the cow, includes: Extract the pixel grayscale values ​​of the pixels in the initial image; Perform a logarithmic transformation on the pixel grayscale values.

7. The identification method according to claim 5, characterized in that, The preprocessing of the initial image, including the target parts of the cow, includes: The initial image is subjected to dynamic exponential filtering and median filtering.

8. A device for identifying cow teats, characterized in that, include: An initial identification module is used to perform preliminary identification on an initial image including target parts of a cow and generate a preliminary identification image. The preliminary identification image includes a target image surrounded by multiple detection boxes, and the target image includes a suspected nipple. The feature recognition module is used to filter out target detection boxes from multiple detection boxes according to preset conditions; Calculate the neighborhood grayscale gradient of the pixels in the target image enclosed by the target detection box, and determine the pixels whose neighborhood grayscale gradient is greater than a preset gradient as edge pixels; and determine that the image contains a cow's nipple when the matching degree between the shape formed by multiple edge pixels and the preset shape of the cow's nipple is greater than or equal to the preset matching degree.

9. The identification device according to claim 8, characterized in that, Also includes: The preprocessing module is used to preprocess the initial image, including the target parts of the cow.

10. An electronic device, characterized in that, include: The processor and memory, wherein the memory stores a computer program, and when the processor executes the computer program, it performs the method for identifying cow teats as described in any one of claims 1-7.