Methods, devices, equipment and storage media for nighttime rat detection

By using infrared camera capture, preprocessing, and a two-layer routing attention mechanism to analyze features, a nighttime mouse detection model is trained, solving the problems of low detection accuracy and susceptibility to interference in low-light environments of traditional methods, and achieving efficient and accurate mouse detection.

CN119049080BActive Publication Date: 2026-11-17HUBEI UNIV OF ARTS & SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411033384.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2026-11-17
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

Traditional nighttime mouse detection algorithms struggle to achieve high-precision and high-efficiency target detection in low-light environments and are susceptible to interference from complex backgrounds and noise, leading to missed detections and false detections.

Method used

Infrared cameras were used to capture images of mice at night under different conditions. Clear image sets were obtained through preprocessing, local features were extracted and normalized, and a two-layer routing attention mechanism was used to analyze the importance of features and assign weights to train a nighttime mouse detection model to detect the location of mice in real time.

Benefits of technology

It significantly improves the accuracy and efficiency of nighttime mouse detection, has stronger generalization and anti-interference capabilities, and solves the problems of low detection accuracy and susceptibility to interference in low-light environments of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119049080B_ABST
    Figure CN119049080B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for nighttime mouse detection, relating to the field of nighttime mouse detection technology. The disclosed method includes: preprocessing a set of nighttime mouse images to obtain a preprocessed nighttime mouse image set; obtaining a uniformly distributed local feature set of nighttime mouse images through normalization; analyzing the feature importance of the uniformly distributed local feature set of nighttime mouse images using a two-layer routing attention mechanism, and adding weights according to feature importance to obtain a nighttime mouse feature map set; obtaining a mouse location set based on the nighttime mouse feature map set, and training a nighttime mouse detection model based on the location set; and in a nighttime environment, detecting the environment in real time using an infrared camera, inputting the real-time environmental detection image into the nighttime mouse detection model to obtain the nighttime mouse detection result. This achieves the technical effect of efficient, fast, and accurate mouse detection and localization in complex nighttime environments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of nighttime rat detection technology, and in particular to nighttime rat detection methods, apparatus, equipment and storage media. Background Technology

[0002] Rats inhabit diverse environments, including urban, rural, and field areas, demonstrating remarkable adaptability. They reproduce rapidly and adapt to varying diets and living conditions, resulting in their widespread distribution in human living environments. However, rats carry various viruses and parasites, potentially spreading multiple infectious diseases and posing a potential threat to human health and quality of life. Nighttime is the most active time for rats, a time for them to forage, reproduce, and communicate. Identifying nocturnal rat behavior can provide valuable insights into their ecological habits and life cycles, offering significant practical and research value for observing their behavior and for preventing and controlling further negative impacts of rats on human life.

[0003] Traditional object detection algorithms employ methods such as feature extraction, image segmentation, and template matching. However, these algorithms struggle to distinguish between the target and the background, especially in nighttime environments where complex backgrounds and noise further complicate detection. Mice are typically small targets, and traditional algorithms perform poorly in detecting them, leading to both false positives and false negatives. Furthermore, traditional algorithms rely on predefined templates, which are ill-suited to the diverse morphologies and behaviors exhibited by mice in nighttime environments. Finally, traditional algorithms, such as sliding windows and template matching, have high computational complexity when dealing with high-resolution images, making real-time detection difficult. These issues hinder the high accuracy and efficiency of traditional algorithms for mouse detection in nighttime environments.

[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0005] The main purpose of this application is to provide a method, apparatus, device and storage medium for detecting mice at night, aiming to solve the technical problem that traditional nighttime mouse detection algorithms are difficult to achieve high-precision and high-efficiency target detection of mice in nighttime environments.

[0006] To achieve the above objectives, this application proposes a method for detecting mice at night. The method is applied to a detection device, which includes: a carrier board, a development kit, a silent roller, a speaker, a functional adapter board, and an infrared camera. The method includes:

[0007] The infrared camera captures images of mice at night under different conditions to obtain a set of nighttime mouse images. The set of nighttime mouse images is then preprocessed to obtain a preprocessed set of nighttime mouse images.

[0008] Local features of nighttime mouse images are extracted from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images;

[0009] By normalizing the local feature set of the nighttime mouse images, a uniformly distributed local feature set of the nighttime mouse images is obtained.

[0010] The feature importance of the local feature set of the uniformly distributed nighttime mouse images is analyzed by a two-layer routing attention mechanism, and weights are added according to the feature importance to obtain the nighttime mouse feature map set.

[0011] The location set of the mice is obtained based on the nighttime mouse feature map set, and a nighttime mouse detection model is trained based on the location set.

[0012] In a nighttime environment, the infrared camera detects the environment in real time to obtain real-time environmental detection images. These real-time environmental detection images are then input into the nighttime mouse detection model to obtain nighttime mouse detection results.

[0013] In one embodiment, the step of analyzing the feature importance of the uniformly distributed local feature set of nighttime mouse images through a two-layer routing attention mechanism, adding weights according to the feature importance, and obtaining the nighttime mouse feature map set according to the weights includes:

[0014] The local features in the uniformly distributed local feature set of nighttime mouse images are divided into blocks by a two-layer routing attention mechanism to obtain a preset number of feature blocks.

[0015] The target weight vector of the preset number of feature blocks is calculated using the weight matrix of the two-layer routing attention mechanism;

[0016] The domain matrix is ​​obtained based on the target weight vector;

[0017] The importance of the local features is analyzed based on the domain matrix, and weights are added according to the importance.

[0018] The local features are pooled according to the weights, and local features of different ranges are captured to obtain the pooling operation results.

[0019] The pooling operation results are subjected to feature fusion to obtain a nighttime mouse feature map set.

[0020] In one embodiment, the step of extracting local features from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images includes:

[0021] The preprocessed nighttime mouse image set is input into a convolutional layer. The convolutional layer slides the preprocessed nighttime mouse images in the preprocessed nighttime mouse image set according to a preset stride to identify mouse features in the preprocessed nighttime mouse images.

[0022] The mouse features are convolved by the convolutional layer to obtain local features and mouse location prediction boxes for the nighttime mouse image;

[0023] Based on the local features of the nighttime mouse image and the mouse location prediction box, a local feature set of the nighttime mouse image is obtained.

[0024] In one embodiment, the step of obtaining a uniformly distributed local feature set of nighttime mouse images by normalizing the local feature set of the nighttime mouse images includes:

[0025] The target normalized value of the local feature set of the nighttime mouse image is calculated through a normalization layer;

[0026] The local features of the nighttime mouse images in the local feature set of the nighttime mouse images are normalized according to the target normalization value to obtain a uniformly distributed local feature set of the nighttime mouse images.

[0027] In one embodiment, the step of obtaining the location set of mice based on the nighttime mouse feature map includes:

[0028] The mouse features in the nighttime mouse images are obtained based on the nighttime mouse feature atlas.

[0029] The coordinates of the mouse's true location bounding box are obtained based on the mouse's features;

[0030] The position of the mouse is obtained based on the coordinates of the mouse's actual location bounding box.

[0031] In one embodiment, after the step of obtaining the coordinates of the mouse's true location bounding box based on the mouse features, the method further includes:

[0032] The mouse location prediction box is obtained by using the local feature set of the nighttime mouse image;

[0033] Based on the predicted mouse location bounding box and the actual mouse location bounding box, the ratio of the area of ​​the intersection region to the area of ​​the merged region between the predicted mouse location bounding box and the actual mouse location bounding box is obtained.

[0034] The loss function is obtained based on the ratio and the positional information of the predicted mouse position bounding box and the actual mouse position bounding box;

[0035] The position of the mouse location prediction box is optimized based on the loss function.

[0036] In one embodiment, the step of taking pictures of mice at night under different conditions using the infrared camera to obtain a set of nighttime mouse images, and preprocessing the nighttime mouse image set to obtain a preprocessed set of nighttime mouse images includes:

[0037] The infrared camera is used to take pictures of mice at night under different conditions to obtain a set of pictures of mice at night. Blurry pictures of mice at night are removed from the set of pictures of mice at night to obtain a set of pictures of mice at night with a preset resolution.

[0038] The preset resolution nighttime mouse image set is labeled to obtain a labeled nighttime mouse image set;

[0039] The format of the marked nighttime mouse image set is converted to obtain a preprocessed nighttime mouse image set.

[0040] In addition, to achieve the above objectives, this application also proposes a nighttime rat detection device, which includes: a preprocessing module, used to take pictures of nighttime rats under different conditions using the infrared camera to obtain a nighttime rat image set, and to preprocess the nighttime rat image set to obtain a preprocessed nighttime rat image set;

[0041] The extraction module is used to extract local features of the nighttime mouse images in the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images.

[0042] The normalization module is used to normalize the local feature set of the nighttime mouse images to obtain a uniformly distributed local feature set of the nighttime mouse images.

[0043] The analysis module is used to analyze the feature importance of the local feature set of the uniformly distributed nighttime mouse images through a two-layer routing attention mechanism, add weights according to the feature importance, and obtain the nighttime mouse feature map set according to the weights.

[0044] The training module is used to obtain the location set of the mice based on the nighttime mouse feature map set, and to train the nighttime mouse detection model based on the location set.

[0045] The detection module is used to detect the environment in real time using the infrared camera at night, obtain real-time environmental detection images, and input the real-time environmental detection images into the nighttime mouse detection model to obtain nighttime mouse detection results.

[0046] In addition, to achieve the above objectives, this application also proposes a nighttime mouse detection device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the nighttime mouse detection method as described above.

[0047] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the nighttime mouse detection method described above.

[0048] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the nighttime mouse detection method described above.

[0049] One or more technical solutions proposed in this application have at least the following technical effects:

[0050] A clear image set of nighttime mice is obtained by capturing images of mice under different conditions using an infrared camera. These images are then preprocessed to extract local mouse features and normalized to ensure feature uniformity and comparability. Based on this, a two-layer routing attention mechanism is used to analyze these features, identify key features, and assign weights, thereby generating a nighttime mouse feature map set with high feature expressiveness. This feature map set is used to train a nighttime mouse detection model, achieving efficient and accurate mouse detection in complex nighttime environments. Compared with existing technologies, the method of this invention significantly improves the accuracy and efficiency of nighttime mouse detection, solves the problems of low detection accuracy and susceptibility to interference in low-light environments of traditional methods, and also possesses stronger generalization and anti-interference capabilities. Attached Figure Description

[0051] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

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

[0053] Figure 1 This is a flowchart illustrating Embodiment 1 of the nighttime rat detection method of this application;

[0054] Figure 2 This is a schematic diagram of the structure of the nighttime mouse detection device provided in Embodiment 1 of the nighttime mouse detection method of this application;

[0055] Figure 3 This is a schematic diagram of the nighttime mouse detection process provided in Embodiment 1 of the nighttime mouse detection method of this application;

[0056] Figure 4 This is a schematic diagram of the nighttime mouse detection effect provided in Embodiment 1 of the nighttime mouse detection method of this application;

[0057] Figure 5 This is a flowchart illustrating Embodiment 2 of the nighttime rat detection method of this application;

[0058] Figure 6 This is a schematic diagram of the module structure of the nighttime rat detection device according to an embodiment of this application;

[0059] Figure 7 This is a schematic diagram of the hardware operating environment involved in the nighttime mouse detection method in this application embodiment.

[0060] Explanation of icon numbers:

[0061] Carrier board 1; Development kit 2; Silent roller 3; Speaker 4; Functional adapter board 5; Infrared camera 6.

[0062] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0063] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0064] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0065] The main solution of this application embodiment is: to take pictures of mice at night under different conditions using the infrared camera to obtain a set of pictures of mice at night, and to preprocess the set of pictures of mice at night to obtain a preprocessed set of pictures of mice at night.

[0066] Local features of nighttime mouse images are extracted from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images;

[0067] By normalizing the local feature set of the nighttime mouse images, a uniformly distributed local feature set of the nighttime mouse images is obtained.

[0068] The feature importance of the local feature set of the uniformly distributed nighttime mouse images is analyzed by a two-layer routing attention mechanism, and weights are added according to the feature importance to obtain the nighttime mouse feature map set.

[0069] The location set of the mice is obtained based on the nighttime mouse feature map set, and a nighttime mouse detection model is trained based on the location set.

[0070] In a nighttime environment, the infrared camera detects the environment in real time to obtain real-time environmental detection images. These real-time environmental detection images are then input into the nighttime mouse detection model to obtain nighttime mouse detection results.

[0071] In this embodiment, for ease of description, the following description will focus on a nighttime mouse detection device.

[0072] Because existing target detection algorithms employ methods such as feature extraction, image segmentation, and template matching, traditional algorithms struggle to distinguish targets from the background. Nighttime environments often contain complex backgrounds and noise, further complicating target detection. Mice are typically small targets, and traditional algorithms perform poorly in detecting them, easily leading to missed detections and false positives. Traditional algorithms rely on predefined templates, but mice in nighttime environments may exhibit diverse morphologies and behaviors, making these templates difficult to handle. Traditional algorithms, such as sliding windows and template matching, have high computational complexity when dealing with high-resolution images, making them unsuitable for real-time detection. These issues hinder the high accuracy and efficiency of traditional algorithms for mouse detection in nighttime environments.

[0073] This application provides a solution for capturing clear nighttime mouse images using an infrared camera under different conditions. These images are then preprocessed to extract local mouse features and normalized to ensure feature uniformity and comparability. Based on this, a two-layer routing attention mechanism is used to analyze these features, identify key features, and assign weights, thereby generating a nighttime mouse feature map set with high feature expressiveness. This feature map set is then used to train a nighttime mouse detection model, achieving efficient and accurate mouse detection in complex nighttime environments. Compared to existing technologies, this invention significantly improves the accuracy and efficiency of nighttime mouse detection, solves the problems of low detection accuracy and susceptibility to interference in low-light environments using traditional methods, and also possesses stronger generalization and anti-interference capabilities.

[0074] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of performing the above functions, such as a nighttime mouse detection device. The following description uses a nighttime mouse detection device as an example to illustrate this embodiment and the subsequent embodiments.

[0075] Based on this, the embodiments of this application provide a method for detecting mice at night, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the nighttime mouse detection method of this application.

[0076] In this embodiment, the nighttime mouse detection method includes steps S10 to S60:

[0077] Step S10: Take pictures of mice at night under different conditions using the infrared camera to obtain a set of pictures of mice at night; preprocess the set of pictures of mice at night to obtain a preprocessed set of pictures of mice at night.

[0078] It should be noted that different conditions refer to filming mice in multiple different scenarios, recording mice in different movement patterns, and filming single targets and multiple targets at multiple distances from different angles.

[0079] The Nighttime Mouse Image Collection is a set of mouse images taken at night for subsequent analysis and processing. The nighttime mouse images in this collection have not been processed and may contain blurry images.

[0080] Additionally, it's important to note that preprocessing refers to a series of operations performed on an image before image analysis. The purpose is to improve image quality, reduce noise, enhance features, or convert the image into a format suitable for further analysis. Preprocessing actions may include image cropping, rotation, scaling, contrast enhancement, and deblurring.

[0081] The preprocessed nighttime mouse image set is a collection of images that have undergone preprocessing steps, resulting in higher image quality and making it more suitable for subsequent feature extraction and analysis.

[0082] Reference Figure 2 , Figure 2 This is a schematic diagram of the nighttime rat detection device of this application.

[0083] like Figure 2 As shown, the testing device includes: a carrier board 1, a development kit 2, a silent roller 3, a speaker 4, a functional adapter board 5, and an infrared camera 6.

[0084] It should be noted that the carrier plate 1 is the structural foundation of the testing device, used to support and fix other components. It is usually made of a robust and durable material, such as aluminum alloy, which not only provides the necessary mechanical support but also helps dissipate heat, ensuring stable operation of the equipment in various environments.

[0085] Development Kit 2 is the core component of the detection device, typically containing necessary hardware components such as a processor, memory, and input / output interfaces, as well as software for implementing the detection algorithm. The development kit integrates a deep learning model and related algorithms, enabling the processing and analysis of image data captured by the infrared camera 6, achieving automatic detection and tracking of mice at night.

[0086] The silent rollers 3 are the moving components of the testing device, enabling the entire unit to move easily without generating noise. This is especially important for nighttime use, as it does not disturb the testing environment, particularly in situations requiring quiet operation, such as libraries or residential areas. The rollers' design also ensures the stability and durability of the device, keeping it smooth during movement.

[0087] Speaker 4 serves as an alarm. When the system detects mouse activity, speaker 4 emits an audible warning, both to alert operators and to scare the mouse away. This feature enhances the practicality of the detection system, especially in applications requiring physical intervention to prevent damage from mice.

[0088] Functional adapter board 5 acts as a bridge connecting various components, allowing different modules to communicate and exchange data with development kit 2. This design improves the system's flexibility and scalability, enabling the addition or replacement of functional modules as needed to adapt to different application scenarios.

[0089] Infrared camera 6 is used to capture mouse activity at night or in low-light conditions. The infrared function allows the camera to operate normally in complete darkness, capturing clear images, which is crucial for nighttime mouse detection. The camera may also have autofocus and tracking capabilities, further enhancing the accuracy and efficiency of detection. In this embodiment, a XIAOMI CW400 outdoor camera can be used. This device has a 4-megapixel camera and an F1.6 aperture lens, capable of capturing 2.5K ultra-high-definition images with a resolution of 2560*1440 pixels. Its infrared night vision function uses two infrared lights for supplementary lighting to ensure clear nighttime shooting. This embodiment does not specifically limit the specific infrared camera device.

[0090] Step S20: Extract local features from the nighttime mouse images in the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images;

[0091] It should be noted that local features refer to the attributes or patterns of specific regions in an image. These features can be used to identify and distinguish different objects in the image. Local features typically include edges, corners, and textures.

[0092] Understandably, specific algorithms or models are used to identify and extract local features from images, which can then be used to train machine learning models to identify and detect specific objects in the images.

[0093] Additionally, it's important to note that the local feature set of nighttime mouse images refers to the collection of all local features extracted from a set of mouse images. These features can be used to train machine learning models to identify and detect specific objects in images.

[0094] Step S30: Normalize the local feature set of the nighttime mouse images to obtain a uniformly distributed local feature set of the nighttime mouse images;

[0095] It should be noted that normalization is a data preprocessing technique that aims to scale feature values ​​to a uniform numerical range, typically [0,1] or [-1,1]. Normalization helps accelerate model training, improves model convergence speed, and increases prediction accuracy.

[0096] Additionally, it should be noted that uniform distribution refers to adjusting all feature values ​​to a common numerical range, making different features numerically comparable. Uniform distribution helps the model treat each feature more fairly and avoids some features having a disproportionate impact on model training due to their large numerical range.

[0097] Understandably, a uniformly distributed local feature set of nighttime mouse images will include key local features in the mouse images, such as edges, textures, and shapes, and the values ​​of these features will be adjusted to a certain range, thereby improving the model's performance and prediction accuracy.

[0098] Step S40: Analyze the feature importance of the uniformly distributed local feature set of nighttime mouse images through a two-layer routing attention mechanism, add weights according to the feature importance, and obtain the nighttime mouse feature map set according to the weights;

[0099] It's important to note that the BiFormer attention mechanism is a deep learning attention mechanism that enhances the model's focus on key features by analyzing their importance. This mechanism typically involves two stages: a coarse global attention allocation and a fine-grained local attention allocation.

[0100] Additionally, it should be noted that weighting refers to assigning a weight value to each feature based on its importance, which can be used to obtain a nighttime mouse feature atlas.

[0101] Understandably, the Nighttime Mouse Feature Atlas refers to a set of mouse feature images that have undergone feature extraction and enhancement. These images highlight the key features of the target object and may contain additional weight information to guide model training and prediction.

[0102] Furthermore, it's understandable that feature importance analysis refers to the process of analyzing which features are most critical for the object detection task. By analyzing feature importance, the model can more effectively focus on those features that have the greatest impact on the detection results. Analyzing feature importance using the BiFormer attention mechanism involves recognizing specific behavioral patterns or morphological features of mice, such as contour changes during rapid movement.

[0103] Step S50: Obtain the location set of the mice based on the nighttime mouse feature map set, and train the nighttime mouse detection model based on the location set;

[0104] It should be noted that a location set refers to a set of data containing information such as the location of a mouse in an image. This location information is usually represented in coordinate form, such as the x and y coordinates (top left corner coordinates) of the mouse in the image, as well as width and height information, forming a bounding box.

[0105] It is understood that training a nighttime rat detection model based on the location set refers to training a deep learning model based on the extracted features and location information, enabling it to automatically detect and identify rats in the nighttime environment.

[0106] In this embodiment, the training of the mouse detection model will be based on the YOLOv5 model, a popular real-time object detection system that treats object detection as a regression problem, directly mapping image pixels to bounding box coordinates and class probabilities.

[0107] Step S60: In a nighttime environment, the environment is detected in real time by the infrared camera to obtain a real-time environment detection image. The real-time environment detection image is then input into the nighttime mouse detection model to obtain the nighttime mouse detection result.

[0108] It should be noted that nighttime environments refer to environments at night or in low-light conditions. In such environments, traditional visual monitoring methods may be limited, thus requiring specialized equipment and technology for monitoring. Nighttime environments include, but are not limited to, warehouses, fields, and residential areas, which may become habitats for rodents at night.

[0109] As is understandable, real-time monitoring refers to the process by which a system continuously monitors its environment and processes and analyzes the monitoring data in real time. Real-time monitoring is crucial for applications requiring rapid response, such as security monitoring and animal behavior research.

[0110] Additionally, it should be noted that real-time environmental detection images refer to images captured in real time at night by infrared cameras. These images contain real-time visual information about the environment, such as the location and behavior of mice.

[0111] Additionally, it is understandable that nighttime mouse detection results include mouse locations marked in real-time captured images, which are displayed on the images by bounding boxes, and may be accompanied by mouse category labels.

[0112] Reference Figure 3 , Figure 3 This is a schematic diagram of the nighttime rat detection process provided in Embodiment 1 of this application, as follows: Figure 3 As shown, a high-definition infrared camera monitors the area in real time within its detection range, capturing images of mice. When the camera detects a mouse, the system automatically identifies and determines "mouse presence." Subsequently, the device's motion function is activated, and the camera smoothly follows the mouse's movement, ensuring continuous and clear image capture. Simultaneously, the real-time image of the mouse is displayed on the screen, allowing the operator to observe its behavior. To further confirm the mouse's presence, the system inputs the captured images to a detection platform for further analysis. If the detection platform confirms the presence of a mouse, the device activates speaker 4 to emit a sound, deterring the mouse, while the camera continues to track its movement. Throughout this process, the device maintains real-time environmental monitoring to ensure timely detection and handling of mouse-related issues. If no mouse is detected, the system continues monitoring within its detection range, awaiting the next possible detection.

[0113] Reference Figure 4 , Figure 4 This is a schematic diagram of the nighttime mouse detection effect provided in Embodiment 1 of this application, as shown below. Figure 4 As shown, in a nighttime environment, once a mouse appears, a real-time image of the mouse will be captured and displayed, and the location of the mouse's appearance will be marked.

[0114] In one feasible implementation, step S10 may include steps S11 to S13:

[0115] Step S11: Take pictures of mice at night under different conditions using the infrared camera to obtain a set of mouse images at night. Remove blurry mouse images from the set of mouse images at night to obtain a set of mouse images at night with a preset resolution.

[0116] Understandably, removing blurry nighttime mouse images means deleting images from the nighttime mouse image collection that have poor image quality due to poor shooting conditions, including but not limited to motion blur and inaccurate focus.

[0117] Additionally, it's understandable that preset sharpness refers to the image quality standard set during the shooting and selection process. Only images that meet the preset sharpness standard will be retained for subsequent processing. The preset sharpness nighttime mouse image set is a collection of nighttime mouse images that meet the preset sharpness standard, and further processing will be carried out based on this image set.

[0118] Step S12: Mark the preset resolution nighttime mouse image set to obtain a marked nighttime mouse image set;

[0119] It's important to note that labeling refers to the process of explicitly identifying regions or objects of interest in an image. In machine learning and computer vision, labeling is often used to guide models in learning how to recognize and locate specific objects in an image.

[0120] In this embodiment, after the preset resolution nighttime mouse image set is sorted and labeled, the labelimg software is used for image annotation, converting the original image files into label files.

[0121] Additionally, it should be noted that the labeled nighttime mouse image set is a collection of labeled images of mice at night, each image containing a label. Images from this set will be used to train a deep learning model, enabling it to identify and locate mice in nighttime environments.

[0122] Step S13: Convert the format of the marked nighttime mouse image set to obtain a preprocessed nighttime mouse image set.

[0123] As is understandable, format conversion refers to converting an image and its annotation information into a specific format so that deep learning models can read and process it. The format conversion step usually involves converting the annotation information from one format to another.

[0124] In this embodiment, the labeled format is saved as YOLO format, and finally a new YOLO format dataset containing labels and images is obtained.

[0125] It should be noted that the preprocessed nighttime mouse image set is a set of nighttime mouse images that have undergone format conversion and further preprocessing. These images and their annotation information have been converted into a format suitable for training deep learning models, and subsequent processing can be performed based on this preprocessed nighttime mouse image set.

[0126] In one feasible implementation, step S20 may include steps S21 to S23:

[0127] Step S21: Input the preprocessed nighttime mouse image set into the convolutional layer, and slide the preprocessed nighttime mouse images in the preprocessed nighttime mouse image set according to a preset stride through the convolutional layer to identify mouse features in the preprocessed nighttime mouse images;

[0128] It's important to note that convolutional layers are fundamental components in deep learning used for feature extraction. They generate feature maps by convolving the input image with a set of learnable filters, or kernels. A convolutional layer may consist of multiple kernels, each responsible for extracting different features from the image, such as edges and textures.

[0129] Additionally, it's important to note that stride refers to the size of the convolutional kernel as it slides across the input image. A preset stride means that during training, the convolutional kernel moves with a fixed stride to cover the entire input image. The preset stride can be set manually, such as 2 pixels, meaning the convolutional kernel moves 2 pixels at a time, thus reducing the size of the feature map and improving computational efficiency.

[0130] As can be understood, sliding refers to the process of the convolutional kernel moving across the input image in strides. By sliding, the convolutional kernel can cover the entire image and extract local features. The convolutional layer slides across the preprocessed nighttime mouse image set, possibly starting from the top left corner of the image and gradually moving towards the bottom right until it covers the entire image.

[0131] Additionally, it is understandable that identifying mouse features refers to processing images through convolutional layers to extract features related to mice, such as body contours and fur texture.

[0132] Step S22: Convolve the mouse features through the convolutional layer to obtain the local features of the mouse image at night and the mouse location prediction box;

[0133] It's important to note that convolution is a mathematical operation that involves sliding a convolution kernel across an input image and calculating the dot product between the kernel and a local region of the image to generate a feature map. Convolution might involve using a 3x3 or 5x5 kernel to extract mouse features by convolving with a local region of the image.

[0134] Understandably, after processing by the convolutional layer, a bounding box, i.e., the mouse's predicted location box, will be generated, marking the mouse's position in the image. This bounding box typically includes the coordinates (x, y) of the mouse's center and the width and height of the box.

[0135] Step S23: Based on the local features of the nighttime mouse image and the mouse location prediction box, obtain the local feature set of the nighttime mouse image.

[0136] It should be noted that the local feature set of nighttime mouse images is a dataset that integrates local mouse features and predicted location boxes. The local features and predicted boxes of each image are combined to form a complete feature set, which is used for subsequent model training and object detection.

[0137] In one feasible implementation, step S30 may include steps S31 to S32:

[0138] Step S31: Calculate the target normalized value of the local feature set of the nighttime mouse image through a normalization layer;

[0139] It should be noted that the target normalized value refers to the feature value after normalization. These values ​​are adjusted to a uniform numerical range, making different features numerically comparable. In this embodiment, if the original feature value range is 0 to 255, such as image pixel values, it may be adjusted to the range of 0 to 1 after normalization. In this way, all feature values ​​are on the same scale, which is convenient for model processing.

[0140] Step S32: Normalize the local features of the nighttime mouse images in the local feature set of the nighttime mouse images according to the target normalization value to obtain a uniformly distributed local feature set of the nighttime mouse images.

[0141] Understandably, a uniform distribution refers to adjusting all feature values ​​to a common numerical range so that different features are numerically comparable.

[0142] Additionally, it is understandable that the uniformly distributed local feature set of nighttime mouse images is a normalized feature set where all feature values ​​are within a uniform numerical range, possibly including normalized edge features, texture features, and the coordinates of the predicted bounding boxes.

[0143] It should be noted that normalization is a data preprocessing technique that aims to adjust the numerical range of data to a specific interval. Normalization helps reduce the numerical differences between different features and improves the stability and effectiveness of model training.

[0144] In one feasible implementation, step S40 may include steps S41 to S46:

[0145] Step S41: The local features in the uniformly distributed local feature set of the nighttime mouse images are divided into blocks by a two-layer routing attention mechanism to obtain a preset number of feature blocks.

[0146] It should be noted that local feature segmentation refers to dividing local features in a feature set into multiple smaller blocks according to certain rules for more detailed processing. Each feature map is divided into multiple smaller blocks, each containing a certain number of pixels. These smaller blocks are then processed separately to extract more detailed feature information.

[0147] Additionally, it should be noted that the preset number of feature blocks refers to the number of small blocks pre-defined during the block segmentation process. These small blocks will be used in subsequent attention mechanism processing. For example, it may be pre-defined that each feature map is divided into 16 small blocks, each containing specific feature information.

[0148] It is understandable that for a feature map with height H, width W, and number of channels C, the purpose of block processing is to divide this continuous feature map into several small blocks, each containing a certain number of pixels and channel information.

[0149] Step S42: Calculate the target weight vector of the preset number of feature blocks using the weight matrix of the two-layer routing attention mechanism;

[0150] It's important to note that the Query plays the role of a "query" in the attention mechanism. It represents the currently processed feature block and is used to compare it with the Key to determine their relevance. The Key in the attention mechanism represents a "key" that is matched against the Query to determine the association between different feature blocks. The feature representation of the Key is typically used to evaluate its relevance to the Query and is the basis for calculating attention weights. The Value stores information associated with the Key in the attention mechanism. Once the relevance between the Query and Key is determined through attention weights, the information stored in the Value is weighted according to these weights to generate the final output features.

[0151] Understandably, Q(Query) is calculated as shown in Equation 1:

[0152] Q = X r W p (Equation 1)

[0153] In Equation 1 above, X r W is the feature block obtained after reshaping the input feature map X. p It is a learnable weight matrix used to convert feature blocks into corresponding Q values.

[0154] It is understandable that T(Key) is calculated as shown in Equation 2:

[0155] T = X r W k (Equation 2)

[0156] In equation 2 above, X r W is the feature block obtained after reshaping the input feature map X. k It is a learnable weight matrix used to transform feature blocks into their corresponding T.

[0157] Understandably, V(Value) is calculated as shown in Equation 3:

[0158] V = X r W v (Equation 3)

[0159] In equation 3 above, X r W is the feature block obtained after reshaping the input feature map X. v It is a learnable weight matrix used to convert feature blocks into corresponding V.

[0160] Step S43: Obtain the neighborhood matrix based on the target weight vector;

[0161] It's important to note that the domain matrix is ​​a mathematical structure, typically a two-dimensional matrix, where elements represent the correlation or association between different regions. In BiFormer, this matrix guides the attention mechanism, determining which regions should be prioritized during the computation process.

[0162] Understandably, the domain matrix is ​​calculated as shown in Equation 4:

[0163] A r =Q r (K r ) T (Equation 4)

[0164] In equation 4 above, Q r It is the average value of Q, K r It is the average value of K.

[0165] Step S44: Analyze the importance of the local features based on the neighborhood matrix, and add weights according to the importance;

[0166] It should be noted that the importance of local features refers to the degree to which different local features contribute to the identification and localization of targets in an object detection task. Using a neighborhood matrix, the model can analyze the relationship between each local feature and other features, determining its importance within the entire feature set.

[0167] It is understandable that weights are added based on the aforementioned importance as shown in Equation 5:

[0168] I r =topkIndex(A r (Equation 5)

[0169] In Equation 5 above, topkIndex is a function used to extract values ​​from matrix A. r In each row, select the indexes of the k most important values, where k is a hyperparameter representing the number of keys that should be focused on at each position or query. r It is an index matrix, with weights added based on the number of keys that should be monitored.

[0170] Step S45: Perform pooling operation on the local features according to the weights, and capture local features of different ranges to obtain the pooling operation result;

[0171] It's important to note that pooling is a common image processing operation used to reduce the spatial dimensionality of feature maps while preserving important feature information. Common pooling operations include max pooling and average pooling. Pooling operations can reduce the size of feature maps, lower computational complexity, and retain the main information in the feature maps, which helps the model to further process the features.

[0172] In this embodiment, the pooling operation represents the use of a pyramid-shaped pooling operation to capture features of different ranges, thereby expanding the feature receptive field of the model.

[0173] Step S46: Perform feature fusion on the pooling operation results to obtain a nighttime mouse feature map set.

[0174] It should be noted that feature fusion refers to integrating information from multiple feature maps to generate a more comprehensive representation. The steps of feature fusion typically involve merging feature maps of different scales or different parts.

[0175] It is understandable that feature fusion of the pooling operation results involves cascading and fusing pooling results of different sizes to improve the model's feature representation ability and classification performance, ultimately obtaining a nighttime mouse feature map set.

[0176] Additionally, it should be noted that the nighttime mouse feature map set refers to a set of feature maps obtained after feature extraction, attention mechanism processing, and feature fusion. These feature maps contain key information from nighttime mouse images and will be used to identify and locate mice in the nighttime environment.

[0177] This embodiment addresses the accuracy and efficiency issues of mouse detection in complex nighttime environments by employing deep learning techniques and a BiFormer (two-layer routing attention) mechanism. Specifically, it first captures images of mice at night under different conditions using an infrared camera, and generates a high-quality training dataset through preprocessing and labeling. Then, it extracts local features from the images using convolutional layers, and analyzes the importance of these features using normalization and the BiFormer mechanism, thereby generating a nighttime mouse feature map set with high feature representation capabilities. Finally, these feature maps are input into a trained nighttime mouse detection model, enabling real-time detection and localization of mice in nighttime environments. This method not only improves detection accuracy and robustness but also enhances the model's adaptability to different scenes and changes, achieving the beneficial effect of efficiently, quickly, and accurately detecting and localizing targets in complex nighttime environments.

[0178] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 5 After step S50, the nighttime mouse detection method may further include steps S51 to S53:

[0179] Step S51: Obtain mouse features in the nighttime mouse images based on the nighttime mouse feature set;

[0180] It should be noted that mouse features refer to attributes or patterns in an image that distinguish mice from other objects. These features can include the mouse's outline, fur texture, shape, etc.

[0181] Step S52: Obtain the coordinates of the mouse's true location bounding box based on the mouse features;

[0182] It should be noted that the bounding box refers to the rectangular box defining the position and size of a mouse in an image. The coordinates of the mouse's true location bounding box refer to the coordinates of the bounding box that best approximates the mouse's true location after model prediction and calibration.

[0183] Additionally, it is understood that obtaining the coordinates of the mouse's true location box based on the mouse's features means converting the extracted mouse features into specific spatial coordinates to determine the mouse's position in the image.

[0184] Step S53: Obtain the position of the mouse based on the coordinates of the mouse's actual position box.

[0185] Understandably, the coordinates of the mouse's ground truth bounding box represent the bounding box coordinates of the mouse's position in the image. These coordinates typically include the top-left corner coordinates (x_min, y_min) and bottom-right corner coordinates (x_max, y_max). If a mouse's bounding box has top-left corner coordinates of (50, 100) and bottom-right corner coordinates of (150, 200) in the image, then these four values ​​are the coordinates of the mouse's ground truth bounding box.

[0186] Additionally, it's understandable that the mouse's position refers to its specific location within the actual image or scene. This is typically represented by the coordinates of the center point of the bounding box (x_center, y_center), and can also be further described using the width and height of the bounding box.

[0187] In one feasible implementation, steps S54 to S57 are included after step S53:

[0188] Step S54: Obtain the mouse location prediction box through the local feature set of the nighttime mouse image;

[0189] It is understandable that mapping local features of a mouse image to a predicted mouse location bounding box means converting the extracted local features into specific spatial locations, thereby predicting the mouse's position in the image.

[0190] Step S55: Based on the predicted mouse position bounding box and the actual mouse position bounding box, obtain the ratio of the area of ​​the intersection region and the area of ​​the merged region between the predicted mouse position bounding box and the actual mouse position bounding box.

[0191] It is understandable that the ratio of the area of ​​the intersection region and the area of ​​the merged region between the predicted mouse location bounding box and the actual mouse location bounding box is calculated as follows: Equation 6:

[0192]

[0193] In Equation 6 above, A∩B represents the area of ​​the intersection region between the predicted mouse position box and the actual mouse position box, and A∪B represents the area of ​​the merged region between the predicted mouse position box and the actual mouse position box.

[0194] Step S56: Based on the ratio and the position information of the predicted mouse position box and the actual mouse position box, obtain the loss function;

[0195] Understandably, the loss function is calculated as shown in Equation 7:

[0196]

[0197] In equation 7 above, where b, b gtThese represent the center points of the predicted and ground truth bounding boxes, respectively. ρ represents the Euclidean distance between the two center points, and c is the diagonal distance of the smallest closed region that simultaneously contains both the predicted and ground truth bounding boxes. w and C h Let w and w represent the width and height of the minimum bounding rectangle, respectively. gt (h+h) represents the difference between the width of the predicted bounding box and the width of the target bounding box. gt The value L represents the difference in height between the predicted bounding box and the target bounding box. IOU L represents a variant of the crossover ratio loss. dis L represents the distance-related loss function. asp It is used to measure the distance between the center point of the predicted box and the center point of the ground truth box, and represents the loss function related to the asymmetry between the predicted box and the ground truth box. IOU represents the crossover ratio loss.

[0198] Step S57: Optimize the position of the mouse location prediction box according to the loss function.

[0199] Understandably, optimization refers to the process of minimizing the loss function by adjusting model parameters, thereby improving the accuracy of model predictions. The difference between the current predicted bounding box and the ground truth bounding box is calculated using the loss function. Based on the result of the loss function, the model's weights and biases are updated using the backpropagation algorithm. This process of repeatedly calculating the loss and updating parameters continues until the model performance reaches a satisfactory level.

[0200] This embodiment extracts local features from a dataset of nighttime rat images, then calculates the area ratio of intersecting and merged regions by comparing predicted and ground truth bounding boxes, thus deriving a loss function. Using this loss function, the model learns to adjust the position and size of the predicted bounding boxes to better match the ground truth bounding boxes. In this way, this embodiment improves the accuracy and efficiency of nighttime rat detection, achieving the beneficial effect of more effectively identifying and controlling rodent infestations in practical applications.

[0201] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the nighttime mouse detection method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0202] This application also provides a nighttime rat detection device; please refer to... Figure 6 The nighttime rat detection device includes:

[0203] The preprocessing module 10 is used to take pictures of mice at night under different conditions using the infrared camera to obtain a set of pictures of mice at night, and to preprocess the set of pictures of mice at night to obtain a preprocessed set of pictures of mice at night.

[0204] Extraction module 20 is used to extract local features of nighttime mouse images from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images;

[0205] The normalization module 30 is used to normalize the local feature set of the nighttime mouse images to obtain a uniformly distributed local feature set of the nighttime mouse images.

[0206] Analysis module 40 is used to analyze the feature importance of the local feature set of the uniformly distributed nighttime mouse images through a two-layer routing attention mechanism, add weights according to the feature importance, and obtain the nighttime mouse feature map set according to the weights;

[0207] Training module 50 is used to obtain the location set of the mice based on the nighttime mouse feature map set, and to train a nighttime mouse detection model based on the location set;

[0208] The detection module 60 is used to detect the environment in real time through the infrared camera in a nighttime environment, obtain a real-time environment detection image, and input the real-time environment detection image into the nighttime mouse detection model to obtain the nighttime mouse detection result.

[0209] The nighttime mouse detection device provided in this application, employing the nighttime mouse detection method described in the above embodiments, can solve the technical problem that traditional nighttime mouse detection algorithms struggle to achieve high-precision and high-efficiency target detection of mice in nighttime environments. Compared with the prior art, the beneficial effects of the nighttime mouse detection device provided in this application are the same as those of the nighttime mouse detection method provided in the above embodiments, and other technical features in the nighttime mouse detection device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0210] This application provides a nighttime mouse detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the nighttime mouse detection method in Embodiment 1 described above.

[0211] The following is for reference. Figure 7The diagram illustrates a structural schematic suitable for implementing a nighttime mouse detection device according to embodiments of this application. The nighttime mouse detection device in embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The nighttime rat detection device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of this application.

[0212] like Figure 7 As shown, the nighttime mouse detection device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the nighttime mouse detection device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. The communication device 1009 allows the nighttime mouse detection device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show nighttime mouse detection devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0213] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0214] The nighttime mouse detection device provided in this application, employing the nighttime mouse detection method described in the above embodiments, can solve the technical problem that traditional nighttime mouse detection algorithms struggle to achieve high-precision and high-efficiency target detection of mice in nighttime environments. Compared with the prior art, the beneficial effects of the nighttime mouse detection device provided in this application are the same as those of the nighttime mouse detection method provided in the above embodiments, and other technical features of this nighttime mouse detection device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0215] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0216] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0217] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to perform the nighttime mouse detection method in the above embodiments.

[0218] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0219] The aforementioned computer-readable storage medium may be included in the nighttime rat detection device; or it may exist independently and not assembled into the nighttime rat detection device.

[0220] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the nighttime mouse detection device, cause the nighttime mouse detection device to: take pictures of nighttime mice under different conditions using the infrared camera to obtain a nighttime mouse image set, and preprocess the nighttime mouse image set to obtain a preprocessed nighttime mouse image set;

[0221] Local features of nighttime mouse images are extracted from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images;

[0222] By normalizing the local feature set of the nighttime mouse images, a uniformly distributed local feature set of the nighttime mouse images is obtained.

[0223] The feature importance of the local feature set of the uniformly distributed nighttime mouse images is analyzed by a two-layer routing attention mechanism, and weights are added according to the feature importance to obtain the nighttime mouse feature map set.

[0224] The location set of the mice is obtained based on the nighttime mouse feature map set, and a nighttime mouse detection model is trained based on the location set.

[0225] In a nighttime environment, the infrared camera detects the environment in real time to obtain real-time environmental detection images. These real-time environmental detection images are then input into the nighttime mouse detection model to obtain nighttime mouse detection results.

[0226] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0227] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0228] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0229] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described nighttime mouse detection method. This solves the technical problem that traditional nighttime mouse detection algorithms struggle to achieve high-precision and high-efficiency target detection of mice in nighttime environments. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the nighttime mouse detection method provided in the above embodiments, and will not be elaborated upon here.

[0230] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the nighttime mouse detection method described above.

[0231] The computer program product provided in this application can solve the technical problem that traditional nighttime mouse detection algorithms are unable to achieve high-precision and high-efficiency target detection of mice in nighttime environments. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the nighttime mouse detection method provided in the above embodiments, and will not be repeated here.

[0232] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for detecting rats at night, characterized in that, The method is applied to a testing device, which includes: a carrier board, a development kit, a silent roller, a speaker, a functional adapter board, and an infrared camera. The method includes: The infrared camera captures images of mice at night under different conditions to obtain a set of nighttime mouse images. The set of nighttime mouse images is then preprocessed to obtain a preprocessed set of nighttime mouse images. Local features of nighttime mouse images are extracted from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images; By normalizing the local feature set of the nighttime mouse images, a uniformly distributed local feature set of the nighttime mouse images is obtained. The feature importance of the local feature set of the uniformly distributed nighttime mouse images is analyzed by a two-layer routing attention mechanism, and weights are added according to the feature importance to obtain the nighttime mouse feature map set. The location set of the mice is obtained based on the nighttime mouse feature map set, and a nighttime mouse detection model is trained based on the location set. In a nighttime environment, the infrared camera detects the environment in real time to obtain a real-time environmental detection image. The real-time environmental detection image is then input into the nighttime mouse detection model to obtain the nighttime mouse detection result. The step of extracting local features from the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images includes: The preprocessed nighttime mouse image set is input into a convolutional layer. The convolutional layer slides the preprocessed nighttime mouse images in the preprocessed nighttime mouse image set according to a preset stride to identify mouse features in the preprocessed nighttime mouse images. The mouse features are convolved by the convolutional layer to obtain local features and mouse location prediction boxes for the nighttime mouse image; Based on the local features of the nighttime mouse image and the mouse location prediction box, a local feature set of the nighttime mouse image is obtained; The step of obtaining the location set of mice based on the nighttime mouse feature map includes: The mouse features in the nighttime mouse images are obtained based on the nighttime mouse feature atlas. The coordinates of the mouse's true location bounding box are obtained based on the mouse's features; The position of the mouse is obtained based on the coordinates of the mouse's actual location bounding box; The step of obtaining the coordinates of the mouse's true location bounding box based on the mouse's features further includes: The mouse location prediction box is obtained by using the local feature set of the nighttime mouse image; Based on the predicted mouse location bounding box and the actual mouse location bounding box, the ratio of the area of ​​the intersection region to the area of ​​the merged region between the predicted mouse location bounding box and the actual mouse location bounding box is obtained. The loss function is obtained based on the ratio and the positional information of the predicted mouse position bounding box and the actual mouse position bounding box; The position of the mouse location prediction box is optimized based on the loss function.

2. The method as described in claim 1, characterized in that, The steps of analyzing the feature importance of the uniformly distributed local feature set of nighttime mouse images through a two-layer routing attention mechanism, adding weights based on the feature importance, and obtaining the nighttime mouse feature map set based on the weights include: The local features in the uniformly distributed local feature set of nighttime mouse images are divided into blocks by a two-layer routing attention mechanism to obtain a preset number of feature blocks. The target weight vector of the preset number of feature blocks is calculated using the weight matrix of the two-layer routing attention mechanism; The domain matrix is ​​obtained based on the target weight vector; The importance of the local features is analyzed based on the domain matrix, and weights are added according to the importance. The local features are pooled according to the weights, and local features of different ranges are captured to obtain the pooling operation results. The pooling operation results are subjected to feature fusion to obtain a nighttime mouse feature map set.

3. The method as described in claim 1, characterized in that, The step of obtaining a uniformly distributed local feature set of nighttime mouse images by normalizing the local feature set of the nighttime mouse images includes: The target normalized value of the local feature set of the nighttime mouse image is calculated through a normalization layer; The local features of the nighttime mouse images in the local feature set of the nighttime mouse images are normalized according to the target normalization value to obtain a uniformly distributed local feature set of the nighttime mouse images.

4. The method as described in claim 1, characterized in that, The steps of taking pictures of mice at night under different conditions using the infrared camera to obtain a set of nighttime mouse images, and preprocessing the nighttime mouse image set to obtain a preprocessed set of nighttime mouse images include: The infrared camera is used to take pictures of mice at night under different conditions to obtain a set of pictures of mice at night. Blurry pictures of mice at night are removed from the set of pictures of mice at night to obtain a set of pictures of mice at night with a preset resolution. The preset resolution nighttime mouse image set is labeled to obtain a labeled nighttime mouse image set; The format of the marked nighttime mouse image set is converted to obtain a preprocessed nighttime mouse image set.

5. A nighttime rat detection device, characterized in that, The nighttime rat detection device performs the nighttime rat detection method according to any one of claims 1 to 4, the device comprising: The preprocessing module is used to take pictures of mice at night under different conditions using the infrared camera to obtain a set of pictures of mice at night, and to preprocess the set of pictures of mice at night to obtain a preprocessed set of pictures of mice at night. The extraction module is used to extract local features of the nighttime mouse images in the preprocessed nighttime mouse image set to obtain a local feature set of nighttime mouse images. The normalization module is used to normalize the local feature set of the nighttime mouse images to obtain a uniformly distributed local feature set of the nighttime mouse images. The analysis module is used to analyze the feature importance of the local feature set of the uniformly distributed nighttime mouse images through a two-layer routing attention mechanism, add weights according to the feature importance, and obtain the nighttime mouse feature map set according to the weights. The training module is used to obtain the location set of the mice based on the nighttime mouse feature map set, and to train the nighttime mouse detection model based on the location set. The detection module is used to detect the environment in real time using the infrared camera at night, obtain real-time environmental detection images, and input the real-time environmental detection images into the nighttime mouse detection model to obtain nighttime mouse detection results.

6. A nighttime rat detection device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the nighttime mouse detection method as described in any one of claims 1 to 4.

7. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the nighttime mouse detection method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Mouse detection model construction method and mouse detection method and device

    CN117671597A

  • Mouse detection method based on video stream

    CN117830890A