Live pig carcass segmentation method based on machine vision

Through frame difference method and foreground degree analysis, combined with shape prediction deviation and color characteristics, background pixels are screened and background models are constructed, which solves the problem of poor accuracy of background models in the prior art and improves the accuracy of pig carcass segmentation.

CN119399239AInactive Publication Date: 2025-02-07XIAN BENBEN ANIMAL HUSBANDRY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510001048.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-02
Publication Date
2025-02-07
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When constructing background models, it is difficult to effectively eliminate the pixel information of moving targets, resulting in poor accuracy of background models and affecting the accuracy of pig carcass segmentation.

Method used

The motion area of ​​the pig video is obtained by frame difference method, the first foreground degree and second foreground degree of each pixel are calculated, and the shape prediction deviation and color characteristics are combined to reflect the situation where each pixel is a foreground pixel, thereby filtering the background pixel and building an accurate Background model.

Benefits of technology

The accurate distinction between background pixels and foreground pixels is achieved, and the background model is constructed is more accurate, which improves the accuracy of pig carcass segmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119399239A_ABST
    Figure CN119399239A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image processing, in particular to a live pig carcass segmentation method based on machine vision, and the method comprises the steps: obtaining a live pig video; acquiring a foreground area; if one pixel in one frame of image belongs to the foreground area, setting the background probability of the pixel as 0; if the pixel in the frame image does not belong to the foreground area, calculating a first foreground degree of the pixel; calculating a second foreground degree, and calculating a background probability according to the first foreground degree and the second foreground degree; screening background pixels according to the background probability; constructing a background model according to the pixel values of the background pixels; and realizing live pig carcass segmentation according to the background model. A background model is accurately constructed by eliminating foreground pixel interference so as to realize live pig carcass segmentation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and more specifically, to a method for segmenting a pig carcass based on machine vision. Background Art

[0002] In order to facilitate the feeding and management of pigs, image processing technology is introduced to analyze the behavior of pigs, so as to judge the health of pigs through their behavior. Image segmentation is the basis of pig behavior analysis, and the quality of its segmentation will directly affect the accuracy of subsequent analysis.

[0003] Pigs generally move around, and the breeding environment in which they are located is mostly static objects, so pig detection can be performed by moving target detection. Background difference method is a commonly used moving target detection method, which can be used for pig carcass segmentation. The background difference method is based on the idea that there is a difference between the distribution of pixel values ​​of background pixels at a position in continuous frames and the distribution of pixel values ​​of moving target pixels to achieve moving target detection, so it is necessary to use background pixels to build a background model before moving target detection. This method believes that the time when a moving target exists at a position is relatively short, so the distribution model of the pixel values ​​of all pixels at a position in continuous frames is directly used as the background model. However, this construction method will definitely introduce pixel information of the moving target, especially when the moving target stops moving, the pixel information of the moving target introduced is more, so the accuracy of the background model constructed by this method is poor. How to achieve accurate background model construction by excluding moving target pixels in the pixels required for background model construction has become the research focus of the present invention.

[0004] The patent document with authorization announcement number CN108961293B discloses a method, device, equipment and storage medium for background subtraction. The focus of the method in the patent document is on background model updating, and the content involved in pixel screening in constructing the background model is relatively small. Therefore, the method in the patent document is not suitable for solving the problem in the present invention. Summary of the invention

[0005] In order to solve the problem of how to realize an accurate background model by excluding moving target pixels from pixels required for background model construction, the present invention proposes a pig carcass segmentation method based on machine vision, which comprises the following steps: Get pig videos; The frame difference method is used to obtain each moving area in each frame of the pig video and record it as the foreground area; if a pixel in a frame belongs to the foreground area, the background probability of the pixel is set to 0; if the pixel does not belong to the foreground area in the frame, the first foreground degree of the pixel is calculated. , , predict the position of the foreground area in the current frame image according to the position of the foreground area in the continuous frame image, record it as the suspected foreground area, d represents the minimum distance between the pixel and the edge of the nearest suspected foreground area, B represents the distance mark value, wherein when the pixel belongs to the nearest suspected foreground area, the distance mark value is 1, otherwise the distance mark value is -1, T represents the shape prediction deviation of the nearest suspected foreground area, norm() represents linear normalization processing; obtain the feature vector of each preset window in the foreground area, obtain the feature vector of the preset local area of ​​the pixel, calculate the similarity between the feature vector of the preset area of ​​the pixel and each preset window, and record the maximum value of the similarity as the second foreground degree, take the inverse of the product of the first foreground degree and the second foreground degree and perform normalization processing to obtain the background probability; Background pixels are selected according to background probability; a background model is constructed according to the pixel values ​​of the background pixels; and pig carcass segmentation is achieved according to the background model.

[0006] The present invention distinguishes foreground pixels from background pixels by reflecting the situation that each pixel is a foreground pixel, thereby providing a data basis for accurately constructing a background model; further, when analyzing the situation that each pixel is a foreground pixel, considering that the pig will move, a part of the pig area, that is, the foreground area, is extracted by a frame difference method; further, considering that the pig will stop and walk from time to time, some pig areas cannot be extracted by the frame difference method, and thus the situation that the pixel is the foreground area is determined by introducing a first foreground degree and a second foreground degree; further, when analyzing the first foreground degree, the position of the foreground area is predicted by the disappearance position of the foreground area in continuous frames, and then the situation that each pixel is the foreground is determined by analyzing the distance relationship between each pixel and the predicted foreground area; further, when analyzing the first foreground degree, considering that the pig will also have posture changes when it is not moving, although the approximate position of the foreground area can be located by the disappearance position of the foreground area in continuous frames, the foreground area cannot be accurately circled, so when analyzing the first foreground degree, the deformation of the foreground is analyzed, and the prediction accuracy of the foreground area is analyzed according to the deformation, and then the situation that each pixel is the foreground is corrected. Furthermore, when analyzing the second foreground degree, the difference between the color of the pig and the color of the background is taken into consideration, and thus the situation of each pixel being a foreground pixel is evaluated through color features.

[0007] Preferably, the method for obtaining the suspected foreground area includes: The foreground area in any frame of image is taken as the target area; Determine whether there is a foreground area whose intersection rate with the target area is greater than a preset threshold in the previous frame image. If not, obtain the area at the same position as the target area in the previous frame image as the suspected foreground area; determine whether there is a foreground area whose intersection rate with the suspected foreground area is greater than a preset threshold in the previous frame of the frame where the suspected foreground area is located. If not, obtain the area at the same position as the suspected foreground area in the previous frame image of the frame where the suspected foreground area is located as the suspected foreground area, and so on, until each previous frame image is traversed to obtain all the suspected foreground areas corresponding to the target area in the previous frame image; Based on the target area, the subsequent frames are also predicted to obtain all the suspected foreground areas corresponding to the target area in the subsequent frame images; each foreground area of ​​each frame image is analyzed to obtain all the suspected foreground areas in all frame images.

[0008] The present invention considers accurately judging whether to predict the foreground area in the subsequent frame by analyzing whether the detected foreground area disappears in the subsequent frame, and then accurately predicting the foreground area in the subsequent frame according to the foreground area when it disappears.

[0009] Preferably, the method for obtaining the shape prediction deviation includes: Obtaining a foreground area derived from the suspected foreground area in a previous frame or a subsequent frame image as a reference area; obtaining the interval frame number between the image where the suspected foreground area is located and the image where the reference area is located; Obtain the corresponding foreground area of ​​any foreground area in continuous frames, and divide the union area of ​​the foreground area of ​​the foreground area in one frame image and the corresponding foreground area in the previous frame image by the intersection area to obtain the deformation rate of the foreground area in the frame image, and record the average deformation rate of the foreground area in all frame images as the reference deformation rate; The product of the interval frame number and the reference deformation rate is taken as the shape prediction deviation.

[0010] The present invention accurately reflects the deformation of the foreground area in a single frame by analyzing the changes in the foreground area of ​​the previous and next two frames, and then uses the accumulated deformation generated in the interval frame to accurately reflect the shape deviation of the predicted foreground area.

[0011] Preferably, the foreground area derived from the suspected foreground area in the previous frame or the next frame image is recorded as the reference area, including: If the suspected foreground area is obtained based on the area in the previous frame image, then the area corresponding to the suspected foreground area in the previous frame image is obtained; if the area corresponding to the suspected foreground area in the previous frame image is the foreground area, then the foreground area is used as the reference area of ​​the suspected foreground area; if the area corresponding to the suspected foreground area in the previous frame image is the suspected foreground area, continue to search forward until the corresponding area of ​​the suspected foreground area is the foreground area, and use the corresponding foreground area found as the reference area; If the suspected foreground area is obtained based on an area in a subsequent frame of image, then searching backwards to obtain a reference area for the suspected foreground area.

[0012] Preferably, the method of obtaining each motion region in each frame of the pig video by using the frame difference method includes: Each frame of the pig video is grayed to obtain a grayscale image of each frame. The continuous frame grayscale images are processed using the frame difference method to obtain a frame difference image. The frame difference image is morphologically processed, and the area surrounded by the outermost edge lines of each connected area in the frame difference image after morphological processing is obtained as the motion area.

[0013] The present invention extracts the motion region by using a frame difference method and a morphological processing method. The method for extracting the motion region is relatively simple and has a higher implementation efficiency.

[0014] Preferably, the method for obtaining the feature vector includes: Calculate the color value of each pixel in the local area or window in each channel, take the average of the color values ​​of the pixel in all channels as the comprehensive color value of the pixel, perform statistics on the comprehensive color values ​​of all pixels in the local area or window to obtain the frequency of occurrence of each comprehensive color value, and take the vector composed of the frequency of occurrence of all kinds of comprehensive color values ​​as the feature vector.

[0015] Preferably, constructing a background model according to the pixel values ​​of background pixels comprises: A background pixel at a position in the continuous frames is obtained, and a Gaussian model is constructed using the comprehensive color value of the background pixel at a position in the continuous frames, which is recorded as the background model.

[0016] The present invention utilizes background pixels to construct a background model, thereby eliminating interference from foreground pixel information, and the background model constructed thereby has a higher accuracy rate.

[0017] Preferably, the method of implementing pig carcass segmentation according to the background model comprises: Get the newly collected pig image, determine the distribution position of the comprehensive color value of a pixel in the newly collected pig image in the corresponding background model, and if the distribution position is If it is outside the range, the pixel is determined to be a foreground pixel. , Respectively represent the mean and standard deviation of the background model; The connected domain formed by all foreground pixels in the newly collected pig image is taken as the pig carcass region.

[0018] The present invention has the following beneficial effects: The present invention distinguishes foreground pixels from background pixels by reflecting the situation that each pixel is a foreground pixel, thereby providing a data basis for accurately constructing a background model; Furthermore, when analyzing the situation where each pixel is a foreground pixel, considering that the pigs will move, a part of the pig area, i.e., the foreground area, is extracted by using the frame difference method; Furthermore, considering that pigs may stop and walk from time to time, some pig areas cannot be extracted using the frame difference method, so the first foreground degree and the second foreground degree are introduced to determine whether the pixel is a foreground area; Furthermore, when analyzing the first foreground degree, the position of the foreground area is predicted by the disappearance position of the foreground area in the continuous frames, and then the distance relationship between each pixel and the predicted foreground area is analyzed to determine whether each pixel is the foreground; Furthermore, when analyzing the first foreground degree, considering that the posture of live pigs will change when they are not moving, although the approximate position of the foreground area can be located by the disappearance position of the foreground area in continuous frames, the foreground area cannot be accurately circled. Therefore, when analyzing the first foreground degree, the deformation of the foreground is analyzed, and the prediction accuracy of the foreground area is analyzed according to the deformation, and then the situation where each pixel is the foreground is corrected.

[0019] Furthermore, when analyzing the second foreground degree, the difference between the color of the pig and the color of the background is taken into consideration, and thus the situation of each pixel being a foreground pixel is evaluated through color features. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein: Figure 1 The present invention is a flowchart of the steps of a method for cutting a pig carcass based on machine vision. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0022] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0023] See also Figure 1 , which shows a flowchart of a method for cutting a pig carcass based on machine vision according to an embodiment of the present invention, the method comprising the following steps: S1: Obtain pig videos.

[0024] Specifically, cameras are installed in pig breeding places and used to collect videos of pigs.

[0025] S2: Use the frame difference method to obtain each moving area in each frame of the pig video, and record it as the foreground area; if a pixel in a frame belongs to the foreground area, set the background probability of the pixel to 0; if the pixel does not belong to the foreground area in the frame, calculate the first foreground degree of the pixel; obtain the feature vector of each preset window in the foreground area, obtain the feature vector of the preset local area of ​​the pixel, calculate the similarity between the preset area of ​​the pixel and the feature vector of each preset window, and record the maximum value of the similarity as the second foreground degree, take the inverse of the product of the first foreground degree and the second foreground degree, and then normalize it to obtain the background probability.

[0026] It should be noted that in order to eliminate the interference of pig pixels on the construction of the background model, it is necessary to distinguish between background pixels and pig pixels.

[0027] S20: using the frame difference method to obtain each moving area in each frame of the pig video, and record it as the foreground area; if a pixel in a frame belongs to the foreground area, the background probability of the pixel is set to 0.

[0028] It should be noted that, in pig breeding places, generally only pigs move, while other objects are stationary. Therefore, pixels with moving objects are more likely to be pig pixels.

[0029] Preferably, as an example, the frame difference method is used to obtain each motion area in each frame of the pig video, which is recorded as the foreground area; if a pixel in a frame belongs to the foreground area, the background probability of the pixel is set to 0, including: Each frame of the pig video is grayed to obtain a grayscale image of each frame. The continuous frame grayscale images are processed using the frame difference method to obtain a frame difference image. The frame difference image is morphologically processed, and the area surrounded by the outermost edge lines of each connected area in the frame difference image after morphological processing is obtained as the motion area, and the motion area is recorded as the foreground area.

[0030] If a pixel in a frame image belongs to the foreground area, the background probability of the pixel is set to 0.

[0031] The morphological processing includes: corrosion, expansion, opening operation, and closing operation.

[0032] It can be understood that the silhouette of the moving object can be extracted by the frame difference method, and the area surrounded by the silhouette of the moving object is the area where the moving object is located, that is, the foreground area. Therefore, the background probability of the pixels in the moving area should be set to 0.

[0033] S21: If the pixel in the frame image does not belong to the foreground area, calculate a first foreground level of the pixel.

[0034] It should be noted that, since the pigs may move and stop from time to time, there may be no moving objects at some pixels, but there may also be pigs there, so it is necessary to further determine the pixels where there are no moving objects.

[0035] It should be further explained that if there are moving objects around the pixels of a pixel in a frame in the previous and next frames, there is a high possibility that there is a live pig in the pixel of the frame, but the pig has stopped moving in this frame. Therefore, it is possible to determine whether there is a live pig at the pixel by the moving position of the pig in consecutive frames.

[0036] Preferably, as an example, if the pixel in the frame image does not belong to the foreground area, calculating the first foreground degree of the pixel includes:

[0037] Among them, the position of the foreground area in the current frame image is predicted according to the position of the foreground area in the continuous frame images, which is recorded as the suspected foreground area. d represents the minimum distance between the pixel and the edge of the nearest suspected foreground area. B represents the distance mark value. When the pixel belongs to the nearest suspected foreground area, the distance mark value is 1, otherwise the distance mark value is -1. T represents the shape prediction deviation of the nearest suspected foreground area. norm() represents linear normalization processing. L represents the first foreground degree of the pixel.

[0038] It is understandable that the suspected foreground area is an area where pigs may exist, and since the suspected foreground area is a predicted pig area, it may not be accurate, so it is not possible to directly determine whether the pixel is a foreground pixel (pig pixel) by whether the pixel belongs to the suspected foreground area. Although the suspected foreground area may not be accurate, the suspected foreground area can locate the pig area to a certain extent, so the closer the pixel is to the suspected foreground area, the greater the possibility that the pixel is a foreground pixel; at the same time, since the situation of the pixel being a foreground pixel is reflected based on the distance situation of the suspected foreground area, the more accurate the prediction of the suspected foreground area, the more accurate the judgment result, so the situation of the pixel being a foreground pixel is corrected by the accuracy of the prediction of the suspected foreground area. Since the foreground area can be detected when the pig moves, if the foreground area cannot be detected using the frame difference method, it means that the pig has not moved, but the pig may have a posture change, so the factor causing the inaccurate prediction of the suspected foreground area is the morphological change of the foreground area, so this embodiment uses the shape change to reflect the accuracy of the prediction of the suspected foreground area, where The probability that a pixel is a foreground pixel, Reflects the prediction accuracy of the suspected foreground area, The larger the value is, the greater the deformation of the pig is, and the less accurate the suspected foreground area predicted using the foreground area of ​​the previous frame is.

[0039] The above embodiments involve suspected foreground areas and shape prediction deviations. The following describes a method for determining suspected foreground areas and shape prediction deviations.

[0040] First, the method of obtaining the suspected foreground area is introduced.

[0041] Preferably, as an example, the method for obtaining the suspected foreground area includes: The foreground area in any frame of image is taken as the target area; It is determined whether there is a foreground area in the previous frame image whose intersection rate with the target area is greater than a preset threshold. If not, the area at the same position as the target area in the previous frame image is obtained as the suspected foreground area. The intersection rate is the ratio of the intersection and the union of the two areas. This embodiment is described by taking the intersection rate as 0.8 as an example. Other embodiments may take other values, and this embodiment does not make specific restrictions.

[0042] Determine whether there is a foreground area whose intersection rate with the suspected foreground area is greater than a preset threshold in the previous frame of the frame where the suspected foreground area is located. If not, obtain the area at the same position as the suspected foreground area in the previous frame image of the frame where the suspected foreground area is located as the suspected foreground area, and so on, until each previous frame image is traversed to obtain all the suspected foreground areas corresponding to the target area in the previous frame image.

[0043] Based on the target area, the subsequent frames are also predicted to obtain all the suspected foreground areas corresponding to the target area in the subsequent frame images.

[0044] In the same way, each foreground area of ​​each frame image is analyzed to obtain all suspected foreground areas in all frame images.

[0045] It is understandable that if the pig stops moving, it is difficult to segment the complete foreground area (pig area) using the frame difference method. Therefore, the foreground area in the previous and next frames can only be used to predict the foreground area in the non-existent frame. Since the pig stops moving, the position of the pig area will not move, so the same position area of ​​the detected foreground area can be used as the predicted foreground area.

[0046] Then the method of obtaining shape prediction deviation is introduced.

[0047] Preferably, as an example, the method for obtaining the shape prediction deviation includes: If the suspected foreground area is obtained based on the area in the previous frame image, then the area corresponding to the suspected foreground area in the previous frame image is obtained; if the area corresponding to the suspected foreground area in the previous frame image is the foreground area, then the foreground area is used as the reference area of ​​the suspected foreground area; if the area corresponding to the suspected foreground area in the previous frame image is the suspected foreground area, continue to search forward until the corresponding area of ​​the suspected foreground area is the foreground area, and use the corresponding foreground area found as the reference area; If the suspected foreground area is obtained based on an area in a subsequent frame of image, then searching backwards to obtain a reference area for the suspected foreground area.

[0048] Obtaining a foreground area derived from the suspected foreground area in a previous frame or a subsequent frame image as a reference area; obtaining the interval frame number between the image where the suspected foreground area is located and the image where the reference area is located; Obtain the corresponding foreground area of ​​any foreground area in continuous frames, and divide the union area of ​​the foreground area of ​​the foreground area in one frame image and the corresponding foreground area in the previous frame image by the intersection area to obtain the deformation rate of the foreground area in the frame image, and record the average deformation rate of the foreground area in all frame images as the reference deformation rate; The product of the interval frame number and the reference deformation rate is taken as the shape prediction deviation.

[0049] It is understandable that since the deformation of the suspected foreground area cannot be directly obtained, the deformation amount per unit time can only be reflected by the shape change of the foreground area in two adjacent frames, and then the shape prediction deviation is obtained by multiplying the accumulated time by the deformation amount per unit time.

[0050] S22: Obtain feature vectors of each preset window in the foreground area, obtain feature vectors of a preset local area of ​​the pixel, calculate similarities between the preset area of ​​the pixel and feature vectors of each preset window, and record the maximum similarity as a second foreground degree.

[0051] It should be noted that the above steps reflect the probability of each pixel being a foreground pixel by means of motion prediction. However, if the motion prediction is inaccurate or the foreground area segmented by the frame difference method is poor, the judgment result will be inaccurate, so it is necessary to combine other features for judgment.

[0052] It should be further explained that there is a certain difference between the color of the live pig and the background, so the color of the live pig can be used to further determine whether each pixel belongs to the foreground.

[0053] Preferably, as an example, obtaining the feature vectors of each preset window in the foreground area, obtaining the feature vector of the preset local area of ​​the pixel, calculating the similarity between the feature vectors of the preset area of ​​the pixel and each preset window, and recording the maximum similarity as the second foreground degree, includes: Taking the pixel as the center, a local area of ​​a preset size is obtained; Calculate the color value of each pixel in each channel in the local area, take the average of the color values ​​of the pixel in all channels as the comprehensive color value of the pixel, perform statistics on the comprehensive color values ​​of all pixels in the local area to obtain the frequency of occurrence of each comprehensive color value, and take the vector composed of the frequency of occurrence of all kinds of comprehensive color values ​​as the feature vector of the local area.

[0054] A window of a preset size is used to slide on each foreground area to obtain several windows, and a feature vector of each window is obtained.

[0055] The cosine similarity between the feature vector of the local area and the feature vector of each window is calculated, and recorded as the similarity between the feature vector of the preset area of ​​the pixel and each preset window.

[0056] The maximum similarity value among the similarities corresponding to all windows is obtained as the second foreground degree of the pixel.

[0057] In this embodiment, the preset size is taken This is described as an example, and other embodiments may take other values, and this embodiment does not make any specific limitation.

[0058] S23: taking the inverse of the product of the first foreground degree and the second foreground degree and then normalizing it to obtain the background probability.

[0059] S3: Filter background pixels according to background probability; construct a background model according to the pixel values ​​of the background pixels; and segment the pig carcass according to the background model.

[0060] S30: Filtering background pixels according to the background probability.

[0061] Preferably, as an example, screening background pixels according to background probability includes: Pixels with background probability greater than a preset probability threshold are regarded as background pixels.

[0062] S31: Construct a background model according to the pixel values ​​of the background pixels.

[0063] Preferably, as an example, constructing a background model according to the pixel values ​​of background pixels includes: A background pixel at a position in the continuous frames is obtained, and a Gaussian model is constructed using the comprehensive color value of the background pixel at a position in the continuous frames, which is recorded as the background model.

[0064] S32: Implement pig carcass segmentation based on the background model.

[0065] Preferably, as an example, the pig carcass segmentation is implemented according to the background model, including: Get the newly collected pig image, and get the distribution position of the comprehensive color value of a pixel in the newly collected pig image in the corresponding background model. If the distribution position is If it is outside the range, the pixel is determined to be a foreground pixel. , Respectively represent the mean and standard deviation of the background model; The connected domain formed by all foreground pixels in the newly collected pig image is taken as the pig carcass region.

[0066] At this point, this embodiment is completed.

[0067] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for cutting pig carcasses based on machine vision, characterized in that: include: Get pig videos; The motion areas in each frame of the pig video are obtained by using the frame difference method and recorded as foreground areas; If a pixel in a frame image belongs to the foreground area, the background probability of the pixel is set to 0; If the pixel in the frame image does not belong to the foreground area, calculate the first foreground level of the pixel , , predict the position of the foreground area in the current frame image according to the position of the foreground area in the continuous frame image, record it as the suspected foreground area, d represents the minimum distance between the pixel and the edge of the nearest suspected foreground area, B represents the distance mark value, wherein when the pixel belongs to the nearest suspected foreground area, the distance mark value is 1, otherwise the distance mark value is -1, T represents the shape prediction deviation of the nearest suspected foreground area, norm() represents linear normalization processing; obtain the feature vector of each preset window in the foreground area, obtain the feature vector of the preset local area of ​​the pixel, calculate the similarity between the feature vector of the preset area of ​​the pixel and each preset window, and record the maximum value of the similarity as the second foreground degree, take the inverse of the product of the first foreground degree and the second foreground degree and perform normalization processing to obtain the background probability; Filter background pixels based on background probability; Building a background model based on the pixel values ​​of background pixels; Pig carcass segmentation is achieved based on background models.

2. The method for cutting pig carcasses based on machine vision according to claim 1, characterized in that: The method for obtaining the suspected foreground area includes: The foreground area in any frame of image is taken as the target area; Determine whether there is a foreground area whose intersection rate with the target area is greater than a preset threshold in the previous frame image. If not, obtain the area at the same position as the target area in the previous frame image as the suspected foreground area; determine whether there is a foreground area whose intersection rate with the suspected foreground area is greater than a preset threshold in the previous frame of the frame where the suspected foreground area is located. If not, obtain the area at the same position as the suspected foreground area in the previous frame image of the frame where the suspected foreground area is located as the suspected foreground area, and so on, until each previous frame image is traversed to obtain all the suspected foreground areas corresponding to the target area in the previous frame image; Based on the target area, the subsequent frames are also predicted to obtain all the suspected foreground areas corresponding to the target area in the subsequent frame images; each foreground area of ​​each frame image is analyzed to obtain all the suspected foreground areas in all frame images.

3. The method for cutting pig carcasses based on machine vision according to claim 2, characterized in that: The method for obtaining the shape prediction deviation comprises: Obtaining a foreground area derived from the suspected foreground area in a previous frame or a subsequent frame image as a reference area; obtaining the interval frame number between the image where the suspected foreground area is located and the image where the reference area is located; Obtain the corresponding foreground area of ​​any foreground area in continuous frames, and divide the union area of ​​the foreground area of ​​the foreground area in one frame image and the corresponding foreground area in the previous frame image by the intersection area to obtain the deformation rate of the foreground area in the frame image, and record the average deformation rate of the foreground area in all frame images as the reference deformation rate; The product of the interval frame number and the reference deformation rate is taken as the shape prediction deviation.

4. The method for cutting pig carcasses based on machine vision according to claim 3, characterized in that: The foreground area derived from the suspected foreground area in the previous frame or the next frame image is recorded as the reference area, including: If the suspected foreground area is obtained based on the area in the previous frame image, then the area corresponding to the suspected foreground area in the previous frame image is obtained; if the area corresponding to the suspected foreground area in the previous frame image is the foreground area, then the foreground area is used as the reference area of ​​the suspected foreground area; if the area corresponding to the suspected foreground area in the previous frame image is the suspected foreground area, continue to search forward until the corresponding area of ​​the suspected foreground area is the foreground area, and use the corresponding foreground area found as the reference area; If the suspected foreground area is obtained based on an area in a subsequent frame of image, then searching backwards to obtain a reference area for the suspected foreground area.

5. The method for cutting pig carcasses based on machine vision according to claim 1, characterized in that: The method of obtaining each motion region in each frame of the pig video by using the frame difference method includes: Each frame of the pig video is grayed to obtain a grayscale image of each frame. The continuous frame grayscale images are processed using the frame difference method to obtain a frame difference image. The frame difference image is morphologically processed, and the area surrounded by the outermost edge lines of each connected area in the frame difference image after morphological processing is obtained as the motion area.

6. The method for cutting pig carcasses based on machine vision according to claim 1, characterized in that: The method for obtaining the feature vector comprises: Calculate the color value of each pixel in the local area or window in each channel, take the average of the color values ​​of the pixel in all channels as the comprehensive color value of the pixel, perform statistics on the comprehensive color values ​​of all pixels in the local area or window to obtain the frequency of occurrence of each comprehensive color value, and take the vector composed of the frequency of occurrence of all kinds of comprehensive color values ​​as the feature vector.

7. The method for cutting pig carcasses based on machine vision according to claim 6, characterized in that: The step of constructing a background model according to the pixel values ​​of background pixels comprises: A background pixel at a position in the continuous frames is obtained, and a Gaussian model is constructed using the comprehensive color value of the background pixel at a position in the continuous frames, which is recorded as the background model.

8. The method for cutting pig carcasses based on machine vision according to claim 1, characterized in that: The method of implementing pig carcass segmentation according to the background model comprises: Get the newly collected pig image, determine the distribution position of the comprehensive color value of a pixel in the newly collected pig image in the corresponding background model, and if the distribution position is If it is outside the range, the pixel is determined to be a foreground pixel. , Respectively represent the mean and standard deviation of the background model; The connected domain formed by all foreground pixels in the newly collected pig image is taken as the pig carcass region.

Citation Information

Patent Citations

  • A method, apparatus, device, and storage medium for background subtraction.

    CN108961293B