YOLOv5 area intrusion detection [with complete code and video demonstration]

1. Preliminary preparation:

First of all, you need to have an official source code of yolov5, and you can find the detect.py file in it.

In the detection process, some projects do not require us to detect all areas, such as intrusion detection in forbidden areas, only need to detect the planned areas. For example, as shown in the picture below, I found a random video on the Internet, and this is a screenshot of it:

2. Analysis of the principle of regional detection

Sometimes when using YOLOv5, we will encounter some specific target detection requirements, such as requiring that the entire image is not detected, and only detected in the specified area. Therefore, in order to meet this requirement, the mask operation can be used to cover the areas that do not want to be detected, so that only the detection range specified by us can be detected during detection.

1. Determine the area detection range

 # mask for certain region
        #1,2,3,4 分别对应左上,右上,右下,左下四个点
        hl1 = 1.4 / 10 #监测区域高度距离图片顶部比例
        wl1 = 6.4 / 10 #监测区域高度距离图片左部比例
        hl2 = 1.4 / 10  # 监测区域

おすすめ

転載: blog.csdn.net/m0_58508552/article/details/126196795