Dog walking behavior detection method and device

By combining the pedestrian-dog detection model with the dog leash detection model, the behavior of walking a dog without a leash is automatically identified, solving the problem of the existing technology that cannot effectively distinguish between stray dogs and dog walking behaviors, and improving detection accuracy and efficiency.

CN115035591BActive Publication Date: 2025-09-09BEIJING E HUALU INFORMATION TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210473808.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2025-09-09
Estimated Expiration
2042-04-29

AI Technical Summary

Technical Problem

Existing technology cannot effectively distinguish between stray dogs and dog walking, which increases the workload of managers.

Method used

Using pre-trained pedestrian and dog detection models and dog leash detection models, the system automatically identifies dogs walking without a leash by expanding and detecting image rectangles, reducing manual recognition workload and improving detection accuracy.

Benefits of technology

It has achieved automatic recognition of off-leash dog walking, reducing staff workload and improving detection accuracy, especially reducing interference from similar objects such as wires and ground gaps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115035591B_ABST
    Figure CN115035591B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for detecting dog walking behavior, wherein the method comprises: obtaining an image to be detected; performing pedestrian detection and dog detection on the image to be detected using a pre-trained pedestrian-dog detection model; if a dog is detected in the image to be detected, obtaining a dog image rectangular frame, expanding the dog image rectangular frame to obtain an extended dog image image; detecting the extended dog image image using a pre-trained dog leash detection model; if no dog leash is detected in the extended dog image image, and a pedestrian is present within a specified range of the dog, determining the detection result as the presence of off-leash dog walking behavior. The present invention automatically identifies off-leash dog walking behavior, reducing the workload of staff. Furthermore, using the extended dog image image as leash detection data can reduce interference from similar objects such as wires and ground gaps, helping to deepen the network's understanding of dog leashes, thereby improving detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a dog walking behavior detection method and device. Background Art

[0002] With the development of civilized cities, the standardized management of stray dogs and the issue of off-leash dog walking have become important components of urban management. Current deep learning detection methods are capable of detecting the presence of dogs in cities, but they cannot effectively distinguish between stray dogs and those walking dogs, increasing the workload for managers. Summary of the Invention

[0003] Therefore, the technical problem to be solved by the present invention is to overcome the defect of large workload in the prior art when manually identifying dog behavior, thereby providing a dog walking behavior detection method and device.

[0004] A first aspect of the present invention provides a method for detecting dog walking behavior, comprising: obtaining an image to be detected; performing pedestrian detection and dog detection on the image to be detected using a pre-trained pedestrian-dog detection model; if a dog is detected in the image to be detected, obtaining a dog image rectangular frame, and expanding the dog image rectangular frame to obtain an extended dog image image; detecting the extended dog image image using a pre-trained dog leash detection model; if no dog leash is detected in the extended dog image image, and there is a pedestrian within a specified range of the dog, determining the detection result as the presence of dog walking without a leash.

[0005] Optionally, in the dog walking behavior detection method provided by the present invention, the image to be detected is obtained through video stream data.

[0006] Optionally, in the dog walking behavior detection method provided by the present invention, the pedestrian and dog detection model is trained by the following steps: obtaining multiple first training images; annotating each of the first training images with pedestrian detection frames and dog detection frames to obtain a first training data set; training the yolov5 network model based on the first training data set until the first loss value of the first loss function meets the first loss condition to obtain the pedestrian and dog detection model.

[0007] Optionally, in the dog walking behavior detection method provided by the present invention, the dog leash detection model is trained by the following steps: obtaining multiple second training images; obtaining a dog image rectangular frame in the image, and expanding the dog image rectangular frame to obtain a training dog image extended image; marking the dog leash in the training dog image extended image to obtain a second training data set; training the optimized yolov5 network model based on the second training data set until the second loss value of the second loss function meets the second loss condition to obtain the dog leash detection model, the optimized yolov5 network model is based on the yolov5 network, includes a bidirectional feature pyramid structure, uses the HardSwitch function as the activation function, and the second loss function is the FOCAL LOSS loss function.

[0008] The second aspect of the present invention provides a dog walking behavior detection device, comprising: an image acquisition module for acquiring an image to be detected; a first detection module for performing pedestrian detection and dog detection on the image to be detected using a pre-trained pedestrian-dog detection model; an image expansion module, if a dog is detected in the image to be detected, the image expansion module is used to acquire a dog image rectangular frame, expand the dog image rectangular frame, and obtain an extended dog image image; a second detection module is used to detect the extended dog image image using a pre-trained dog leash detection model; a dog walking behavior detection module, if no dog leash is detected in the extended dog image image, and there is a pedestrian within the specified range of the dog, the dog walking behavior detection module is used to determine the detection result as the presence of dog walking without a leash.

[0009] Optionally, in the dog walking behavior detection device provided by the present invention, the image to be detected is obtained through video stream data.

[0010] Optionally, in the dog walking behavior detection device provided by the present invention, the device includes a first training module for training the pedestrian and dog detection model, and the first training module includes: a first training image acquisition submodule for acquiring multiple first training images; a first training set acquisition submodule for annotating pedestrian detection frames and dog detection frames on each of the first training images to obtain a first training data set; a first model training submodule for training the yolov5 network model based on the first training data set until the first loss value of the first loss function meets the first loss condition to obtain the pedestrian and dog detection model.

[0011] Optionally, in the dog walking behavior detection device provided by the present invention, the device includes a second training module for training the dog leash detection model, and the second training module includes: a second training image acquisition submodule for acquiring multiple second training images; a second training set acquisition submodule for acquiring a dog image rectangular frame in the image, and expanding the dog image rectangular frame to obtain a training dog image extended image, and marking the dog leash in the training dog image extended image to obtain a second training data set; a second model training submodule for training the optimized yolov5 network model based on the second training data set until the second loss value of the second loss function meets the second loss condition to obtain the dog leash detection model, the optimized yolov5 network model is based on the yolov5 network, includes a bidirectional feature pyramid structure, adopts the HardSwitch function as the activation function, and the second loss function is the FOCAL LOSS loss function.

[0012] The third aspect of the present invention provides a computer device comprising: 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, and the instructions are executed by the at least one processor, thereby executing the dog walking behavior detection method provided in the first aspect of the present invention.

[0013] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the dog walking behavior detection method provided in the first aspect of the present invention.

[0014] The technical solution of the present invention has the following advantages:

[0015] The dog walking behavior detection method and device provided by the present invention, after obtaining the image to be detected, if the image to be detected is detected by a pedestrian-dog detection model to obtain a dog image rectangular frame, the dog image rectangular frame is expanded to obtain an extended dog image image, and a pre-trained dog leash detection model is used to detect the extended dog image image to detect whether there is a dog leash. If the dog leash is not detected and there are pedestrians within the specified range of the dog, it is determined that the dog is walking without a leash. By implementing the present invention, the dog walking without a leash behavior can be automatically identified without manual identification, reducing the workload of the staff. In addition, the dog image extended image obtained by expanding the dog image rectangular frame as dog leash detection data can reduce interference from similar objects such as wires and ground gaps, which helps to deepen the network's understanding of the dog leash, thereby improving the detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0017] Figure 1 This is a flowchart of a specific example of a method for detecting dog walking behavior in an embodiment of the present invention;

[0018] Figure 2 This is a principle block diagram of a specific example of a dog walking behavior detection device in an embodiment of the present invention;

[0019] Figure 3 This is a principle block diagram of a specific example of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION

[0020] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0021] In the description of the present invention, it should be noted that the terms “first” and “second” are only used for descriptive purposes and should not be understood as indicating or implying relative importance.

[0022] In addition, the technical features involved in different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0023] The embodiment of the present invention provides a method for detecting dog walking behavior. Figure 1 Shown, including:

[0024] Step S11: Acquire the image to be detected.

[0025] In an optional embodiment, the image to be detected is obtained from a video stream. The acquisition of stream data can distinguish between the previous and next frame images and different stream addresses, so that the dog leash detection model can detect multiple channels of video and implement a multi-frame deduplication function. The input data stream format is:

[0026]

[0027]

[0028] Step S12: Use a pre-trained pedestrian and dog detection model to perform pedestrian detection and dog detection on the image to be detected.

[0029] In an embodiment of the present invention, the pedestrian and dog detection model can detect pedestrians and dogs in an image simultaneously.

[0030] Step S13: If a dog is detected in the image to be detected, obtain the rectangular frame of the dog image, and expand the rectangular frame of the dog image to obtain an expanded dog image.

[0031] In an optional embodiment, if the pedestrian and dog detection model detects a dog in the image to be detected, the output of the pedestrian and dog detection model includes the rectangular frame of the dog image.

[0032] In an optional embodiment, each side of the rectangular frame of the dog image is expanded outward by N pixels to obtain an expanded dog image. Exemplarily, N can be 200; if the number of pixel points between one side of the rectangular frame of the dog image and the image edge is n, and n < N, then each side of the rectangular frame of the dog image is expanded outward by n pixels to obtain an expanded dog image.

[0033] In an optional embodiment, if no dog is detected, there is no need to detect the behavior of walking a dog, and the current process ends.

[0034] Step S14: Use a pre-trained dog leash detection model to detect the expanded dog image.

[0035] In an embodiment of the present invention, using the expanded dog image obtained by expanding the rectangular frame of the dog image as dog leash detection data can reduce the interference of similar objects such as wires and ground gaps, and help the network better understand the dog leash.

[0036] Step S15: If no dog leash is detected in the expanded dog image and there is a pedestrian within the specified range of the dog, determine that there is a behavior of walking a dog without a leash.

[0037] In an optional embodiment, when performing step S12 above, if the pedestrian and dog detection model detects a pedestrian in the image to be detected, the output of the pedestrian and dog detection model also includes a pedestrian rectangular frame. By determining whether there is a pedestrian rectangular frame within the preset range of the rectangular frame of the dog image, it is determined whether there is a pedestrian within the specified range of the dog.

[0038] In an optional embodiment, if no dog leash is detected in the expanded dog image and there is no pedestrian within the specified range of the dog, determine that there is a stray dog. [[ID=?]] [[ID=?]]

[0039] By implementing the present invention, the detection of stray dogs and walking dogs without a leash is clear and definite, without the need for manual secondary classification.

[0040] In an optional embodiment, after executing step S12 above, multiple images to be detected obtained through the video stream data are detected. If multiple dogs are detected, multiple dog image rectangular frames are output, and the multiple dog image rectangular frames are organized into a list. The dog image rectangular frames in the list are stored in a global dictionary whose length does not exceed a preset value. When the preset value is exceeded, the earliest stored dog image rectangular frame is deleted to meet the requirement of being less than the preset value. For example, the preset value can be 200. Each time, the detected dog image rectangular frame is compared with the dog image rectangular frames in the dictionary. If the intersection-and-union ratio of the detected dog image rectangular frame and the dog image rectangular frames in the dictionary is greater than 0.5, the detected dog image rectangular frame is deleted from the list and does not participate in the subsequent determination of stray dogs and off-leash dog walking behaviors.

[0041] In an optional embodiment, the pedestrian and dog detection model is trained by the following steps:

[0042] First, a plurality of first training images are acquired.

[0043] In an optional implementation, images of pedestrians and dogs in actual application scenarios are collected, and multi-angle samples are collected from multiple scenes and multiple time periods. Each image requires that the shapes of pedestrians and dogs are clear and easy to distinguish, and relevant data from the VOC public dataset is added to obtain the first training image.

[0044] In an optional embodiment, after acquiring a plurality of first training images, a plurality of data enhancement methods (such as mosaic enhancement, random erasure, noise addition, etc.) are used to further expand the data set.

[0045] Then, pedestrian detection frames and dog detection frames are annotated on each first training image to obtain a first training data set.

[0046] Finally, the yolov5 network model is trained based on the first training data set until the first loss value of the first loss function meets the first loss condition to obtain a pedestrian and dog detection model.

[0047] In an optional embodiment, the dog leash detection model is trained by the following steps:

[0048] First, a plurality of second training images are acquired.

[0049] In an optional implementation, pictures and images of dogs in actual application scenarios are collected, and samples of pedestrians walking their dogs on leashes are collected from multiple scenes, multiple time periods, and multiple angles. The leash must be clearly visible in each picture to obtain a second training image.

[0050] In an optional embodiment, after acquiring a plurality of second training images, a plurality of data enhancement methods (such as mosaic enhancement, random erasure, noise addition, etc.) are used to further expand the data set.

[0051] Secondly, a dog image rectangular frame in the image is obtained, and the dog image rectangular frame is expanded to obtain an expanded image of the training dog image.

[0052] In an optional embodiment, the method of obtaining the extended image of the training dog image is the same as the method of obtaining the extended image of the dog image in the above embodiment. For details, please refer to the description in the above embodiment and will not be repeated here.

[0053] Then, the dog leash in the extended image of the training dog image is labeled to obtain a second training data set.

[0054] Finally, the optimized yolov5 network model is trained based on the second training data set until the second loss value of the second loss function meets the second loss condition to obtain the dog leash detection model. The optimized yolov5 network model is based on the yolov5 network, including a bidirectional feature pyramid structure, and uses the HardSwitch function as the activation function. The second loss function is the FOCAL LOSS loss function.

[0055] In an optional embodiment, the input of the optimized yolov5 network model uses a 608*608 three-channel image.

[0056] In an embodiment of the present invention, the HardSwitch activation function is used to replace the original Leaky RELU activation function to simplify the activation process, thereby improving the calculation speed and reducing the model parameters. In addition, a bidirectional feature pyramid network is integrated into the optimized yolov5 network model. The structure includes a top-down downsampling structure in which different levels are coupled with each other, and finally bottom-up upsampling is performed, which significantly enhances the feature expression ability of the model. For relatively small dog samples on the road, the dog leash detection model has a strong detection capability. In addition, the FOCAL LOSS loss function is used to replace the original loss function, which increases the proportion of small target features in the loss function and enhances the expression of the relationship between the dog target frame and the dog leash target frame, thereby realizing the detection of the dog leash and avoiding confusion with ground cracks.

[0057] In an optional embodiment, the dog walking behavior detection method provided by the embodiment of the present invention further constructs an output result dictionary. For each frame of the image, if there is a stray dog ​​or a dog walking without a leash, an event is reported. The judgment confidence, box, and behavior of the dog and pedestrian are output. The output data format is:

[0058]

[0059]

[0060] By executing the dog walking behavior detection method provided in the above embodiment, it is possible to quickly and accurately detect stray dogs and dogs walking without a leash in various application scenarios and under different lighting conditions. The accuracy rate in multiple scenarios reaches 95%, and the test speed on a Tesla P4 can reach 0.12s.

[0061] The embodiment of the present invention provides a dog walking behavior detection device, such as Figure 2 Shown, including:

[0062] The image acquisition module 21 is used to acquire the image to be detected. For details, please refer to the description in the above embodiment and will not be repeated here.

[0063] The first detection module 22 is used to perform pedestrian detection and dog detection on the image to be detected using a pre-trained pedestrian and dog detection model. For details, please refer to the description in the above embodiment and will not be repeated here.

[0064] The image expansion module 23 is used to obtain a dog image rectangular frame if a dog is detected in the image to be detected, and expand the dog image rectangular frame to obtain an extended dog image. For details, please refer to the description in the above embodiment and will not be repeated here.

[0065] The second detection module 24 is used to detect the extended image of the dog image using a pre-trained dog leash detection model. For details, please refer to the description in the above embodiment and will not be repeated here.

[0066] The dog walking behavior detection module 25 is used to determine the detection result as the presence of a dog walking without a leash if no dog leash is detected in the extended image of the dog image and there are pedestrians within the specified range of the dog. For details, please refer to the description in the above embodiment and will not be repeated here.

[0067] In an optional embodiment, in the dog walking behavior detection device provided by the embodiment of the present invention, the image to be detected is obtained through video stream data.

[0068] In an optional embodiment, in the dog walking behavior detection device provided in an embodiment of the present invention, the device includes a first training module for training a pedestrian-dog detection model, and the first training module includes:

[0069] The first training image acquisition submodule is used to obtain multiple first training images. For details, please refer to the description in the above embodiment and will not be repeated here.

[0070] The first training set acquisition submodule is used to annotate each first training image with a pedestrian detection frame and a dog detection frame to obtain a first training data set. For details, please refer to the description in the above embodiment and will not be repeated here.

[0071] The first model training submodule is used to train the yolov5 network model based on the first training data set until the first loss value of the first loss function meets the first loss condition to obtain a pedestrian and dog detection model. For details, please refer to the description in the above embodiment and will not be repeated here.

[0072] In an optional embodiment, in the dog walking behavior detection device provided in an embodiment of the present invention, the device includes a second training module for training the dog leash detection model, and the second training module includes:

[0073] The second training image acquisition submodule is used to obtain multiple second training images. For details, please refer to the description in the above embodiment and will not be repeated here.

[0074] The second training set acquisition submodule is used to obtain the dog image rectangular frame in the image, expand the dog image rectangular frame to obtain an extended image of the training dog image, and mark the dog leash in the extended image of the training dog image to obtain a second training data set. For details, please refer to the description in the above embodiment and will not be repeated here.

[0075] The second model training submodule is used to train the optimized yolov5 network model based on the second training data set until the second loss value of the second loss function satisfies the second loss condition to obtain a dog leash detection model. The optimized yolov5 network model is based on the yolov5 network, including a bidirectional feature pyramid structure, and adopts the HardSwitch function as the activation function. The second loss function is the FOCAL LOSS loss function. For details, please refer to the description in the above embodiment and will not be repeated here.

[0076] An embodiment of the present invention provides a computer device, such as Figure 3 As shown, the computer device mainly includes one or more processors 31 and a memory 32. Figure 3 A processor 31 is taken as an example.

[0077] The computer device may further include an input device 33 and an output device 34 .

[0078] The processor 31, memory 32, input device 33 and output device 34 may be connected via a bus or other means. Figure 3 The bus connection is taken as an example.

[0079] The processor 31 can be a central processing unit (CPU). The processor 31 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned chips. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The memory 32 can include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the dog walking behavior detection device. In addition, the memory 32 can include a high-speed random access memory and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 32 can optionally include a memory remotely located relative to the processor 31, and these remote memories can be connected to the dog walking behavior detection device via a network. The input device 33 can receive a calculation request (or other digital or character information) input by a user and generate a key signal input related to the dog walking behavior detection device. The output device 34 can include a display device such as a display screen to output the calculation result.

[0080] An embodiment of the present invention provides a computer-readable storage medium that stores computer instructions. The computer storage medium stores computer-executable instructions that can execute the dog walking behavior detection method in any of the above-mentioned method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); the storage medium can also include a combination of the above-mentioned types of memory.

[0081] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will readily appreciate that other variations or modifications based on the above descriptions are possible. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain within the scope of protection of the present invention.

Claims

1. A dog walking behavior detection method, characterized in that: include: Obtain the image to be detected, which is obtained from the video stream; Performing pedestrian detection and dog detection on the image to be detected using a pre-trained pedestrian and dog detection model; If a dog is detected in the image to be detected, obtaining a dog image rectangular frame, and expanding the dog image rectangular frame to obtain an expanded dog image; Detecting the extended image of the dog image using a pre-trained dog leash detection model; If no dog leash is detected in the extended image of the dog image, and there is a pedestrian within the specified range of the dog, the detection result is determined to be a behavior of walking the dog without a leash; The dog leash detection model is trained through the following steps: acquiring a plurality of second training images; Acquire a dog image rectangular frame in the image, and expand the dog image rectangular frame to obtain an expanded image of the training dog image; Annotating the dog leash in the extended image of the training dog image to obtain a second training data set; The optimized yolov5 network model is trained based on the second training data set until a second loss value of the second loss function satisfies a second loss condition to obtain the dog leash detection model, wherein the optimized yolov5 network model is based on the yolov5 network and includes a bidirectional feature pyramid structure, wherein the bidirectional feature pyramid structure includes a top-down downsampling structure and a bottom-up upsampling structure, wherein different levels in the downsampling structure are coupled with each other, a HardSwitch function is used as an activation function, and the second loss function is a FOCAL LOSS loss function; When executing the step of using the pre-trained pedestrian and dog detection model to perform pedestrian detection and dog detection on the image to be detected, multiple images to be detected obtained through video stream data are detected. If multiple dogs are detected, multiple dog image rectangular frames are output, and the multiple dog image rectangular frames are combined into a list. The dog image rectangular frames in the list are stored in a global dictionary whose length does not exceed a preset value. When the preset value is exceeded, the earliest stored dog image rectangular frame is deleted to meet the requirement of being less than the preset value. Each time, the detected dog image rectangular frame is compared with the dog image rectangular frames in the dictionary. If the intersection-and-union ratio of the detected dog image rectangular frame and the dog image rectangular frames in the dictionary is greater than 0.5, the detected dog image rectangular frame is deleted from the list and does not participate in the subsequent determination of stray dogs and dogs walking without a leash.

2. The dog walking behavior detection method according to claim 1, characterized in that: The image to be detected is obtained through video stream data.

3. The dog walking behavior detection method according to claim 1, characterized in that: The pedestrian and dog detection model is trained through the following steps: acquiring a plurality of first training images; Performing pedestrian detection frame labeling and dog detection frame labeling on each of the first training images to obtain a first training data set; The yolov5 network model is trained based on the first training data set until the first loss value of the first loss function meets the first loss condition to obtain the pedestrian and dog detection model.

4. A dog walking behavior detection device, characterized in that: include: An image acquisition module is used to acquire an image to be detected, where the image to be detected is obtained from a video stream; A first detection module is used to perform pedestrian detection and dog detection on the image to be detected using a pre-trained pedestrian and dog detection model; an image expansion module, which is used to obtain a dog image rectangular frame if a dog is detected in the image to be detected, and expand the dog image rectangular frame to obtain an expanded dog image; a second detection module, configured to detect the extended image of the dog image using a pre-trained dog leash detection model; a dog walking behavior detection module, configured to determine the detection result as an off-leash dog walking behavior if no dog leash is detected in the extended image of the dog image and a pedestrian is present within the designated range of the dog; The device includes a second training module for training the dog leash detection model, and the second training module includes: A second training image acquisition submodule, configured to acquire a plurality of second training images; a second training set acquisition submodule, configured to acquire a dog image rectangular frame in the image, expand the dog image rectangular frame to obtain an expanded training dog image image, and annotate the dog leash in the expanded training dog image image to obtain a second training data set; A second model training submodule is used to train the optimized YOLOv5 network model based on the second training data set until a second loss value of the second loss function satisfies a second loss condition to obtain the dog leash detection model, wherein the optimized YOLOv5 network model is based on the YOLOv5 network and includes a bidirectional feature pyramid structure, wherein the bidirectional feature pyramid structure includes a top-down downsampling structure and a bottom-up upsampling structure, wherein different levels in the downsampling structure are coupled with each other, a HardSwitch function is used as an activation function, and the second loss function is a FOCAL LOSS loss function; When executing the step of using the pre-trained pedestrian and dog detection model to perform pedestrian detection and dog detection on the image to be detected, multiple images to be detected obtained through video stream data are detected. If multiple dogs are detected, multiple dog image rectangular frames are output, and the multiple dog image rectangular frames are combined into a list. The dog image rectangular frames in the list are stored in a global dictionary whose length does not exceed a preset value. When the preset value is exceeded, the earliest stored dog image rectangular frame is deleted to meet the requirement of being less than the preset value. Each time, the detected dog image rectangular frame is compared with the dog image rectangular frames in the dictionary. If the intersection-and-union ratio of the detected dog image rectangular frame and the dog image rectangular frames in the dictionary is greater than 0.5, the detected dog image rectangular frame is deleted from the list and does not participate in the subsequent determination of stray dogs and dogs walking without a leash.

5. The dog walking behavior detection device according to claim 4, characterized in that: The image to be detected is obtained through video stream data.

6. The dog walking behavior detection device according to claim 4, characterized in that: The device includes a first training module for training the pedestrian and dog detection model, and the first training module includes: A first training image acquisition submodule, configured to acquire a plurality of first training images; A first training set acquisition submodule is configured to label each of the first training images with a pedestrian detection frame and a dog detection frame to obtain a first training data set; The first model training submodule is used to train the yolov5 network model based on the first training data set until the first loss value of the first loss function meets the first loss condition to obtain the pedestrian and dog detection model.

7. A computer device, characterized in that: include: 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, and the instructions are executed by the at least one processor, thereby executing the dog walking behavior detection method according to any one of claims 1 to 3.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the dog walking behavior detection method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Illegal dog walking event detection method and device based on monitoring video

    CN112906678A