Method for detecting bovine profile image, electronic device and storage medium
By acquiring the shape and texture features of cow side profile images and using a pre-trained model to detect and locate tampered areas, the problem of accurate detection of cow side profile image tampering was solved, ensuring the accuracy of cow identification and transaction data.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- AIEASY
- Filing Date
- 2025-02-05
- Publication Date
- 2026-06-05
AI Technical Summary
Current technology lacks effective means to accurately detect and locate tampering traces in cattle profile images, leading to problems such as incorrect cattle identification information, transaction fraud, and inaccurate breeding data.
By acquiring the shape and texture features of the livestock images to be detected, and using a pre-trained image tampering detection model and region generation network, it is possible to determine whether the image has been tampered with and to locate the tampered region.
It enables accurate tamper detection of cow profile images, ensuring the accuracy of cow identification and transaction data, and improving the data credibility of related industries.
Smart Images

Figure CN122156940A_ABST
Abstract
Description
[0001] This application is a divisional application of application number 202510129576.6, filed on February 5, 2025, entitled "Method, Apparatus, Electronic Device and Storage Medium for Detecting Livestock Images". Technical Field
[0002] This application relates to the field of image detection technology, and in particular to a method, apparatus, electronic device and storage medium for detecting livestock images. Background Technology
[0003] With the rapid development of digital imaging technology, images have been widely used in numerous fields such as agriculture, livestock trading, and food safety traceability. Taking the cattle farming industry as an example, cattle images are frequently used for identification, health monitoring, and breed identification. However, image tampering is becoming increasingly rampant. Malicious alteration of cattle profile images can lead to errors in cattle identification, transaction fraud, and inaccurate farming data, seriously affecting the normal order of related industries and the credibility of data. Currently, there is a lack of effective technical means specifically designed for the accurate detection and localization of tampering traces in cattle profile images. Summary of the Invention
[0004] The purpose of this application is to provide a method, apparatus, electronic device, and storage medium for detecting livestock images to solve the above-mentioned technical problems.
[0005] On the one hand, a method for detecting livestock images is provided, including:
[0006] Obtain target features from the livestock image to be detected; the target features include the shape features of the livestock extracted from the livestock image to be detected and the texture features of the livestock image to be detected;
[0007] Based on the target features, determine whether the livestock image to be detected is a tampered image.
[0008] In one embodiment, the shape features include at least one of the following: the perimeter of the livestock's outer contour, the area of the region enclosed by the outer contour, the circularity of the outer contour, Hu invariant moments, the position of the key parts of the livestock in the image of the livestock to be detected, and the geometric features of the image region corresponding to the key parts; the texture features include at least one of the following: contrast, correlation, energy, and entropy extracted from the gray-level co-occurrence matrix of the image of the livestock to be detected.
[0009] In one embodiment, the method further includes:
[0010] When it is determined that the image of the livestock to be detected is a tampered image, the tampered image region is identified from the image of the livestock to be detected.
[0011] In one embodiment, determining whether the livestock image to be detected is a tampered image based on the target features includes:
[0012] The target features are input into a preset image tampering detection model to obtain the detection result of whether the livestock image to be detected is a tampered image; the image tampering detection model is a model trained based on a training dataset, which includes multiple tampered livestock images and a first category label corresponding to each tampered livestock image, as well as normal livestock images and a second category label corresponding to each normal livestock image.
[0013] In one embodiment, when determining that the livestock image to be detected is a tampered image, determining the tampered image region from the livestock image to be detected includes:
[0014] Using the intermediate layer feature map and the preset region generation network in the image tampering detection model, the tampered image region is determined from the livestock image to be detected.
[0015] In one embodiment, determining whether the livestock image to be detected is a tampered image based on the target features includes:
[0016] Calculate the shape difference value between the shape feature of the livestock image to be detected and the normal shape feature corresponding to the normal livestock image in the preset feature library, and calculate the texture difference value between the texture feature of the livestock image to be detected and the normal texture feature corresponding to the normal livestock image;
[0017] Based on the shape difference value and the texture difference value, it is determined whether the livestock image to be detected is a tampered image.
[0018] In one embodiment, when determining that the livestock image to be detected is a tampered image, determining the tampered image region from the livestock image to be detected includes:
[0019] When the difference between the target feature of a certain image region in the livestock image to be detected and the corresponding normal feature of the normal livestock image in the preset feature library reaches a preset difference threshold, the image region is taken as the target image region.
[0020] Based on the target image region, region expansion processing is performed to obtain the tampered image region in the livestock image to be detected.
[0021] Furthermore, a livestock image detection device is also provided, comprising:
[0022] An acquisition module is used to acquire target features of an image of livestock to be detected; the target features include shape features of the livestock extracted from the image of livestock to be detected and texture features of the image of livestock to be detected;
[0023] The judgment module is used to determine whether the livestock image to be detected is a tampered image based on the target features.
[0024] Furthermore, an electronic device is also provided, including a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement any of the methods described above.
[0025] Furthermore, a computer-readable storage medium is also provided, characterized in that the computer-readable storage medium stores a computer program, which, when executed by at least one processor, implements the method described above.
[0026] The livestock image detection method, apparatus, electronic device, and storage medium provided in this application acquire target features of the livestock image to be detected. The target features include the shape features of the livestock extracted from the livestock image to be detected and the texture features of the livestock image to be detected. Based on the target features, it is determined whether the livestock image to be detected is a tampered image, thereby realizing the detection of whether the livestock image has been tampered with. Attached Figure Description
[0027] Figure 1 A schematic flowchart illustrating the livestock image detection method provided in this application embodiment;
[0028] Figure 2 A schematic diagram of the structure of the livestock image detection device provided in the embodiments of this application;
[0029] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0031] This application provides a method for detecting livestock images. Please refer to [link to relevant documentation]. Figure 1 As shown, it includes:
[0032] S101: Obtain the target features of the livestock image to be detected; the target features include the shape features of the livestock extracted from the livestock image to be detected and the texture features of the livestock image to be detected.
[0033] S102: Determine whether the livestock image to be detected is a tampered image based on the target features.
[0034] The shape features in this embodiment include at least one of the outer contour features of the livestock and features of key parts. Specifically, it includes at least one of the following: the outer contour perimeter of the livestock, the area enclosed by the outer contour, the circularity of the outer contour, Hu invariant moment, the position of the key parts of the livestock in the image of the livestock to be detected, and the geometric features of the image region corresponding to the key parts; the texture features include at least one of the following: contrast, correlation, energy, and entropy extracted from the gray-level co-occurrence matrix of the image of the livestock to be detected.
[0035] In step S101 above, the livestock image to be detected can be preprocessed first, and then the target features can be extracted from the preprocessed livestock image to be detected.
[0036] The preprocessing in this application embodiment includes grayscale processing and filtering and noise reduction processing.
[0037] In the grayscale conversion process, a weighted average method can be used to convert a color image of livestock to a grayscale image. For each pixel in the color image... ,That The values are respectively , , grayscale value The calculation formula is This method can better preserve the brightness information of the image, highlight the outline and texture details of the livestock image to be detected, and reduce the amount of data and computational complexity of subsequent processing.
[0038] In the process of filtering and denoising, Gaussian filtering can be used to smooth grayscale images. The kernel function of Gaussian filtering is... ,in The standard deviation determines the degree of filtering. By sliding this kernel function across the image and performing convolution with the image pixels, Gaussian noise in the image can be effectively removed while preserving the edge information of the image well, making the outline of the livestock image to be detected clearer and providing a more accurate image basis for subsequent feature extraction.
[0039] The outer contour features of livestock images can be extracted using edge detection algorithms.
[0040] Specifically, the Canny edge detection algorithm can be used. For the preprocessed livestock image to be detected, the gradient magnitude and direction can be calculated, edge pixels can be determined through non-maximum suppression, and finally, double threshold detection and edge connection are used to obtain the outer contour edge of the livestock. For example, for an image with a resolution of... In calculating the gradient magnitude of an image, the gradient value of each pixel is approximated by using the partial derivatives in the horizontal and vertical directions. The formula is as follows: ,in and These are the gradient components in the horizontal and vertical directions, respectively.
[0041] Perimeter of the outer contour: Traverse the outer contour points obtained by Canny edge detection, calculate the distance between adjacent outer contour points and sum them to obtain the perimeter of the livestock's outer contour. .
[0042] The area enclosed by the outer contour: The area enclosed by the outer contour can be calculated using Green's formula. Specifically, for points on the contour The area calculation formula is: .
[0043] Outer contour roundness: can be calculated using the formula Calculate the roundness of the outer contour. The closer the value is to 1, the closer the shape is to a circle. This feature can be used to distinguish the outer contour of livestock from other irregular shapes.
[0044] It should be noted that the livestock image to be detected in the embodiments of this application can be a cow side profile image. A cow side profile image has a unique shape, texture, and obvious physiological features such as horns, eyes, and mouth and nose. These features will show specific change patterns during the tampering process, so it can be determined whether the cow side profile image has been tampered with based on these features.
[0045] Hu invariant moments are shape descriptors based on image moments, exhibiting invariance to translation, rotation, and scaling. For image functions... ,That Step moment is defined as Central Moment ,in , Then, calculate the Hu invariant moment based on the central moment. ,in Finally, we obtained the seven invariants of Hu's invariant moments. These invariants can effectively characterize the shape characteristics of livestock in the livestock image to be detected, and are not affected by the translation, rotation and scaling of the image. They can be used to compare with the shape feature library of normal livestock images to detect whether the livestock image to be detected has been tampered with.
[0046] Features of key parts of livestock in an image to be detected can be obtained based on a pre-trained key part detection model. This model can determine the location of the key part in the image and / or the geometric features of the corresponding image region. These geometric features include, but are not limited to, at least one of the following: area, perimeter, length, width, circularity, and curvature of the image region corresponding to the key part.
[0047] This example uses a cow's profile image as an example to illustrate the process. A key feature detection model extracts features from the key features of the cow's profile image. These key features refer to parts that can distinguish the cow's identity, including but not limited to at least one of the cow's eyes, muzzle, and horns.
[0048] This section describes the training process of the key feature detection model. A large number of cow side-face images of different breeds, ages, sexes, and postures are collected. Image annotation tools (such as Label Img) are used to annotate physiological features such as horns, eyes, and muzzle in the images. Annotation information includes the feature location, bounding box coordinates, and category information, constructing a cow side-face physiological feature annotation dataset. Then, a deep learning-based object detection model, such as the Faster R-CNN model, is used for training. First, the base network of Faster R-CNN is initialized on the ImageNet dataset using a pre-trained convolutional neural network (such as VGG16). Then, fine-tuning training is performed on the constructed cow side-face physiological feature annotation dataset. During training, a stochastic gradient descent (SGD) optimizer is used, setting hyperparameters such as learning rate and momentum. The model parameters are adjusted by minimizing a loss function (such as a multi-task loss function, including classification loss and regression loss), enabling the model to accurately detect the location and geometric features of physiological features such as horns, eyes, and muzzle in cow side-face images.
[0049] The cow's profile image to be detected is input into the key feature detection model, and the model outputs the detection results of physiological features, including the location of the key feature, the corresponding category, and geometric features.
[0050] For example, for cow horns, the corresponding position, category label, curvature feature, and length feature can be output. In this embodiment, the curvature of the cow horn contour can be calculated to describe its degree of bending; the length feature can be obtained by calculating the distance between the endpoints of the cow horn contour. For example, for eyes, the corresponding position, category label, aspect ratio, and roundness can be output. The aspect ratio and roundness of the eyes can reflect the shape features of the eyes. For example, for the mouth and nose, the corresponding position, category label, perimeter of the mouth and nose, and area of the mouth and nose can be output.
[0051] In this embodiment, the location and geometric features of the aforementioned key parts can be used to determine whether the image of the livestock to be detected has been tampered with.
[0052] The texture features of normal images and tampered images can differ, so in this embodiment, texture features can also be used to determine whether the livestock image to be detected is a tampered image. The process of extracting texture features is described below.
[0053] In this embodiment of the application, the grayscale image can be divided into: The sub-region can be divided into: The sub-regions are defined. The gray-level co-occurrence matrix is calculated within each sub-region. ,in, The distance between pixel pairs For direction (usually taken) , , , ).
[0054] Extract the following texture feature parameters from the gray-level co-occurrence matrix:
[0055] Contrast: It reflects the clarity of texture and the degree of local change in an image. The greater the contrast, the clearer the texture and the more dramatic the changes in grayscale values in the image.
[0056] Correlation: Correlation measures the similarity of elements in a gray-level co-occurrence matrix in the row or column direction. The closer the values are, the stronger the correlation and the more regular the texture.
[0057] energy: Energy reflects the uniformity of grayscale distribution and the coarseness of texture in an image. The greater the energy, the more uniform the texture and the smoother the image.
[0058] entropy Entropy represents the randomness of texture in an image. The larger the entropy value, the more complex the texture and the higher the information content in the image.
[0059] These texture feature parameters of each sub-region can be combined into a texture feature vector to describe the texture features of the entire livestock image to be detected, so as to perform differential analysis with the texture features of normal livestock images and detect tampering traces.
[0060] In this embodiment of the application, when it is determined that the image of the livestock to be detected is a tampered image, the tampered image area can be determined from the image of the livestock to be detected.
[0061] First, let's explain step S102, which involves determining whether the livestock image to be detected is a tampered image based on the target features.
[0062] In one optional implementation, the target features can be input into a preset tampering image detection model to obtain the detection result of whether the livestock image to be detected is a tampered image; the tampering image detection model is a model trained based on a training dataset, which includes multiple tampered livestock images and a first category label corresponding to each tampered livestock image, as well as normal livestock images and a second category label corresponding to each normal livestock image.
[0063] Specifically, a tampered image detection model can be pre-built. This model can be a convolutional neural network model, consisting of multiple convolutional layers, pooling layers, and fully connected layers. Convolutional layers extract local features from the image, pooling layers perform feature dimensionality reduction, and fully connected layers integrate and classify the extracted features. Within the convolutional layers, appropriate kernel size, stride, and padding are set to effectively extract the image's feature information.
[0064] Then, a training dataset is collected for training. The training dataset includes multiple images of tampered livestock and the first category label corresponding to each tampered livestock image, as well as images of normal livestock and the second category label corresponding to each normal livestock image. The images in the training dataset are preprocessed and feature extracted and then used as input. The first category label and the second category label can be "tampered" and "normal".
[0065] Cross-entropy loss function can be used during model training. Training was conducted. Among other things, For real labels, To predict the probability values for the model, an optimizer (such as the Adam optimizer) is used to train the model, adjusting the model's weights and biases so that the model can accurately learn the feature difference patterns between tampered and normal images. During training, data augmentation techniques, such as flipping, rotating, and cropping, are employed to increase the diversity of training data and improve the model's generalization ability.
[0066] In this embodiment, the target features of the livestock image to be detected are input into the image tampering detection model, which outputs a judgment result of "tampered" or "normal". If the model outputs "tampered", the tampered area can be further located.
[0067] In another optional implementation, the shape difference value between the shape feature of the livestock image to be detected and the normal shape feature corresponding to a normal livestock image in a preset feature library can be calculated, and the texture difference value between the texture feature of the livestock image to be detected and the normal texture feature corresponding to a normal livestock image can be calculated; based on the shape difference value and the texture difference value, it can be determined whether the livestock image to be detected is a tampered image.
[0068] It should be noted that the preset feature library can store the normal shape features and normal texture features corresponding to multiple normal livestock images. In this case, the target features of the livestock image to be detected can be matched with the normal features corresponding to each normal livestock image to determine the target normal livestock image that is closest to the livestock to be detected. The shape difference value between the shape feature of the livestock image to be detected and the normal shape feature corresponding to the target normal livestock image in the preset feature library is calculated, and the texture difference value between the texture feature of the livestock image to be detected and the normal texture feature corresponding to the target normal livestock image is also calculated.
[0069] Specifically, calculating the shape difference value between the shape features of the livestock image to be detected and the normal shape features corresponding to the target normal livestock image in the preset feature library includes:
[0070] Obtain the contour feature vector of the livestock image to be detected and the geometric feature vector corresponding to each key part. Calculate the first distance between the contour feature vector and the normal contour feature vector corresponding to the target normal livestock image. Use the first distance as the first shape difference value. Calculate the second distance between the geometric feature vector of each key part and the normal geometric feature vector of the corresponding key part in the target normal livestock image. Use each second distance as the second shape difference value.
[0071] Calculating the texture difference value between the texture features of the livestock image to be detected and the normal texture features corresponding to the target normal livestock image includes:
[0072] Obtain the texture feature vector of the livestock image to be detected, calculate the third distance between the texture feature vector and the normal texture feature vector corresponding to the target normal livestock image, and use the third distance as the texture difference value.
[0073] The step of determining whether the livestock image to be detected is a tampered image based on the shape difference value and the texture difference value includes:
[0074] When the first shape difference value, the second shape difference value, and the texture difference value meet a preset condition, the livestock image to be detected is determined to be a tampered image; otherwise, the livestock image to be detected is determined not to be a tampered image. The preset condition includes at least one of the following conditions:
[0075] Condition 1: The first shape difference value is greater than or equal to a preset first shape difference threshold;
[0076] Condition 2: The sum of all second shape difference values is greater than or equal to a preset second shape difference threshold; or, the number of target key parts is greater than or equal to a preset number threshold, wherein the target key parts are the parts whose corresponding second shape difference values are greater than or equal to a preset third shape difference threshold.
[0077] Condition 3: The texture difference value is greater than or equal to a preset texture difference threshold.
[0078] To facilitate understanding, specific examples will be used here.
[0079] Feature Library Construction: A large number of real livestock images are collected as normal livestock images. The shape and texture features described above are extracted from these images to construct a normal livestock image feature library. The feature library stores the normal shape feature vector and normal texture feature vector for each normal livestock image. The normal shape feature vector includes the normal contour feature vector and the geometric feature vectors corresponding to each key part of the image. For example, the normal contour feature vector includes, but is not limited to, the perimeter of the outer contour, the area enclosed by the outer contour, and the roundness of the outer contour. The normal geometric feature vectors corresponding to each key part include, but are not limited to, the position of the key part and the parameters used to describe the shape. The normal texture feature vector includes, but is not limited to, the contrast, correlation, energy, and entropy of each image sub-region.
[0080] Feature comparison and difference calculation: The target features of the livestock image to be detected are compared with normal features in the feature library. For shape features, the distance between the shape feature vector of the livestock image to be detected and the normal shape feature vector of the target normal livestock image in the feature library is calculated, for example, using the Euclidean distance formula. ,in The first image of the livestock to be detected Shape feature vectors of key parts The first normal livestock image in the feature library The normal shape feature vector of each key part, when the distance exceeds a set threshold When this occurs, the shape of the key area is considered abnormal. For texture features, the difference between the detected livestock image and the normal texture feature vectors of normal livestock images in the feature library is also calculated. For example, when the texture difference values of N sub-regions exceed a threshold... If the image's texture features are abnormal, the image is determined to have been tampered with. If any one or more of the shape and texture are abnormal, the image of the livestock being tested is determined to have been tampered with.
[0081] The following describes the method for determining the tampered image region from the livestock image when it is determined that the livestock image to be detected is a tampered image.
[0082] In one alternative implementation, the tampered image region can be determined from the livestock image to be detected using the intermediate layer feature map and the preset region generation network in the tampered image detection model.
[0083] The intermediate layer feature map of this convolutional neural network model for image tampering detection contains rich feature information of the image and has a good response to tampered regions. This intermediate layer feature map is used in conjunction with a Region Generation Network (RPN) to generate the tampered image region. Specifically, the RPN generates a series of candidate regions (anchor boxes) on the feature map. By calculating the Intersection over Union (IoU) ratio between the candidate regions and the true tampered regions, the candidate regions are classified (whether they are tampered regions) and regressed (adjusting the position and size of the candidate regions). The Non-Maximum Suppression (NMS) algorithm is used to remove candidate regions with excessive overlap, retaining the most likely tampered regions. Based on the position and size information of the finally retained candidate regions, the precise location and range of the tampered region are determined on the original image of the livestock to be detected and marked, for example, by outlining the tampered region with a red box, for visual presentation to the user or subsequent analysis.
[0084] In another optional implementation, when the difference between the target feature of a certain image region in the livestock image to be detected and the corresponding normal feature of the normal livestock image in the preset feature library reaches a preset difference threshold, the image region is taken as the target image region; based on the target image region, region expansion processing is performed to obtain the tampered image region in the livestock image to be detected.
[0085] Specifically, the image of the livestock to be detected can be divided into multiple image regions. The shape difference value between the shape feature vector of each image region and the normal shape feature vector of the target normal livestock image is calculated. The texture difference value between the texture feature vector of each image region and the normal texture feature vector of the target normal livestock image is also calculated. When the image region is determined to meet a preset condition based on the shape difference value and the texture difference value, that image region is taken as the target image region. The preset condition includes at least one of the following:
[0086] Condition 1: The shape difference value of the image region of the livestock image to be detected reaches a preset fourth shape difference threshold;
[0087] Condition 2: The texture difference value of the image region of the livestock image to be detected reaches a preset second texture difference threshold.
[0088] It should be noted that when dividing the livestock image to be detected into multiple image regions, the division can be based on key parts. For example, for each key part, a corresponding image region can be determined from the livestock image to be detected. Alternatively, the livestock image to be detected can be divided into multiple... The sub-regions are also known as the image regions.
[0089] When performing region expansion processing based on the target image region, a certain range of areas can be expanded from the target image region as a possible tampering area. Finally, these possible tampering areas are merged and optimized, and some isolated small regions are removed to obtain the final tampered image region.
[0090] Based on the same inventive concept, please refer to Figure 2 As shown in the illustration, this application also provides a livestock image detection device, comprising:
[0091] The acquisition module 201 is used to acquire target features of the livestock image to be detected; the target features include the shape features of the livestock extracted from the livestock image to be detected and the texture features of the livestock image to be detected; the judgment module 202 is used to determine whether the livestock image to be detected is a tampered image based on the target features.
[0092] It should be understood that, for the sake of brevity, some of the content described in the previous embodiments will not be repeated in this embodiment.
[0093] Based on the same inventive concept, please refer to Figure 3 As shown in the figure, this application embodiment also provides an electronic device, which includes a processor 301 and a memory 302. The memory 302 stores a computer program. The processor 301 and the memory 302 communicate through a communication bus. The processor 301 executes the computer program to implement the steps of the method in the above embodiment, which will not be described again here.
[0094] Understandable. Figure 3 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 3 The more or fewer components shown, or having the same Figure 3 The different configurations shown.
[0095] Processor 301 can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; 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. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.
[0096] The memory 302 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable read-only memory (EPROM), electrically erasable read-only memory (EEPROM), etc.
[0097] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0098] It should be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show components relevant to the present invention and are not drawn according to the actual number, shape, and size of components in implementation. In actual implementation, the form, quantity, and proportion of each component can be arbitrarily changed, and the component layout may be more complex. The structures, proportions, sizes, etc., depicted in the accompanying drawings are only for illustrative purposes to aid those skilled in the art and are not intended to limit the implementation conditions of the present invention. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to size, without affecting the effects and objectives of the present invention, should still fall within the scope of the technical content disclosed in the present invention. Furthermore, the terms such as "upper," "lower," "left," "right," "middle," and "one" used in this specification are only for clarity of description and are not intended to limit the scope of the present invention. Changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the present invention.
[0099] 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.
[0100] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for detecting a cow's profile image, characterized in that, include: Obtain target features from the livestock image to be detected; the target features include shape features of the livestock extracted from the livestock image to be detected and texture features of the livestock image to be detected; the shape features include the outer contour features of the livestock and features of key parts of the livestock image to be detected obtained based on a key part detection model; The shape features specifically include at least one of the following: the perimeter of the livestock's outer contour, the area of the region enclosed by the outer contour, the circularity of the outer contour, Hu invariant moments, the position of the key parts of the livestock in the image of the livestock to be detected, and the geometric features of the image region corresponding to the key parts; the texture features include at least one of the following: contrast, correlation, energy, and entropy extracted from the gray-level co-occurrence matrix of the image of the livestock to be detected; the image of the livestock to be detected is a cow's profile image; the key parts are at least one of the cow's eyes, muzzle, and horns; For the outer contour features of livestock images, the Canny edge detection algorithm is used for extraction; for the preprocessed livestock images to be detected, the gradient magnitude and direction of the image are calculated, edge pixels are determined by non-maximum suppression, and finally the outer contour edge of the livestock is obtained by double threshold detection and edge connection. Obtain the contour feature vector of the livestock image to be detected and the geometric feature vector corresponding to each key part. Calculate the first distance between the contour feature vector and the normal contour feature vector corresponding to the target normal livestock image. Use the first distance as the first shape difference value. Calculate the second distance between the geometric feature vector of each key part and the normal geometric feature vector of the corresponding key part in the target normal livestock image. Use each second distance as the second shape difference value. Obtain the texture feature vector of the livestock image to be detected, calculate the third distance between the texture feature vector and the normal texture feature vector corresponding to the target normal livestock image, and use the third distance as the texture difference value; When the first shape difference value, the second shape difference value, and the texture difference value meet preset conditions, the livestock image to be detected is determined to be a tampered image; otherwise, the livestock image to be detected is determined not to be a tampered image. The preset conditions include the following: Condition 1: The first shape difference value is greater than or equal to a preset first shape difference threshold; Condition 2: The sum of all second shape difference values is greater than or equal to a preset second shape difference threshold; or, the number of target key parts is greater than or equal to a preset number threshold, wherein the target key parts are the parts whose corresponding second shape difference values are greater than or equal to a preset third shape difference threshold. Condition 3: The texture difference value is greater than or equal to a preset texture difference threshold; When determining that the livestock image to be detected is a tampered image, the tampered image region is identified from the livestock image to be detected, including: When the difference between the target feature of a certain image region in the livestock image to be detected and the corresponding normal feature of a normal livestock image in the preset feature library reaches a preset difference threshold, the image region is taken as the target image region. Based on the target image region, region expansion processing is performed to obtain the tampered image region in the livestock image to be detected.
2. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a computer program, the processor executing the computer program to implement the method as claimed in claim 1.
3. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by at least one processor, implements the method as described in claim 1.