A method, apparatus, and server for counting white-feathered chickens based on image enhancement density estimation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-28
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]本发明实施例提供了一种基于图像增强密度估计的白羽鸡计数方法、装置及服务器,以解决现有技术中在密集遮挡、白羽反光及低分辨率监控条件下,传统目标检测与密度估计方法计数精度低、泛化能力不足且标注成本高昂的技术问题
[0009] The invention provides a method, apparatus, and server for counting broiler chickens based on image-enhanced density estimation. The method involves processing the broiler chicken image through a multi-scale feature extraction module to obtain multi-scale fusion features; inputting these features into an edge branch for edge texture feature extraction; inputting these features into a context branch for global semantic feature extraction; fusing the edge texture features and global semantic features to obtain enhanced fusion features; inputting these enhanced fusion features into a density estimation branch; and using a spatial information decoupling unit to evaluate and separate information richness, extracting first and second spatial information features. Spatial information features and second spatial information features are fed into the channel semantic refinement unit, where local density features are obtained through separation and fusion strategies. Position encoding information is generated based on the two-dimensional spatial coordinates corresponding to the local density features. This position encoding information is then mapped to obtain mapped position encoding information. The local density features and the mapped position encoding information are fused and input into the state space global regression branch to extract the global dependencies between white-feathered chicken targets, generating global association features. These global association features are then input into the decoder for decoding, outputting the predicted center point coordinates of the white-feathered chickens. The total number of white-feathered chickens is obtained based on these predicted center point coordinates. By combining multi-scale feature extraction and edge context enhancement, density estimation through spatial information decoupling and channel semantic refinement, and introducing position encoding and state space global regression to capture long-range dependencies between targets, high-precision counting of white-feathered chickens in low-resolution dense scenes is achieved.
Smart Images

Figure CN122574901A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision and image processing technology, and in particular to a method, apparatus and server for counting white-feathered chickens based on image enhancement density estimation. Background Technology
[0002] In recent years, with the continuous growth in demand for poultry products, broiler chickens, with their advantages of short growth cycle and high feed conversion rate, have become the core breed for large-scale poultry farming in my country. In large-scale floor-raising or net-bed farming models, maintaining a reasonable stocking density is crucial for improving survival rates, optimizing poultry house space utilization, and ensuring animal welfare. However, traditional farms mainly rely on manual observation and sampling of large amounts of monitoring video. This model is not only inefficient and subjective, but also lacks unified standards, significantly increasing labor costs and intensity, severely hindering the transformation and upgrading of smart poultry farming.
[0003] To reduce labor costs and improve management efficiency, deep learning-based object detection algorithms have been gradually introduced into the field of poultry counting. Early research mainly relied on classic object detection models such as R-CNN and Faster R-CNN, which achieved population counting by locating bounding boxes of individuals.
[0004] Although deep learning methods have been initially applied to poultry counting, existing technologies face systemic challenges in real-world scenarios of large-scale broiler chicken farming. Severe individual occlusion caused by high-density farming and high bounding box annotation costs, coupled with feature adhesion and background confusion caused by white feather reflection in monitoring images, have led traditional detection and density estimation networks into a dilemma between local detail perception and global semantic modeling. Ultimately, this results in a significant decrease in generalization ability and counting accuracy in poultry housing environments with mixed high and low densities, making it difficult to meet the practical needs of smart farming. Summary of the Invention
[0005] This invention provides a method, apparatus, and server for counting white-feathered chickens based on image-enhanced density estimation, in order to solve the technical problems of low counting accuracy, insufficient generalization ability, and high annotation cost of traditional target detection and density estimation methods under conditions of dense occlusion, white feather reflection, and low-resolution monitoring.
[0006] In a first aspect, embodiments of the present invention provide a method for counting broiler chickens based on image enhancement density estimation, comprising: The white-feathered chicken images are processed by a multi-scale feature extraction module to obtain multi-scale fused features; The multi-scale fusion features are input into the edge branch to extract edge texture features, and the multi-scale fusion features are input into the context branch to extract global semantic features. The edge texture features and global semantic features are then fused to obtain enhanced fusion features. The enhanced fusion features are input into the density estimation branch, and the information richness is evaluated and the first spatial information feature and the second spatial information feature are extracted through the spatial information decoupling unit. The first spatial information feature and the second spatial information feature are then sent to the channel semantic refinement unit, and the local density features are obtained through the separation and fusion strategy. Based on the two-dimensional spatial coordinates corresponding to the local density features, position encoding information is generated, and the position encoding information is mapped to obtain mapped position encoding information. The local density features are fused with the mapping location encoding information, and the global dependency between white-feathered chicken targets is extracted by inputting the state space global regression branch to generate global association features; The global correlation features are input into the decoder for decoding, and the predicted center point coordinates of the white-feathered chickens are output. The total number of white-feathered chickens is obtained based on the predicted center point coordinates of the white-feathered chickens.
[0007] Secondly, embodiments of the present invention also provide a broiler chicken counting device based on image enhancement density estimation, comprising: The multi-scale fusion feature extraction module is used to process the white-feathered chicken image through the multi-scale feature extraction module to obtain multi-scale fusion features; The edge and context feature extraction module is used to input the multi-scale fusion features into the edge branch to extract edge texture features, input the multi-scale fusion features into the context branch to extract global semantic features, and fuse the edge texture features and global semantic features to obtain enhanced fusion features; The local density feature extraction module is used to input the enhanced fusion features into the density estimation branch, and extract the first spatial information feature and the second spatial information feature by performing information richness evaluation and separation through the spatial information decoupling unit. The first spatial information feature and the second spatial information feature are then sent to the channel semantic refinement unit to obtain local density features through separation and fusion strategies. The mapping location encoding information acquisition module is used to generate location encoding information based on the two-dimensional spatial coordinates corresponding to the local density features, and to obtain mapped location encoding information by mapping the location encoding information. The global association feature acquisition module is used to fuse the local density features with the mapping position encoding information, and extract the global dependency relationship between white-feathered chicken targets from the state space global regression branch to generate global association features; The total number calculation module is used to input the global correlation features into the decoder for decoding, output the predicted center point coordinates of the white-feathered chickens, and obtain the total number of white-feathered chickens based on the predicted center point coordinates of the white-feathered chickens.
[0008] Thirdly, embodiments of the present invention also provide a server, comprising: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the white-feathered chicken counting method based on image enhancement density estimation as provided in the above embodiments.
[0009] The invention provides a method, apparatus, and server for counting broiler chickens based on image-enhanced density estimation. The method involves processing the broiler chicken image through a multi-scale feature extraction module to obtain multi-scale fusion features; inputting these features into an edge branch for edge texture feature extraction; inputting these features into a context branch for global semantic feature extraction; fusing the edge texture features and global semantic features to obtain enhanced fusion features; inputting these enhanced fusion features into a density estimation branch; and using a spatial information decoupling unit to evaluate and separate information richness, extracting first and second spatial information features. Spatial information features and second spatial information features are fed into the channel semantic refinement unit, where local density features are obtained through separation and fusion strategies. Position encoding information is generated based on the two-dimensional spatial coordinates corresponding to the local density features. This position encoding information is then mapped to obtain mapped position encoding information. The local density features and the mapped position encoding information are fused and input into the state space global regression branch to extract the global dependencies between white-feathered chicken targets, generating global association features. These global association features are then input into the decoder for decoding, outputting the predicted center point coordinates of the white-feathered chickens. The total number of white-feathered chickens is obtained based on these predicted center point coordinates. By combining multi-scale feature extraction and edge context enhancement, density estimation through spatial information decoupling and channel semantic refinement, and introducing position encoding and state space global regression to capture long-range dependencies between targets, high-precision counting of white-feathered chickens in low-resolution dense scenes is achieved. Attached Figure Description
[0010] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0011] Figure 1 This is a flowchart of the white-feathered chicken counting method based on image enhancement density estimation provided in Embodiment 1 of the present invention; Figure 2 This is the overall network architecture diagram of the white-feathered chicken counting method based on image enhancement density estimation provided in Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of the structure of the white-feathered chicken counting device based on image enhancement density estimation provided in Embodiment 2 of the present invention; Figure 4 This is a structural diagram of the server provided in Embodiment 3 of the present invention. Detailed Implementation
[0012] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0013] Example 1 Figure 1 This is a flowchart of a broiler chicken counting method based on image enhancement density estimation provided in Embodiment 1 of the present invention. This embodiment is applicable to the accurate counting of broiler chickens in large-scale farming models, and specifically includes the following steps: Step 110: The white-feathered chicken image is processed by a multi-scale feature extraction module to obtain multi-scale fusion features.
[0014] White-feathered chicken images refer to raw footage captured in real-time or at set intervals by monitoring cameras deployed in poultry houses, covering large-scale poultry farming areas. These images typically exhibit complex characteristics such as limited resolution, uneven lighting distribution, severe overlap of individual birds, and blurred edges due to reflections from the white feathers, accurately reflecting the actual state of low-quality monitoring data in smart farming scenarios. The multi-scale feature extraction module is used to downsample the white-feathered chicken images layer by layer, generating multiple layers of Gaussian pyramid features at different scales. Based on these multiple layers of Gaussian pyramid features, upsampling and differencing operations are used to obtain multiple layers of Laplacian pyramid features. The dimensions of the multiple layers of Laplacian pyramid features are aligned, and the aligned features are input into a progressive fusion path. A depthwise separable convolution module performs cross-scale feature interaction and compression to obtain multi-scale fused features.
[0015] For example, the raw images captured by the poultry house monitoring camera are first input into the Gaussian pyramid decomposition process. By alternating Gaussian smoothing filtering and layer-by-layer downsampling operations, a set of Gaussian pyramid features with resolution halved layer by layer is generated. Different levels of Gaussian pyramid features correspond to different receptive fields. Lower-level features focus on the fine structures of individual broiler chickens, such as feather texture and beak contours, while higher-level features cover a broader global view, capturing the overall spatial distribution, aggregation centers, and sparse areas of the flock. Subsequently, upsampling and differencing operations are performed on adjacent levels of Gaussian pyramid features to construct the corresponding level of Laplacian pyramid features. The i-th level Laplacian feature... Features of this layer of the Gaussian pyramid Subtract the first Features of the Gaussian Pyramid The result after upsampling and restoring to the same size is calculated using the following formula: ,in This is an upsampling function used to upsample lower-resolution features. Restore to Same spatial dimensions. Through the above difference operation, Essentially, it extracts the high-frequency residual information of the image at this scale, that is... The low-frequency profile it represents cannot be described, and The remaining details are crucial. In the white-feathered chicken counting scene, these high-frequency residuals correspond to the individual edge contours, the light and dark transitions in the overlapping feather areas, and the subtle differences between the white feathers and the reflective background, providing key discrimination criteria for subsequent differentiation of densely clustered targets. After obtaining the Laplacian pyramid features of each layer, size alignment and feature fusion operations are further performed. Optionally, firstly, each layer of Laplacian features is upsampled or downsampled to uniformly restore it to a preset target resolution (such as 1 / 2 or 1 / 4 of the original image size to balance computational efficiency and feature fidelity), resulting in a hierarchical feature sequence with consistent spatial dimensions. Subsequently, a top-down progressive fusion path is used to process the hierarchical feature sequence: starting from the highest layer of Laplacian features, semantic information is passed down layer by layer; at each fusion node, the fusion result of the previous layer is concatenated with the current layer of Laplacian features, and input into a depthwise separable convolutional module for cross-scale feature interaction and channel compression, outputting the current layer's fused features. Finally, the lowest-level fusion feature is used as a multi-scale fusion feature containing rich multi-scale contextual information. This fusion feature combines local edge details from the low level with global semantic context from the high level, laying the feature foundation for texture enhancement of subsequent edge branches, background suppression of context branches, and accurate counting of density estimation branches.
[0016] Step 120: Input the multi-scale fusion feature into the edge branch to extract edge texture features, input the multi-scale fusion feature into the context branch to extract global semantic features, and fuse the edge texture features and global semantic features to obtain enhanced fusion features.
[0017] To overcome the problems of blurred individual outlines and background interference of white-feathered chickens under low-resolution monitoring conditions, multi-scale fusion features that combine local details and global semantics are first fed into the edge branch and context branch respectively to independently enhance the edge outline response of white-feathered chickens and capture the global scene semantics under different aggregation patterns. Then, the two are deeply fused to form enhanced fusion features with stronger anti-interference ability, thereby providing high-quality and high-discrimination feature representation for subsequent density estimation.
[0018] For example, the edge branch is used to extract the horizontal gradient of the multi-scale fused features using the Sobel x operator to obtain horizontal gradient features; and to extract the vertical gradient of the multi-scale fused features using the Sobel y operator to obtain vertical gradient features; the horizontal gradient features and vertical gradient features are then weighted and fused to obtain edge texture features. The Sobel operator is a type of discrete difference operator used for edge detection in digital images. Its core idea is to approximate the gradient vector of the image brightness function through local convolution operations. The Sobel x operator and the Sobel y operator correspond to the gradient detection kernels in the horizontal and vertical directions, respectively, and together they constitute the orthogonal basis for two-dimensional image edge extraction. The convolution kernel of the Sobel x operator has weights arranged horizontally. This kernel produces a strong response to edges extending vertically in the image, while its response to flat areas or horizontally oriented edges is weaker. In the convolution operation, the convolution kernel traverses the image in a sliding window manner, calculating the weighted sum of the brightness differences between the left and right sides in the neighborhood of each pixel, thereby extracting the vertical contour and horizontal texture transition of the target in the image. The Sobel x operator's convolution kernel has weights arranged vertically, producing a strong response to edges extending horizontally in the image. By calculating the weighted sum of the brightness differences between the upper and lower sides within the neighborhood of each pixel, the convolution kernel can effectively extract the horizontal contour and vertical structural boundaries of the target. For example, the edge branch uses multi-scale fusion features as input, and performs directional gradient extraction using both the Sobel x and Sobel y operators to obtain the edge response components of the white-feathered chicken target in different directions. Specifically, the multi-scale fusion features are subjected to a sliding-window convolution operation with the Sobel x convolution kernel to obtain a horizontal gradient feature map. This feature map highlights the vertical contour structure of the white-feathered chicken, such as the lines of the chicken's legs, the boundary between the neck and torso, and the changes in feather texture in a vertical posture. Simultaneously, the multi-scale fusion features are subjected to a sliding-window convolution operation with the Sobel y convolution kernel to obtain a vertical gradient feature map. This feature map focuses on characterizing the horizontal contour information of the white-feathered chicken, such as the back curve, wing edges, and texture transitions in horizontally overlapping areas. After obtaining the horizontal and vertical gradient features, the edge branches further perform a directional gradient fusion operation. Considering the non-uniformity of light direction and the reflective properties of white feathers in actual poultry house monitoring environments, the reliability of gradient features from different directions may vary. Optionally, a weighted summation fusion strategy can be adopted, introducing learnable scalar weight coefficients. and The horizontal gradient features and vertical gradient features are linearly weighted and combined, i.e. This fusion method allows the network to adaptively adjust the contribution ratio of the two directional gradient components based on the illumination distribution and chicken pose features of the input image during training, thereby obtaining edge texture features that are more robust to illumination changes.
[0019] For example, the context branch is used to input the multi-scale fused features into adaptive average pooling branches with scales of 1×1, 2×2, and 3×3 for pooling processing to obtain a first low-frequency pooling feature, a second low-frequency pooling feature, and a third low-frequency pooling feature; the first low-frequency pooling feature, the second low-frequency pooling feature, and the third low-frequency pooling feature are fused to obtain a fused low-frequency feature; the fused low-frequency feature is input into an adaptive average pooling unit with a scale of 6×6 for low-frequency semantic extraction to obtain multi-scale low-frequency semantic features; bilinear interpolation upsampling is performed on the multi-scale low-frequency semantic features, and the upsampling result is concatenated with the multi-scale fused features to obtain global semantic features. Specifically, the context branch first uses a parallel multi-scale pooling structure to perform preliminary context information collection on the multi-scale fused features. The multi-scale fused features are input into adaptive average pooling branches with scales of 1×1, 2×2, and 3×3, respectively. Each branch divides the input feature map into grid regions of corresponding sizes and averages the feature values within each grid, thereby compressing the feature map to different spatial resolutions. The 1×1 pooling branch is essentially a global average pooling operation, compressing the entire feature map into a single spatial point and extracting the most macroscopic global statistical information, which helps to perceive the overall density level and distribution trend of chickens in the entire image. The 2×2 pooling branch divides the feature map into four regions, capturing coarse-grained region-level semantics, reflecting the relative density of chickens in different quadrants. The 3×3 pooling branch provides finer-grained partitioning information, with good characterization of local cluster centers and sparse transition regions. After the above parallel pooling processing, the first, second, and third low-frequency pooling features are obtained. Subsequently, the first, second, and third low-frequency pooling features are fused to obtain the fused low-frequency features. Optionally, the fusion operation can be implemented using element-wise addition or channel concatenation followed by convolution. The aim is to converge regional contextual information at different granularities into a single feature representation, ensuring that the fused feature contains both a global statistical overview and retains some spatial differences. Subsequently, the fused low-frequency features are input into a 6×6 adaptive average pooling unit for deeper low-frequency semantic extraction. The 6×6 pooling operation further compresses the feature map, filtering out remaining high-frequency details and local fluctuations, retaining only the most stable low-frequency semantic components. The features extracted at this level correspond to the most macroscopic scene structure information in the image, providing robust scene priors for subsequent density estimation. Finally, bilinear interpolation upsampling is performed on the extracted multi-scale low-frequency semantic features to restore their spatial resolution to match the original multi-scale fused features. The upsampling result is then concatenated with the multi-scale fused features along the channel dimension to obtain the global semantic features. By fusing deep low-frequency semantic information with the original multi-scale features, the global semantic features achieve complementary advantages between local details and global context.After the multi-scale fusion features are processed by edge branch to extract edge texture features and context branch to extract global semantic features, the edge texture features and global semantic features are fused to obtain enhanced fusion features. Optionally, this fusion can be performed by first concatenating along the channel dimension and then using convolutional layers for feature interaction and dimensionality reduction. Through this fusion operation, the enhanced fusion features achieve deep coupling between edge contour response and global context semantics, enabling the feature representation to simultaneously possess accurate individual localization capabilities and stable density perception capabilities in complex poultry house environments with mixed high and low densities, laying a solid foundation for density regression in the density estimation branch.
[0020] Step 130: Input the enhanced fusion features into the density estimation branch, perform information richness evaluation and separation extraction of the first spatial information feature and the second spatial information feature through the spatial information decoupling unit, and send the first spatial information feature and the second spatial information feature into the channel semantic refinement unit to obtain local density features through separation and fusion strategies.
[0021] To effectively suppress background noise and feature redundancy in low-resolution images while preserving the edge response of individual white-feathered chickens, the enhanced fusion feature input density estimation branch needs to be used. The spatial information decoupling unit evaluates and separates the information richness of each location in the feature map. Then, the channel semantic refinement unit is used to adaptively weight and reorganize the separated features to obtain more discriminative local density features, providing a high-quality intermediate representation for subsequent accurate center point regression and counting.
[0022] For example, the spatial decoupling unit is used to normalize the enhanced fusion features and generate spatial weights based on the normalized feature responses; it then maps the spatial weights using an activation function to obtain a weight matrix; it compares each element value in the weight matrix with a preset threshold, assigning a value of 1 to elements greater than the preset threshold and a value of 0 to elements less than or equal to the preset threshold, thus obtaining a binary separation mask; it uses the binary separation mask to filter the enhanced fusion features, outputting a first spatial information feature and a second spatial information feature. The first spatial information feature contains rich information about the white-feathered chicken target, while the second spatial information feature contains less semantic information. Specifically, the spatial information decoupling unit first normalizes the input enhanced fusion features, mapping the feature values to a uniform numerical range to eliminate scale differences in feature responses between different channels, ensuring the stability and consistency of subsequent weight generation. Subsequently, it generates spatial weights based on the normalized feature responses. These spatial weights reflect the richness of information contained in each spatial location of the feature map. In the area where the white-feathered chicken individual is located, due to the denser visual cues such as contours and textures, its feature responses are usually more significant, resulting in higher spatial weight values. In background areas such as reflective surfaces, blank walls, or material lines, the feature response is relatively weak, resulting in lower spatial weight values. Next, an activation function is applied to these spatial weights, compressing the weight values to the [0,1] interval to obtain a smooth and continuous weight matrix. The value of each element in this weight matrix represents the probability estimate that the corresponding spatial location belongs to the foreground target region. To further achieve clear foreground and background separation, the spatial information decoupling unit compares each element value in the weight matrix with a preset threshold. Elements greater than the preset threshold are assigned a value of 1, indicating that the location is determined to be a foreground region. Elements less than or equal to the preset threshold are assigned a value of 0, indicating that the location is determined to be a background region. This generates a binary separation mask, which uses a hard decision method to spatially divide the target region and non-target region. Finally, the binary separation mask is used to spatially screen the enhanced fusion features. The feature vectors corresponding to locations with a mask value of 1 are assigned to the first spatial information feature. This feature mainly covers the area where the white-feathered chicken individual is located, containing rich edge contours, texture details, and target semantic information. The feature vectors corresponding to positions with a mask value of 0 are assigned to the second spatial information feature. This part of the feature mainly corresponds to the background and noise regions and contains less semantic information related to the counting task. Through the above spatial information decoupling process, the enhanced fusion feature is split into two branches with significant differences in semantic abundance, providing a structured input for the subsequent channel semantic refinement unit.
[0023] For example, the channel semantic refinement unit is used to perform channel compression and feature transformation processing on the first spatial information features, and output the first branch features. The second spatial information features are subjected to channel compression and background redundancy suppression processing to output the second branch features. The first branch features Second branch characteristics The joint features are concatenated along the channel dimension; adaptive average pooling is then applied to the joint features to obtain the weight vector. ; the weight vector Decomposed into features corresponding to the first branch First weight and corresponding to the second branch feature Second weight Based on the first weight Second weight For the characteristics of the first branch Second branch characteristics Weighted aggregation is performed to obtain local density features. Specifically, the channel semantic refinement unit first performs differentiated preprocessing operations on the first spatial information feature and the second spatial information feature. For the first spatial information feature, which contains rich information about the white-feathered chicken target, it is input into the upper branch for channel compression and feature transformation. This branch performs channel dimensionality reduction and nonlinear mapping on the input features through convolutional layers or fully connected layers, compressing redundant channels while retaining discriminative semantic information closely related to the white-feathered chicken count, and outputting the first branch features. For the second spatial information features containing limited semantic information, channel compression and background redundancy suppression are applied to the lower branch. Based on channel compression, the lower branch multiplies the features channel-by-channel with a learnable channel attenuation vector. This allows the network to adaptively attenuate the pure noise channel response to near zero, actively reducing the interference of background noise on subsequent density regression, and outputting the second branch features. Through the above dual-branch differentiation processing, Focusing on the refined expression of future goals, This is then constrained to a low-response background residual representation. Subsequently, the first branch features are... Features of the second branch The features are concatenated along the channel dimension to obtain joint features. These joint features simultaneously carry strong semantic information from the foreground branches and weak response signals from the background branches, providing a global view for subsequent weight allocation. Next, adaptive average pooling is performed on the joint features, compressing the feature map of each channel into a single scalar value, resulting in a weight vector of the same length as the number of channels. The weight vector Each element in the vector corresponds to the global statistical strength of a certain channel in the joint features, reflecting the average response level of that channel across the entire space. Further, the weight vector... according to and The channel division method is decomposed into two parts, corresponding to the characteristics of the first branch. First weight and the features corresponding to the second branch Second weight Finally, based on the first weight Second weight A soft attention weighted aggregation strategy is used to fuse the features of the two branches to obtain local density features. Its weighted aggregation method is as follows: This formula uses an activation function to weight... and Normalization to a probability distribution with a sum of 1 creates a competitive relationship between the contributions of the two branches in each channel. Since Softmax normalization ensures the smoothness and mutual exclusivity of the weights, this fusion method effectively suppresses background redundancy while preserving foreground target discrimination information, and avoids information loss that may result from hard truncation. Through the three-stage processing flow of differential preprocessing, joint weight generation, and soft attention weighted aggregation, the channel semantic refinement unit adaptively fuses the two spatially decoupled features into local density features, accurately reflecting the distribution density of white-feathered chicken targets in various local regions of the image, providing high-quality density prior information for subsequent global regression branches in the state space.
[0024] Step 140: Generate position encoding information based on the two-dimensional spatial coordinates corresponding to the local density features, and then process the position encoding information through mapping to obtain mapped position encoding information.
[0025] Location encoding information is an auxiliary feature representation used to explicitly inject prior two-dimensional spatial coordinates. Its role is to provide the subsequent state-space model with a reference for the absolute or relative position of each spatial location of the feature map in the original image. In the broiler counting task, since the state-space global regression branch unfolds the two-dimensional feature map into a one-dimensional sequence for processing, the model naturally loses its ability to perceive the spatial location of features. The introduction of location encoding information can effectively make up for this deficiency, enabling the network to accurately distinguish broiler targets located in different areas of the image during sequence modeling, thereby correctly capturing the spatial proximity relationship and global density distribution pattern between individuals.
[0026] For example, a local density feature is an image of size [size missing]. The feature map, where each spatial location Each coordinate corresponds to a unique two-dimensional coordinate in the original image or the feature space after downsampling. First, a coordinate grid with the same size as the local density feature space is constructed, generating normalized X-axis and Y-axis coordinate maps respectively. Then, a sine / cosine position encoding function can be used to map each coordinate to a high-dimensional space, generating position encoding information with the same number of channels as the local density features. To enable fusion with the local density features in the channel dimension, the position encoding information needs to be mapped. Optionally, a 1×1 convolutional layer or a fully connected layer can be used to adjust the number of channels in the position encoding to match the local density features, obtaining mapped position encoding information, thus achieving dimension alignment. The dimension-aligned mapped position encoding information is then concatenated with or element-wise added to the local density features along the channel dimension, forming the input to the global regression branch of the state space. This input carries the local density prior from the density estimation branch and embeds explicit spatial coordinate information, enabling the Mamba encoder to fully combine spatial location and density distribution when scanning along multiple directions, accurately extracting the long-range spatial dependencies between white-feathered chicken targets, and effectively solving the problem of spatial information loss caused by feature serialization.
[0027] Step 150: The local density features are fused with the mapping location encoding information, and the global dependency relationship between white-feathered chicken targets is extracted from the state space global regression branch to generate global association features.
[0028] Since the local density features output by the density estimation branch mainly reflect the flock density in each local area and lack explicit modeling capabilities for spatial relationships between distant targets within the poultry house, a state-space global regression branch is needed to overcome the limitations of the local receptive field. For example, the local density features are first fused with the mapped location encoding information to obtain the initial input features. This fusion operation is typically implemented using channel concatenation or element-wise addition, ensuring that the initial input features inherit the local density prior from the density estimation branch while also embedding explicit two-dimensional spatial coordinate information, providing a comprehensive representation with both semantic and spatial references for subsequent sequence modeling. Simultaneously, the local density features are convolved to obtain local density prior features. These prior features are further refined using lightweight convolutional layers to extract robust density patterns closely related to the target spatial distribution, serving as stable prior guidance information throughout the entire state-space global regression branch. Subsequently, the initial input features and local density prior features are input into the state-space global regression branch, which consists of multiple cascaded network layers. For the first cascaded network layer, the initial input features are first fused with the local density prior features to obtain the fused features of the first-level network layer. Then, a two-dimensional selective scanning mechanism is used to model this fused feature, unfolding the two-dimensional feature map into a one-dimensional sequence along four directions: top-left to bottom-right, bottom-right to top-left, top-right to bottom-left, and bottom-left to top-right. The time-step features in each direction's one-dimensional sequence are then analyzed. This corresponds to a spatial location feature of the fused feature of the current layer in the corresponding scanning direction. For a one-dimensional sequence in each direction, the features at each time step are recursively modeled according to the discretized state space update relationship, and their hidden states... and output features satisfy: ,in, , and The discretized state transition parameters and projection parameters, dependent on the current input, are responsible for controlling the degree of retention of historical information, the fusion method of the current input, and the mapping relationship to the output features. Through this state space recursion, the output at the current position... It depends not only on the input at the current time step It also hides its state. Information from all preceding positions along the scanning direction is selectively aggregated to establish long-range spatial dependencies between broiler targets. After sequence modeling in each direction, the output sequence is mapped back to a two-dimensional feature map according to the original spatial position. The recovered results from the four directions are then added and fused to obtain the output features of the first-level network layer. The output features of the first-level network layer are then used as new initial input features and fused again with local density prior features, and the above modeling process is repeated. After n iterations of cascaded network layers, each layer further expands the receptive field and deepens the extraction of global dependencies based on the previous layer. Finally, the output features of the last cascaded network layer are used as the global correlation feature. This global correlation feature combines spatial distribution information from local density estimation with long-range dependencies from multi-directional state space modeling, accurately depicting the overall spatial structure of broiler targets in the poultry house image.
[0029] Step 160: Input the global correlation feature into the decoder for decoding, output the predicted center point coordinates of the white-feathered chickens, and obtain the total number of white-feathered chickens based on the predicted center point coordinates of the white-feathered chickens.
[0030] The decoder, located after the global regression branch in the state space, is a lightweight prediction head structure used to transform globally correlated features into the final counting result. Its main function is to predict the probability that each pixel location belongs to the center point of a broiler chicken and the corresponding sub-pixel coordinate offset through parallel classification and regression branches. For example, the globally correlated features obtained in step 150 can be used as input. First, the features are decoded through a series of convolutional layers and upsampling operations to gradually restore the spatial resolution of the feature map, making its size approximate the original input image or a preset output scale to obtain more refined spatial location information. Subsequently, a classification head and a regression head are connected in parallel at the end of the decoder. The classification head outputs a channel-based category response heatmap for each spatial location in the decoded feature map, representing the confidence that the location belongs to the center point of the broiler chicken. The regression head outputs the center point coordinate offsets of two channels to compensate for the coordinate quantization error caused by feature downsampling, achieving sub-pixel-level precise localization. Based on this, local peak detection is performed on the heatmap output by the classification head to filter out candidate center point locations with response values higher than a preset threshold. The candidate coordinates are then corrected using the corresponding offset output by the regression head, ultimately obtaining the predicted center point coordinates for each white-feathered chicken. Based on the total number of predicted center point coordinates, the accurate total number of white-feathered chickens in the current monitoring image is output. The decoder unifies center point localization and counting tasks within an end-to-end trainable framework, maintaining high counting accuracy and localization robustness even in densely occluded scenes.
[0031] It should be noted that during the training phase, the Hungarian algorithm is first used to establish an optimal binary classification matching relationship between the set of predicted center points and the set of ground truth labeled center points, thus determining a one-to-one correspondence between predicted and ground truth points. Based on the optimal matching relationship, the classification loss and coordinate regression loss are calculated separately, and the counting loss based on the mean squared error is calculated based on the output counting results and the ground truth density map. Subsequently, a joint loss function is used to perform end-to-end joint optimization of the parameters of each branch of the network. The joint loss function is expressed as: , among which, among which, This is a counting loss based on mean square error, used to constrain the overall deviation between the counting result and the true count. The binary cross-entropy loss is used to supervise the classification head's confidence prediction of the center point location. The coordinate regression loss is used to optimize the offset between the predicted center point coordinates and the true coordinates. The counting loss weight coefficient is used to balance the magnitude difference between the counting loss and other loss terms. Through the above multi-task joint optimization mechanism, the network can maintain a global awareness of the overall flock size while learning to accurately locate the individual center point, effectively improving the counting accuracy and localization robustness in dense scenes.
[0032] To verify the effectiveness of this embodiment, monitoring images of broiler chickens with different density distributions were selected as the experimental dataset, covering image samples from both high-density clustering areas and low-density distribution areas, to comprehensively evaluate the model's counting performance under different crowding levels. Figure 2 As shown, the overall network architecture of this embodiment is compared with existing counting methods MFF, P2PNet, MAN, and CCST under the same dataset, the same number of training rounds, and the same hardware environment. Mean absolute error (MAE) and mean squared error (MSE) are used as performance evaluation metrics. MAE measures the average deviation between the predicted and actual numbers, while MSE assesses the degree of error fluctuation to reflect the model's stability in dense scenes. The experimental results are shown in the table below: The method of this invention achieves a MAE of 3.01 and an MSE of 4.21, both significantly outperforming the comparative methods, with an accuracy improved to 96.46%. These results demonstrate that the method of this invention, through multi-scale feature extraction, dual edge and context enhancement, spatial and channel decoupling refinement, and state-space global regression, effectively overcomes the counting challenges caused by dense occlusion of broiler chickens, glare from white feathers, and low-resolution monitoring. It exhibits superior counting accuracy and robustness in complex poultry house environments with mixed high and low densities.
[0033] In this embodiment, the image of the white-feathered chicken is processed by a multi-scale feature extraction module to obtain multi-scale fusion features. These multi-scale fusion features are then input into an edge branch for edge texture feature extraction and into a context branch for global semantic feature extraction. The edge texture features and global semantic features are then fused to obtain enhanced fusion features. These enhanced fusion features are input into a density estimation branch, where a spatial information decoupling unit performs information richness evaluation and separation to extract first and second spatial information features. These first and second spatial information features are then fed into a channel semantic refinement unit, where a separation and fusion strategy is used to obtain local density features. Position encoding information is generated based on the two-dimensional spatial coordinates corresponding to the local density features. This position encoding information is then mapped to obtain mapped position encoding information. The local density features and the mapped position encoding information are fused and input into a state space global regression branch to extract the global dependency between the white-feathered chicken targets, generating global association features. These global association features are then input into a decoder for decoding, outputting the predicted center point coordinates of the white-feathered chickens. The total number of white-feathered chickens is then determined based on these predicted center point coordinates. By combining multi-scale feature extraction and edge context enhancement, density estimation with spatial information decoupling and channel semantic refinement, and by introducing position encoding and state space global regression to capture long-range dependencies between targets, high-precision counting of white-feathered chickens in low-resolution dense scenes can be achieved.
[0034] Example 2 Figure 3 This is a schematic diagram of the structure of the white-feathered chicken counting device based on image enhancement density estimation provided in Embodiment 2 of the present invention, as shown below. Figure 3 As shown, the device includes: The multi-scale fusion feature extraction module 210 is used to process the white-feathered chicken image through the multi-scale feature extraction module to obtain multi-scale fusion features; The edge and context feature extraction module 220 is used to input the multi-scale fusion feature into the edge branch to extract edge texture features, input the multi-scale fusion feature into the context branch to extract global semantic features, and fuse the edge texture features and global semantic features to obtain enhanced fusion features; The local density feature extraction module 230 is used to input the enhanced fusion features into the density estimation branch, and extract the first spatial information feature and the second spatial information feature through the spatial information decoupling unit for information richness evaluation and separation. The first spatial information feature and the second spatial information feature are then sent to the channel semantic refinement unit to obtain local density features through separation and fusion strategies. The mapping position encoding information acquisition module 240 is used to generate position encoding information based on the two-dimensional spatial coordinates corresponding to the local density features, and to obtain mapped position encoding information by mapping the position encoding information. The global association feature acquisition module 250 is used to fuse the local density features with the mapping position encoding information, and extract the global dependency relationship between white-feathered chicken targets from the state space global regression branch to generate global association features; The total number calculation module 260 is used to input the global correlation features into the decoder for decoding, output the predicted center point coordinates of the white-feathered chickens, and obtain the total number of white-feathered chickens based on the predicted center point coordinates of the white-feathered chickens.
[0035] The broiler counting device based on image-enhanced density estimation provided in this embodiment processes the broiler image through a multi-scale feature extraction module to obtain multi-scale fusion features. The multi-scale fusion features are then input into an edge branch for edge texture feature extraction and into a context branch for global semantic feature extraction. The edge texture features and global semantic features are fused to obtain enhanced fusion features. These enhanced fusion features are then input into a density estimation branch, where a spatial information decoupling unit performs information richness evaluation and separation to extract first and second spatial information features. These first and second spatial information features are then fed into a channel semantic refinement unit, where a separation and fusion strategy is used to obtain local density features. Position encoding information is generated based on the two-dimensional spatial coordinates corresponding to the local density features. This position encoding information is then mapped to obtain mapped position encoding information. The local density features and the mapped position encoding information are fused and input into a state space global regression branch to extract global dependencies between broiler targets, generating global association features. These global association features are then input into a decoder for decoding, outputting the predicted center point coordinates of the broilers. The total number of broilers is then determined based on these predicted center point coordinates. By combining multi-scale feature extraction and edge context enhancement, density estimation with spatial information decoupling and channel semantic refinement, and by introducing position encoding and state space global regression to capture long-range dependencies between targets, high-precision counting of white-feathered chickens in low-resolution dense scenes can be achieved.
[0036] Based on the above embodiments, the global association feature acquisition module includes: A fusion unit is used to fuse the local density features with the mapping position encoding information to obtain initial input features; A convolutional unit is used to perform convolution processing on the local density features to obtain local density prior features; The extraction unit is used to input the initial input features and local density prior features into the state space global regression branch to extract the global spatial dependency relationship between the white-feathered chicken targets, and obtain the global association features.
[0037] Example 3 Figure 4 This is a schematic diagram of the structure of a server provided in Embodiment 3 of the present invention. Figure 4 A block diagram is shown of an exemplary server 12 suitable for implementing embodiments of the present invention. Figure 4 The server 12 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0038] like Figure 4 As shown, server 12 is presented in the form of a general-purpose computing server. The components of server 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0039] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0040] Server 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by server 12, including volatile and non-volatile media, removable and non-removable media.
[0041] System memory 28 may include computer system readable media in the form of volatile memory, such as RAM 30 and / or cache 32. Server 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 Not shown; usually referred to as a "hard drive"). Although Figure 4Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0042] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0043] Server 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing server, display 24, etc.), and with one or more servers that enable users to interact with server 12, and / or with any server (e.g., network card, modem, etc.) that enables server 12 to communicate with one or more other computing servers. This communication can be performed via I / O interface 22. Furthermore, server 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of server 12 via bus 18. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with server 12, including but not limited to: microcode, server drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0044] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the white-feathered chicken counting method based on image enhancement density estimation provided in the embodiments of the present invention.
[0045] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for counting broiler chickens based on image-enhanced density estimation, characterized in that, include: The white-feathered chicken images are processed by a multi-scale feature extraction module to obtain multi-scale fused features; The multi-scale fusion features are input into the edge branch to extract edge texture features, and the multi-scale fusion features are input into the context branch to extract global semantic features. The edge texture features and global semantic features are then fused to obtain enhanced fusion features. The enhanced fusion features are input into the density estimation branch, and the information richness is evaluated and the first spatial information feature and the second spatial information feature are extracted through the spatial information decoupling unit. The first spatial information feature and the second spatial information feature are then sent to the channel semantic refinement unit, and the local density features are obtained through the separation and fusion strategy. Based on the two-dimensional spatial coordinates corresponding to the local density features, position encoding information is generated, and the position encoding information is mapped to obtain mapped position encoding information. The local density features are fused with the mapping location encoding information, and the global dependency between white-feathered chicken targets is extracted by inputting the state space global regression branch to generate global association features; The global correlation features are input into the decoder for decoding, and the predicted center point coordinates of the white-feathered chickens are output. The total number of white-feathered chickens is obtained based on the predicted center point coordinates of the white-feathered chickens.
2. The method for counting broiler chickens based on image enhancement density estimation according to claim 1, characterized in that, The multi-scale feature extraction module is used for: The white-feathered chicken image is downsampled layer by layer to generate multi-layer Gaussian pyramid features of different scales. Based on the multi-layered Gaussian pyramid features at different scales, upsampling and difference operations are used to obtain the multi-layered Laplacian pyramid features. The features of the multi-layer Laplacian pyramid are size aligned, and the aligned features are input into the progressive fusion path. The feature interaction and compression are performed across scales by the depthwise separable convolution module to obtain multi-scale fused features.
3. The method for counting broiler chickens based on image enhancement density estimation according to claim 1, characterized in that, The edge branch is used for: The multi-scale fused features are then subjected to horizontal gradient extraction using the Sobel x operator to obtain horizontal gradient features. The multi-scale fused features are subjected to vertical gradient extraction using the Sobel y operator to obtain vertical gradient features; The horizontal gradient features and vertical gradient features are weighted and summed to obtain the edge texture features.
4. The method for counting broiler chickens based on image enhancement density estimation according to claim 1, characterized in that, The context branch is used for: The multi-scale fusion features are respectively input into adaptive average pooling branches with scales of 1×1, 2×2 and 3×3 for pooling processing to obtain the first low-frequency pooling feature, the second low-frequency pooling feature and the third low-frequency pooling feature. The first low-frequency pooling feature, the second low-frequency pooling feature, and the third low-frequency pooling feature are fused to obtain a fused low-frequency feature; The fused low-frequency features are input into an adaptive average pooling unit with a scale of 6×6 for low-frequency semantic extraction to obtain multi-scale low-frequency semantic features. A bilinear interpolation upsampling operation is performed on the multi-scale low-frequency semantic features, and the upsampling result is concatenated with the multi-scale fused features to obtain global semantic features.
5. The method for counting broiler chickens based on image enhancement density estimation according to claim 1, characterized in that, The process of fusing the local density features with the mapped position encoding information and extracting the global dependencies between white-feathered chicken targets from the state space global regression branch to generate global association features includes: The local density features are fused with the mapping location encoding information to obtain the initial input features; The local density features are convolved to obtain the local density prior features; The initial input features and local density prior features are input into the state space global regression branch to extract the global spatial dependency between white-feathered chicken targets, thus obtaining global association features.
6. The method for counting broiler chickens based on image enhancement density estimation according to claim 5, characterized in that, The state-space global regression branch includes: Cascaded network layers are used for: The initial input features are fused with the local density prior features to obtain the fused features of the first cascaded network layer. The fusion features of the first cascaded network layer are modeled using a two-dimensional selective scanning mechanism. The features are expanded into one-dimensional sequences along four directions. The one-dimensional sequences in each direction are modeled according to the discretized state space update relationship. The output sequences in each direction are restored to two-dimensional feature maps and then added and fused to obtain the output features of the first cascaded network layer. The output features of the first cascaded network layer are used as new initial input features. The feature fusion and modeling steps are repeated n times, and the output features of the final cascaded network layer are used as the global correlation features.
7. The method for counting broiler chickens based on image enhancement density estimation according to claim 1, characterized in that, The spatial information decoupling unit is used for: The enhanced fusion features are normalized, and spatial weights are generated based on the normalized feature responses. The spatial weights are mapped using activation functions to obtain a weight matrix; The values of each element in the weight matrix are compared with a preset threshold. Elements that are greater than the preset threshold are assigned a value of 1, and elements that are less than or equal to the preset threshold are assigned a value of 0, thus obtaining a binary separation mask. The enhanced fusion features are screened using the binary separation mask to output a first spatial information feature and a second spatial information feature. The first spatial information feature contains rich white-feathered chicken target information, while the second spatial information feature contains less semantic information.
8. The method for counting broiler chickens based on image enhancement density estimation according to claim 1, characterized in that, The channel semantic refinement unit is used for: The first spatial information features are subjected to channel compression and feature transformation processing to output the first branch features. ; The second spatial information feature is subjected to channel compression and background redundancy suppression processing to output the second branch feature. ; The first branch features Second branch characteristics By concatenating along the channel dimension, joint features are obtained; Adaptive average pooling is applied to the joint features to obtain the weight vector. ; The weight vector Decomposed into features corresponding to the first branch First weight and corresponding to the second branch feature Second weight ; Based on the first weight Second weight For the characteristics of the first branch Second branch characteristics Weighted aggregation is performed to obtain local density features. The weighted aggregation method is as follows: in, Represents local density features. As the first weight, As the second weight, Features of the first branch This is a characteristic of the second branch.
9. A broiler chicken counting device based on image enhancement density estimation, characterized in that, include: The multi-scale fusion feature extraction module is used to process the white-feathered chicken image through the multi-scale feature extraction module to obtain multi-scale fusion features; The edge and context feature extraction module is used to input the multi-scale fusion features into the edge branch to extract edge texture features, input the multi-scale fusion features into the context branch to extract global semantic features, and fuse the edge texture features and global semantic features to obtain enhanced fusion features; The local density feature extraction module is used to input the enhanced fusion features into the density estimation branch, and extract the first spatial information feature and the second spatial information feature by performing information richness evaluation and separation through the spatial information decoupling unit. The first spatial information feature and the second spatial information feature are then sent to the channel semantic refinement unit to obtain local density features through separation and fusion strategies. The mapping location encoding information acquisition module is used to generate location encoding information based on the two-dimensional spatial coordinates corresponding to the local density features, and to obtain mapped location encoding information by mapping the location encoding information. The global association feature acquisition module is used to fuse the local density features with the mapping position encoding information, and extract the global dependency relationship between white-feathered chicken targets from the state space global regression branch to generate global association features; The total number calculation module is used to input the global correlation features into the decoder for decoding, output the predicted center point coordinates of the white-feathered chickens, and obtain the total number of white-feathered chickens based on the predicted center point coordinates of the white-feathered chickens.
10. A server, characterized in that, The server includes: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the white-feathered chicken counting method based on image enhancement density estimation as described in any one of claims 1-8.