You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.7 KiB
42 lines
1.7 KiB
3 years ago
|
import time
|
||
|
import ec.zmqpub
|
||
|
# class names
|
||
|
names= [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
|
||
|
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
|
||
|
'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
|
||
|
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
|
||
|
'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
|
||
|
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
|
||
|
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
|
||
|
'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
|
||
|
'hair drier', 'toothbrush' ]
|
||
|
|
||
|
|
||
|
|
||
|
waringnames=['行人', '直行车','摩托']
|
||
|
waringclsids=[0, 1,3]
|
||
|
# 预警
|
||
|
def filter(item_bbox,bboxlist,direction,shape):
|
||
|
x1, y1, x2, y2, track_id,cls_id= item_bbox
|
||
|
detectmodle = {}
|
||
|
detectmodle['track_id']=int(track_id)
|
||
|
detectmodle['lable']=names[int(cls_id)]
|
||
|
detectmodle['direction']=direction
|
||
|
newbox={}
|
||
|
newbox["x1"]=int(x1)
|
||
|
newbox["y1"]=int(y1)
|
||
|
newbox["x2"]=int(x2)
|
||
|
newbox["y2"]=int(y2)
|
||
|
detectmodle['box']=newbox
|
||
|
detectmodle['width']=int(shape[1])
|
||
|
detectmodle['height']=int(shape[0])
|
||
|
ec.zmqpub.sendcount(detectmodle)
|
||
|
# 不是行人退出
|
||
|
if cls_id == 0:
|
||
|
ec.zmqpub.sendcwarning(detectmodle)
|
||
|
# return
|
||
|
# for bbox in bboxlist:
|
||
|
# x1, y1, x2, y2, track_id,cls_id= bbox
|
||
|
|
||
|
|