人流进出判别算法

本文介绍了如何在目标检测中利用追踪算法,通过四个入口区域(entrance_one, entrance_two, entrance_three)的边界定义,实现对进入和离开行为的识别。着重于根据物体中心位置判断其沿水平或垂直方向的进出,涉及score、track_id和tlwh等关键概念。
摘要由CSDN通过智能技术生成
		#entrance,entrance_one,entrance_two,entrance_three =xmin,ymin,xmax,ymax
		entrance_x, entrance_y = entrance[0], entrance[1]
        entrance_y_right = entrance[2]  # 右临界点
        entrance_yy = entrance_one[1]  # 第二条线
        entrance_yy_left = entrance_one[0]
        entrance_yyy = entrance_two[1]  # 第三条线
        entrance_yyy_right = entrance_two[2]  # 右临界点
        entrance_yyyy = entrance_three[1]  # 第四条线
        entrance_yyyy_left = entrance_three[0]
        #---------------------------------------------上水平,下垂直
        #xmin, ymin, xmax, ymax
        entrance_xx=entrance_one[0]
        entrance_xxx = entrance_one[0]
        entrance_xxxx = entrance_one[0]
		#目标检测中实现追踪
		#score识别个体的分数
		#track_id为个体设置的id
		#tlwh为个体的坐标,为xmin,ymin,xmax,ymax
        for tlwh, score, track_id in zip(tlwhs, tscores, track_ids):
            if track_id < 0: continue
            if data_type == 'kitti':
                frame_id -= 1
            x1, y1, w, h = tlwh
            center_x = x1 + w / 2.
            center_y = y1 + h / 2.
            if track_id in prev_center:
                if region_type == 'horizontal':
                    #第一幅画面-进
                    if prev_center[track_id][1] <= entrance_y and \
                            center_y > entrance_y and prev_center[track_id][0] <= entrance_y_right:
                        in_id_list.append(track_id)
                        in_id_list_one.append(track_id)
                    # 第二幅画面-进
                    if prev_center[track_id][1] <= entrance_yy and \
                            center_y > entrance_yy and prev_center[track_id][0] >= entrance_yy_left:
                        in_id_list.append(track_id)
                        in_id_list_two.append(track_id)
                    # ----------------------------------------------------------------------------------------------
                    if prev_center[track_id][1] >= entrance_y and \
                            center_y < entrance_y and prev_center[track_id][0] <= entrance_y_right:
                        out_id_list.append(track_id)
                        out_id_list_one.append(track_id)

                    if prev_center[track_id][1] >= entrance_yy and \
                            center_y < entrance_yy and prev_center[track_id][0] >= entrance_yy_left:
                        out_id_list.append(track_id)
                        out_id_list_two.append(track_id)
                else:
                    # vertical center line
                    if prev_center[track_id][0] <= entrance_x and center_x > entrance_x:
                        in_id_list.append(track_id)
                        in_id_list_one.append(track_id)
                    if prev_center[track_id][0] <= entrance_xx and center_x > entrance_xx:
                        in_id_list.append(track_id)
                        in_id_list_two.append(track_id)
                    if prev_center[track_id][0] >= entrance_x and center_x < entrance_x:
                        out_id_list.append(track_id)
                        out_id_list_one.append(track_id)

                    if prev_center[track_id][0] >= entrance_xx and center_x < entrance_xx:
                        out_id_list.append(track_id)
                        out_id_list_two.append(track_id)
                prev_center[track_id][0] = center_x
                prev_center[track_id][1] = center_y
            else:
                prev_center[track_id] = [center_x, center_y]

```python
在这里插入代码片

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值