Method, device, medium and product for automatic recognition of dairy farm breeding manual records

CN120071357BActive Publication Date: 2026-10-16INST OF ANIMAL SCI & VETERINARY MEDICINE SHANDONG ACADEMY OF AGRI SCI +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411957357.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2026-10-16
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

而纸质材料的临时保存不便于长期利用,且有丢失的可能,人工录入不仅需要工作人员,增加工作量,且存在可能录入不规范甚至错误的可能性,且养殖场养殖动物数量很多,记录信息量大,导致工作人员负担沉重

Benefits of technology

[0045] This application provides an automatic recognition method, device, medium, and product for manual records of dairy farm breeding. The method involves denoising, binarizing, and skew-correcting the original image; using connected component analysis to determine the text region in the preprocessed image; segmenting the text region into multiple single-character images; inputting each single-character image into a character recognition model; generating a pending recognition document from the character recognition results of all single-character images; and post-processing the pending recognition document to obtain an automatically recognized document of the manual records of dairy farm breeding. By improving the character recognition model, the automation level of text recognition in dairy farm breeding data is enhanced, thereby improving the standardization, accuracy, and efficiency of the text entry process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120071357B_ABST
    Figure CN120071357B_ABST
Patent Text Reader

Abstract

The application discloses a dairy farm breeding artificial record automatic identification method, device, medium and product, relates to the character recognition technical field, and the method comprises the following steps: determining the character region in the pretreatment image by using the connected domain analysis method; the character region is divided into a plurality of single character images; the current single character image is input into a character recognition model to obtain a character recognition result; the character recognition model is obtained by training the CNN model by using a plurality of single character training images; based on the character recognition result of all single character images, a to-be-determined recognition document is generated; the to-be-determined recognition document is post-processed to obtain the automatic identification document of the dairy farm breeding artificial record; the application realizes the automatic identification of the handwritten content by recognizing and dividing the character region and the character recognition model, and further improves the standardization, accuracy and work efficiency of information input.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of character recognition technology, and in particular to an automatic recognition method, equipment, medium and product for manual records of dairy farm breeding. Background Technology

[0002] Continuously and effectively obtaining individual dairy cow breeding data is fundamental to the continuous innovation and genetic improvement of dairy cow germplasm. Dairy farms typically record breeding data for individual dairy cows, such as reproduction data, manually on paper, temporarily stored, or manually entered into computers for future storage or sharing. Temporary storage of paper materials is inconvenient for long-term use and carries the risk of loss. Manual entry not only requires staff and increases workload but also carries the risk of inaccurate or incorrect data entry. Furthermore, the large number of animals and the large volume of information on farms place a heavy burden on staff. With the application of Optical Character Recognition (OCR) in various fields, the development of a system that allows for the direct digitization of dairy cow breeding data during manual recording would undoubtedly improve the efficiency, accuracy, and standardization of data recording for frontline dairy farm staff. This would significantly enhance the acquisition of standardized, accurate, and regulated breeding data. Summary of the Invention

[0003] The purpose of this application is to provide an automatic identification method, equipment, medium, and product for manual breeding records in dairy farms, which can realize the automatic identification of handwritten breeding data records, thereby improving the standardization, accuracy, and efficiency of information entry.

[0004] To achieve the above objectives, this application provides the following solution:

[0005] Firstly, this application provides an automatic identification method for manual breeding records in dairy farms, including:

[0006] Acquire the original image; the original image includes multiple handwritten characters;

[0007] The original image is preprocessed to obtain a preprocessed image; the preprocessing includes: noise reduction, binarization, and tilt correction.

[0008] The text regions in the preprocessed image are determined using connected component analysis.

[0009] The text region is divided into multiple single-character images;

[0010] Select any single-character image as the current single-character image;

[0011] The current single-character image is input into the character recognition model to obtain the character recognition result; the character recognition model is obtained by training a CNN model using multiple single-character training images;

[0012] Update the current single-character image and return to the step "Input the current single-character image into the character recognition model to obtain the character recognition result" until all single-character training images are traversed to obtain the character recognition result for each single-character image;

[0013] Based on the character recognition results of all single-character images, generate a document to be recognized;

[0014] The unidentified identification document is post-processed to obtain an automatically identified document of the dairy farm breeding manual record; the post-processing includes error correction and formatting.

[0015] Optionally, the noise reduction process employs Gaussian filtering or median filtering.

[0016] The tilt correction process employs an edge detection algorithm and the Hough transform method.

[0017] Optionally, connected component analysis is used to determine the text regions in the preprocessed image, including:

[0018] A search algorithm is used to determine multiple initial connected regions in the preprocessed image; the search algorithm is either depth-first search or breadth-first search.

[0019] An expansion operation is performed on each of the initial connected domains to obtain multiple expanded connected domains; the number of expanded connected domains is less than or equal to the number of the initial connected domains.

[0020] Each expanded connected component is subjected to an erosion operation to obtain multiple eroded connected components; the number of eroded connected components is equal to the number of expanded connected components.

[0021] Determine the area of ​​each eroded connected region; the area of ​​any eroded connected region is equal to the number of all pixels in the eroded connected region;

[0022] Deleting eroded connected components with an area smaller than a preset area yields multiple first connected components.

[0023] Determine the aspect ratio of each first connected component;

[0024] Delete the first connected component whose aspect ratio does not conform to the preset aspect ratio range to obtain multiple second connected components;

[0025] Determine the bounding rectangle of each second connected component; determine all bounding rectangles.

[0026] The set of pixels within all bounding rectangles is determined as the text region in the preprocessed image.

[0027] Optionally, the text region is segmented into multiple single-character images using connected component analysis, including:

[0028] Determine the vertical projection map of the text region; the vertical projection map includes the vertical projection value of each column in the text region; any vertical projection value is the number of all pixels with a grayscale value of 0 in the corresponding column of the text region;

[0029] Columns in a text area whose vertical projection value is less than a preset vertical projection value are designated as character intervals;

[0030] Delete all character intervals in the text region to obtain multiple images of single characters to be determined.

[0031] Optionally, after deleting all character intervals in the text region to obtain multiple images of the single character to be determined, the method further includes:

[0032] Each undetermined single-character image is adjusted to a preset size to obtain each single-character image.

[0033] Optionally, before acquiring the original image, the following steps are also included:

[0034] Acquire multiple training images; the training images include multiple handwritten characters;

[0035] Multiple training images are preprocessed to obtain multiple preprocessed training images;

[0036] Connected component analysis was used to determine the text regions in each preprocessed training image;

[0037] Each preprocessed training image is divided into multiple single-character training images; the size of each single-character training image is a preset size.

[0038] Label the characters in each single-character training image;

[0039] A character recognition model is obtained by training a single character image as input and outputting the characters from the single character training image.

[0040] Optionally, the CNN model includes an input layer, a convolutional layer, an activation layer, a pooling layer, a fully connected layer, and an output layer connected in sequence.

[0041] Secondly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described method for automatic identification of manual breeding records in dairy farms.

[0042] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned method for automatic identification of manual records in dairy farm breeding.

[0043] Fourthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-mentioned method for automatically identifying manual records of dairy farm breeding.

[0044] According to the specific embodiments provided in this application, the following technical effects are disclosed:

[0045] This application provides an automatic recognition method, device, medium, and product for manual records of dairy farm breeding. The method involves denoising, binarizing, and skew-correcting the original image; using connected component analysis to determine the text region in the preprocessed image; segmenting the text region into multiple single-character images; inputting each single-character image into a character recognition model; generating a pending recognition document from the character recognition results of all single-character images; and post-processing the pending recognition document to obtain an automatically recognized document of the manual records of dairy farm breeding. By improving the character recognition model, the automation level of text recognition in dairy farm breeding data is enhanced, thereby improving the standardization, accuracy, and efficiency of the text entry process. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 This is a schematic diagram of a dot-matrix digital pen in one embodiment of this application;

[0048] Figure 2 This is an example diagram illustrating the use of a digital pen to write milk volume information and store dot matrix information in one embodiment of this application;

[0049] Figure 3 This is a schematic diagram of a mobile terminal of the system connected to a dot-matrix digital pen in one embodiment of this application;

[0050] Figure 4 To generate an electronic handwriting image from dot matrix information in one embodiment of this application;

[0051] Figure 5 This is a flowchart of an automatic identification method for manual records of dairy farm breeding in one embodiment of this application. Detailed Implementation

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

[0053] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0054] In one exemplary embodiment, an automatic identification method for manual breeding records in dairy farms is provided, which is applied to a dairy farm optical dot matrix identification system.

[0055] The cattle farm optical dot matrix recognition system introduces a dot matrix digital pen (such as...) Figure 1 (As shown). This digital pen incorporates an invisible dot matrix pattern printed on ordinary paper. It can capture the movement trajectory of the pen tip in real time using a built-in high-speed camera and store it as dot matrix information in the digital pen's storage module (e.g., ...). Figure 2 (As shown). This technology makes accurate acquisition of handwritten text possible. After acquiring the handwritten text information, the mobile terminal of the Niuchang Optical Dot Matrix Recognition System connects to a digital pen (such as...) via Bluetooth. Figure 3 As shown), the stored dot matrix information is transmitted to the system. Subsequently, the system uses the developed dot matrix position generation function (such as...) to generate handwritten trajectory images. Figure 4 As shown, the dot matrix information is converted into an electronic handwriting image, realizing the transformation from physical paper to electronic paper. After generating the electronic handwriting image, the system's integrated OCR automatic recognition module for dairy farm breeding manual records can recognize the text information in the image, thereby completing the extraction of handwritten text. After extraction, the system verifies the correctness of the handwritten content and provides prompts for information that does not meet the logical verification, while also providing a manual modification function to ensure the accuracy and completeness of the information.

[0056] like Figure 5 As shown in this embodiment, an automatic identification method for manual breeding records in dairy farms includes:

[0057] Step 101: Obtain the original image. The original image contains multiple handwritten characters. Use a scanner, digital camera, or other device to convert the document or picture into a digital image.

[0058] Step 102: Preprocess the original image to obtain a preprocessed image. The acquired digital image undergoes denoising, binarization, and tilt correction to improve image quality and lay the foundation for subsequent text recognition.

[0059] Preprocessing includes denoising, binarization, and tilt correction. Denoising is performed using Gaussian filtering or median filtering.

[0060] Gaussian filtering reduces noise in an image by weighted averaging of each pixel while preserving edge smoothness. The steps are as follows:

[0061] 1. Choosing a Gaussian kernel: The core of Gaussian filtering is the Gaussian kernel (or filter), whose shape follows a normal distribution. The formula for the Gaussian function is:

[0062]

[0063] Here, σ is the standard deviation, which controls the width of the Gaussian kernel. Choosing an appropriate standard deviation value will affect the filtering strength. G(x,y) is a Gaussian function, where x and y represent the horizontal and vertical offsets (i.e., coordinates) from the center of the Gaussian kernel to a certain pixel position. They are in pixels, usually starting from the center of the kernel, and take values ​​in the range [-k,k], where k is half the kernel size. For example, if the kernel size is 3×3, the coordinates of the center point are (0,0), and the coordinates of the surrounding points are (-1,-1), (-1,0), (0,-1), etc. e represents the natural constant.

[0064] 2. Construct the Gaussian kernel matrix: Based on the selected standard deviation, construct the mirror K×K Gaussian kernel matrix.

[0065] For example, when K=3 and σ=1, the Gaussian kernel G is as follows:

[0066]

[0067] 3. Image Convolution: Using a Gaussian kernel to perform convolution processing on the image.

[0068] 4. Edge processing: During convolution, the processing of image edges needs to be considered. Common methods include padding (such as zero padding and mirror padding) and cropping.

[0069] 5. Repeat the process: Perform the above convolution operation on the entire image until all pixels have been processed.

[0070] Median filtering is mainly used to remove salt-and-pepper noise. It mainly uses the median of neighboring pixels to replace the current pixel, thereby reducing the impact of noise on the image.

[0071] The implementation steps are as follows:

[0072] 1. Selecting a Neighborhood Window: For each pixel I(i,j) in the image, first select a neighborhood window containing that pixel, typically a K×K square region, where K is an odd number (e.g., 3, 5, 7, etc.). This selection ensures that there is a clearly defined center pixel within the window. In Gaussian filtering, K represents the size (width and height) of the Gaussian kernel matrix, i.e., the size of the filter, usually a square matrix, such as 3×3, 5×5, 7×7, etc.

[0073] 2. Extract neighboring pixel values: Extract all pixel values ​​from the window to form a set X:

[0074]

[0075] Where I(m,n) refers to the pixel value located at coordinates (m,n) in the image, where m represents the horizontal coordinate of the current pixel in the image and n represents the vertical coordinate of the current pixel in the image.

[0076] 3. Sorting: Sort the pixel values ​​in set X to obtain the sorted array X. sorted .

[0077] 4. Calculate the median: Calculate the median Median(I(i,j)) based on the number of pixels n in the window.

[0078] If n is odd:

[0079]

[0080] If n is even:

[0081]

[0082] 5. Replace pixel value: Replace the original pixel I(i,j) value with the calculated median value.

[0083] 6. Repeat the process: Perform the above operation on each pixel in the image until the entire image processing is complete.

[0084] Specifically, the binarization process is as follows: Image binarization is performed using the OTSU algorithm (Great Law Method). This method selects the optimal threshold by maximizing the inter-class variance in order to divide the image into foreground and background.

[0085] The implementation steps are as follows:

[0086] 1. Calculate the image histogram: First, we need to calculate the gray-level histogram H(i) of the input image, representing the number of pixels at each gray level i. If the total number of pixels in this image is N, then the histogram H(i) can be represented as:

[0087]

[0088] Where n(i) is the number of pixels at gray level i.

[0089] 2. Calculate the cumulative probability distribution: Calculate the cumulative probability P(ω) for each gray level:

[0090]

[0091] Where P(ω) represents the cumulative probability distribution from gray level 0 to the current gray level ω; H(i) represents the number of pixels at gray level i; and ω represents the cutoff gray level for the current cumulative calculation.

[0092] 3. Calculate the mean and variance: Calculate the global mean μ of the image:

[0093]

[0094] Where L is the number of gray levels (usually 256).

[0095] 4. Between-class variance: For each possible threshold T, calculate the mean of the foreground and background, and the between-class variance:

[0096]

[0097]

[0098] Where μ1(T) is the average gray level of the background class; μ2(T) is the average gray level of the foreground class; P(T) represents the cumulative probability of the background pixels, that is, the cumulative probability from gray level 0 to the current threshold T; P(L-1) represents the cumulative probability of the foreground pixels, that is, the cumulative probability from gray level T+1 to the maximum gray level L-1.

[0099] Between-class variance for:

[0100]

[0101] 5. Select the optimal threshold: Calculate the inter-class variance of all possible thresholds. The optimal threshold is the one that maximizes the inter-class variance.

[0102] 6. Binarize the image: Use the optimal threshold to binarize the image.

[0103] Specifically, the tilt correction process employs an edge detection algorithm and the Hough transform method.

[0104] The implementation steps are as follows:

[0105] 1. Edge Detection: First, the edge information of the image is extracted using an edge detection algorithm (Canny edge detection). edge The formula for edge detection is:

[0106]

[0107] in, This represents the gradient of the image.

[0108] 2. Parameter Space of the Hough Transform: The Hough transform works by transforming the equation of the line at each edge point into a parameter space. For each edge point (x, y), the line can be represented in polar coordinates:

[0109] r = xcos(θ) + ysin(θ)

[0110] Where r is the distance from the line to the origin, and θ is the angle of the line.

[0111] 3. Accumulator Construction: Create a two-dimensional accumulator array A(r, θ) to record the parameters of each line. For each edge point, calculate r for different values ​​of θ and update the accumulator accordingly.

[0112] A(r,θ)+=1.

[0113] 4. Finding local maxima: By traversing the accumulator, find local maxima and determine the most significant (r, θ) value.

[0114] 5. Calculate the tilt angle: Calculate the tilt angle of the text line based on the found θ value:

[0115] Inclination angle = θ.

[0116] 6. Image Rotation: The calculated tilt angle is used to rotate and correct the image I(x,y) to obtain the corrected image I'(x',y'). The rotation transformation formula is:

[0117] I'(x,y′)=I(x,y).

[0118] Step 103: Use connected component analysis to determine the text regions in the preprocessed image.

[0119] Step 103 includes:

[0120] Step 103-1: Use a search algorithm to determine multiple initial connected regions in the preprocessed image. The search algorithm can be either depth-first search or breadth-first search.

[0121] Step 103-2: Perform expansion operations on all initial connected regions to obtain multiple expanded connected regions. The number of expanded connected regions is less than or equal to the number of initial connected regions.

[0122] Step 103-3: Perform an erosion operation on each dilated connected component to obtain multiple eroded connected components. The number of eroded connected components is equal to the number of dilated connected components.

[0123] Step 103-4: Determine the area of ​​each eroded connected region. The area of ​​any eroded connected region is equal to the number of pixels in the eroded connected region.

[0124] Step 103-5: Delete eroded connected components with an area smaller than the preset area to obtain multiple first connected components.

[0125] Step 103-6: Determine the aspect ratio of each first connected component.

[0126] Step 103-7: Delete the first connected component whose aspect ratio does not conform to the preset aspect ratio range to obtain multiple second connected components.

[0127] Step 103-8: Determine the bounding rectangle of each second connected component. Step 103-9: Determine the set of pixels within all bounding rectangles as the text region in the preprocessed image.

[0128] Specifically, text region detection includes locating text regions in the preprocessed image and excluding non-text regions. That is, after image denoising, binarization, and tilt correction preprocessing, text region recognition is performed.

[0129] The specific steps are as follows:

[0130] 1. Connected component analysis:

[0131] Connectivity between pixels is defined using either 4-connectivity or 8-connectivity. 4-connectivity considers only pixels that are adjacent vertically, horizontally, or vertically, while 8-connectivity also includes diagonally adjacent pixels. Each pixel is traversed using either Depth-First Search (DFS) or Breadth-First Search (BFS), and each connected region is labeled. Starting from unlabeled pixels, DFS is used to find all connected pixels and assigns them the same label.

[0132] 2. Morphological operations:

[0133] Dilation operation: Dilation connects discrete character parts, enhancing the connectivity of regions. The dilation formula is defined as follows:

[0134]

[0135] Where S is the structuring element and D(x,y) is the expanded connected domain.

[0136] Erosion operation: The erosion operation removes small noises and sharpens text edges. The erosion formula is defined as follows:

[0137]

[0138] Where E(x,y) is the eroded connected domain.

[0139] 3. Feature extraction and filtering.

[0140] Area calculation: Calculate the number of pixels (i.e., area) A of each connected region, and filter out regions smaller than a certain threshold.

[0141] A=∑( x,y ) ∈R I(x,y).

[0142] Where R is a connected region.

[0143] Aspect Ratio: Calculates the aspect ratio of a connected region.

[0144] The aspect ratio of connected regions is calculated to extract potential text regions and filter out noise and irrelevant regions.

[0145] Extracting potential text regions: The regularity of text regions, for example, a single Chinese character is close to a square (the aspect ratio is about 1), while English words, number strings or continuous lines of text show a larger aspect ratio.

[0146] Filtering noise and irrelevant areas: Exclude non-text areas, which often have abnormal aspect ratios (e.g., dotted noise, lines, graphics).

[0147] 4. Bounding box generation: Generates bounding boxes for the filtered text area to facilitate subsequent processing.

[0148] Step 104: Segment the text region into multiple single-character images.

[0149] Step 104 includes:

[0150] Step 104-1: Determine the vertical projection map of the text region. The vertical projection map includes the vertical projection values ​​of each column in the text region. Any vertical projection value is the number of all pixels in the corresponding column of the text region with a grayscale value of 0.

[0151] Step 104-2: Determine the columns in the text area whose vertical projection value is less than the preset vertical projection value as character intervals.

[0152] Step 104-3: Delete all character intervals in the text area to obtain multiple images of single characters to be determined.

[0153] Step 104-4: Adjust each undetermined single character image to the preset size to obtain each single character image.

[0154] The text region is segmented into individual characters (or single-character images). This involves using text region detection methods to determine the bounding box information of each text region. Segmenting the text region into individual characters facilitates subsequent character recognition.

[0155] The specific steps are as follows:

[0156] 1. Vertical projection analysis.

[0157] Calculate the vertical projection: Perform a vertical projection on the binarized image of the text region and calculate the number of black pixels in each column. The formula is:

[0158]

[0159] Where P(x) is the projection value of the x-th column, and H is the height of the text region image.

[0160] Character spacing identification: In the projection image, higher values ​​for black pixels indicate the presence of characters, while lower values ​​indicate character gaps. By setting a threshold, the location of character gaps can be identified; typically, areas with smaller projection values ​​are selected as character gaps.

[0161] 2. Character segmentation.

[0162] Determine the cutting positions: Based on the vertical projection diagram, determine the start and end positions of the characters. Local minima can be used to mark the character boundaries.

[0163] Character cutting: Based on the determined start and end positions, each character is cut out from the original text region image to generate an independent character image.

[0164] 3. Output character images.

[0165] Step 105: Determine any single-character image as the current single-character image.

[0166] Step 106: Input the current single-character image into the character recognition model to obtain the character recognition result. The character recognition model is obtained by training a CNN model using multiple single-character training images. The CNN model consists of an input layer, convolutional layer, activation layer, pooling layer, fully connected layer, and output layer connected in sequence.

[0167] Step 107: Update the current single-character image and return to step 106 until all single-character training images have been traversed to obtain the character recognition result for each single-character image.

[0168] Step 108: Generate a document to be identified based on the character recognition results of all single-character images.

[0169] Character features, such as contours and structures, are extracted; these features are then matched with a pre-trained character model to identify the character. Deep learning models are commonly used for character recognition; this embodiment uses a convolutional neural network (CNN) for character recognition.

[0170] Convolutional Neural Networks (CNNs) contain the following hierarchical structure:

[0171] Input layer: Receives the segmented character images, usually grayscale images, with a uniform size (e.g., 28x28 pixels).

[0172] Convolutional layer: Extracts features from the input image using multiple convolutional kernels.

[0173] Activation layer: The ReLU (Rectified LinearUnit) activation function is typically used, with the following formula:

[0174] f(x) = max(0,x).

[0175] Pooling layer: Max pooling is used to reduce the dimensionality of the feature map. The formula for max pooling is:

[0176]

[0177] Where T is the range of the pooling window.

[0178] Fully connected layer: In the final fully connected layer, the feature maps are flattened and connected to the output layer to generate the predicted probability for each character.

[0179] y = W T ·a+b.

[0180] Where W is the weight matrix, b is the bias, and a is the input feature vector.

[0181] Output layer: The Softmax function is used to output the probability distribution of each character category.

[0182] The character recognition model construction process includes: acquiring multiple training images, each containing multiple handwritten characters; preprocessing all training images to obtain preprocessed training images; using connected component analysis to determine the text regions in each preprocessed training image; segmenting each preprocessed training image's text region into multiple single-character training images; ensuring each single-character training image has a preset size; labeling the characters in each single-character training image; and training the CNN model using the single-character training images as input and the characters from those images as output to obtain the character recognition model.

[0183] The model needs to be trained, and the training process includes the following steps:

[0184] 1. Data preparation:

[0185] Dataset: Prepare a dataset containing a large number of labeled character images, each image paired with a corresponding label.

[0186] Data augmentation: To improve the generalization ability of a model, data augmentation can be performed, such as rotation, scaling, translation, and adding noise.

[0187] 2. Define the loss function: The cross-entropy loss function is usually used to measure the difference between the model output and the true label.

[0188] 3. Select an optimization algorithm: Use an optimization algorithm to update the model parameters. The optimization objective is to minimize the loss function.

[0189] 4. Training process:

[0190] Forward propagation: The input image is propagated forward through a CNN to generate the predicted output.

[0191] Calculate the loss: Use the loss function to calculate the loss between the current output and the true label.

[0192] Backpropagation: Calculate the gradient based on the loss and update the model parameters.

[0193] 5. Validation and tuning: After each training cycle, use the validation set to evaluate the model performance and perform hyperparameter tuning (such as learning rate, batch size, etc.) to improve recognition accuracy.

[0194] The steps for character recognition using a trained model are as follows:

[0195] Input character image: Input the segmented character image into the trained CNN model. The image must be the same size as the one used during training, 28×28 pixels.

[0196] Feature extraction: The input image passes through the model's convolutional layers, activation layers, and pooling layers to extract features.

[0197] Output Probabilities: In the output layer, the Softmax function is used to transform the extracted features into a probability distribution for each character category.

[0198] Recognition result: Based on the output probabilities, the category with the highest probability is selected as the recognition result.

[0199] Step 109: Post-process the document to be identified to obtain the automatically identified document of the dairy farm breeding manual record. Post-processing includes error correction and formatting.

[0200] To improve recognition accuracy, the recognized characters are corrected using the following steps:

[0201] 1. Error detection.

[0202] Dictionary-based detection: Dictionary construction: using common vocabulary, industry terminology, or domain-specific dictionaries. Character comparison: comparing each character in the OCR recognition result with words in the dictionary to detect spelling errors. The rationale is that some characters in production tables are impossible to find; for example, a cow's code only contains numbers and cannot contain letters.

[0203] Similarity calculation: Distance metric: The Levenshtein distance method is used to calculate the similarity between the identified character and candidate words in the dictionary to identify possible erroneous characters.

[0204] 2. Generate candidates.

[0205] Generate candidate characters: For each erroneous character identified, generate a set of similar characters as candidates. For example, for "0", candidates such as "o" or "D" can be generated.

[0206] Statistical weighting: Candidate characters are assigned weights based on the frequency of use of each word in the dictionary; the higher the frequency, the greater the weight.

[0207] 3. Corrective decision-making.

[0208] Contextual analysis: Analyze the rationality of candidate characters in the context, use the N-gram language model to evaluate the probability of each candidate character, and select the one with the highest probability as the final replacement.

[0209] Maximum entropy model or deep learning: Combining contextual information and candidate characters, the final character selection is performed using a trained model (such as Long Short-Term Memory Neural Network (LSTM) or Natural Language Processing Model (BERT)).

[0210] 4. Integration results.

[0211] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal. The computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is connected to the system bus via the I / O interfaces. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The I / O interfaces of the computer device are used for exchanging information between the processor and external devices. The communication interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements an automatic identification method for manual records of dairy farm breeding.

[0212] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0213] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0214] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0215] 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, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0216] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0217] 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.

[0218] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. An automatic identification method for manual breeding records in dairy farms, characterized in that, include: Obtain the original image; The original image includes multiple handwritten characters; The original image is preprocessed to obtain a preprocessed image; The preprocessing includes: noise reduction, binarization, and tilt correction. The text regions in the preprocessed image are determined using connected component analysis. The text region is divided into multiple single-character images; Select any single-character image as the current single-character image; The current single-character image is input into the character recognition model to obtain the character recognition result; the character recognition model is obtained by training a CNN model using multiple single-character training images; Update the current single-character image and return to the step "input the current single-character image into the character recognition model to obtain the character recognition result" until all single-character training images are traversed to obtain the character recognition result for each single-character image; Based on the character recognition results of all single-character images, generate a document to be recognized; The unidentified document is post-processed to obtain an automatically identified document of the manual breeding records of the dairy farm; the post-processing includes error correction and formatting. The text region is segmented into multiple single-character images, including: Determine the vertical projection map of the text region; the vertical projection map includes the vertical projection value of each column in the text region; any vertical projection value is the number of all pixels with a grayscale value of 0 in the corresponding column of the text region; Columns in a text area whose vertical projection value is less than a preset vertical projection value are designated as character intervals; Delete all character intervals in the text region to obtain multiple images of single characters to be determined; Each undetermined single-character image is adjusted to a preset size to obtain each single-character image.

2. The automatic identification method for manual breeding records in dairy farms according to claim 1, characterized in that, The noise reduction process employs either Gaussian filtering or median filtering. The tilt correction process employs an edge detection algorithm and the Hough transform method.

3. The automatic identification method for manual breeding records in dairy farms according to claim 1, characterized in that, The text regions in the preprocessed image are determined using connected component analysis, including: A search algorithm is used to determine multiple initial connected regions in the preprocessed image; the search algorithm is either depth-first search or breadth-first search. An expansion operation is performed on each of the initial connected domains to obtain multiple expanded connected domains; the number of expanded connected domains is less than or equal to the number of the initial connected domains. Each expanded connected component is subjected to an erosion operation to obtain multiple eroded connected components; the number of eroded connected components is equal to the number of expanded connected components. Determine the area of ​​each eroded connected region; the area of ​​any eroded connected region is equal to the number of all pixels in the eroded connected region; Deleting eroded connected components with an area smaller than a preset area yields multiple first connected components. Determine the aspect ratio of each first connected component; Delete the first connected component whose aspect ratio does not conform to the preset aspect ratio range to obtain multiple second connected components; Determine the bounding rectangle of each second connected component; The set of pixels within all bounding rectangles is determined as the text region in the preprocessed image.

4. The automatic identification method for manual breeding records in dairy farms according to claim 1, characterized in that, Before acquiring the original image, the following steps are also included: Acquire multiple training images; the training images include multiple handwritten characters; Multiple training images are preprocessed to obtain multiple preprocessed training images; Connected component analysis was used to determine the text regions in each preprocessed training image; Each preprocessed training image is divided into multiple single-character training images; the size of each single-character training image is a preset size. Label the characters in each single-character training image; A character recognition model is obtained by training a single character image as input and outputting the characters from the single character training image.

5. The automatic identification method for manual breeding records in dairy farms according to claim 4, characterized in that, The CNN model comprises an input layer, a convolutional layer, an activation layer, a pooling layer, a fully connected layer, and an output layer connected in sequence.

6. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the automatic identification method for manual records of dairy farm breeding as described in any one of claims 1-5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the automatic identification method for manual breeding records in dairy farms as described in any one of claims 1-5.

8. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the automatic identification method for manual breeding records in dairy farms as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Character recognition method, device and electronic equipment

    CN107977659A

  • Handwriting training sample acquisition method, device and apparatus and medium

    CN108985324A

  • Character recognition method of handwritten meteorological archive data based on deep learning

    CN112052852A