update
This commit is contained in:
@ -16,6 +16,8 @@ from utils.retrieval_feature import AntiFraudFeatureDataset
|
|||||||
DEVICE = 'cuda'
|
DEVICE = 'cuda'
|
||||||
global Result
|
global Result
|
||||||
pre_area = 0
|
pre_area = 0
|
||||||
|
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3)) # 定义膨胀结构元素
|
||||||
|
kernel1 = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2, 2)) # 定义腐蚀结构元素
|
||||||
def load_image(imfile):
|
def load_image(imfile):
|
||||||
#img = np.array(Image.open(imfile)).astype(np.uint8)
|
#img = np.array(Image.open(imfile)).astype(np.uint8)
|
||||||
img = np.array(imfile).astype(np.uint8)
|
img = np.array(imfile).astype(np.uint8)
|
||||||
@ -65,11 +67,12 @@ def analysis_video(model, video_path, result_path, uuid_barcode, maskpath=None,
|
|||||||
frame_show = frame
|
frame_show = frame
|
||||||
nn += 1
|
nn += 1
|
||||||
if flag: #过滤为入侵画面
|
if flag: #过滤为入侵画面
|
||||||
if nn%2==0 or nn%3==0:continue #跳帧
|
#if nn%2==0 or nn%3==0:continue #跳帧
|
||||||
flag = img_filter(frame, oriimg, fgbg, nn)
|
flag = img_filter(frame, oriimg, fgbg, nn)
|
||||||
if flag: continue
|
if flag: continue
|
||||||
else: #RAFT定位
|
else: #RAFT定位
|
||||||
if nn%2==0:continue
|
#if nn%2==0:continue #RAFT跳帧
|
||||||
|
pass
|
||||||
height, width = frame.shape[:2]
|
height, width = frame.shape[:2]
|
||||||
frame = cv2.GaussianBlur(frame,(5,5),0)
|
frame = cv2.GaussianBlur(frame,(5,5),0)
|
||||||
frame = cv2.resize(frame, (int(width/2), int(height/2)), interpolation=cv2.INTER_CUBIC)
|
frame = cv2.resize(frame, (int(width/2), int(height/2)), interpolation=cv2.INTER_CUBIC)
|
||||||
@ -208,6 +211,8 @@ def img_filter(frame, oriimg, fgbg, nn):
|
|||||||
# 计算前景掩码
|
# 计算前景掩码
|
||||||
fgmask = fgbg.apply(frame)
|
fgmask = fgbg.apply(frame)
|
||||||
draw1 = cv2.threshold(fgmask, 25, 255, cv2.THRESH_BINARY)[1]
|
draw1 = cv2.threshold(fgmask, 25, 255, cv2.THRESH_BINARY)[1]
|
||||||
|
draw1 = cv2.erode(draw1, kernel1, iterations=2)
|
||||||
|
draw1 = cv2.dilate(draw1, kernel, iterations=1)
|
||||||
if nn==2: return True
|
if nn==2: return True
|
||||||
draw1 = cv2.bitwise_and(oriimg[:, :, 0], draw1)
|
draw1 = cv2.bitwise_and(oriimg[:, :, 0], draw1)
|
||||||
contours_m, hierarchy_m = cv2.findContours(draw1.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
contours_m, hierarchy_m = cv2.findContours(draw1.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
@ -216,7 +221,8 @@ def img_filter(frame, oriimg, fgbg, nn):
|
|||||||
if len(dics.keys())>0:
|
if len(dics.keys())>0:
|
||||||
cc = sorted(dics.keys())
|
cc = sorted(dics.keys())
|
||||||
iouArea = cv2.contourArea(dics[cc[-1]])
|
iouArea = cv2.contourArea(dics[cc[-1]])
|
||||||
if iouArea>10000 and iouArea<40000:
|
#if iouArea>10000 and iouArea<40000:
|
||||||
|
if iouArea>3000 and iouArea<50000:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -80,16 +80,28 @@ def search():
|
|||||||
else:
|
else:
|
||||||
state = analysis_video(raft_model, videoPath, '',uuid_barcode,None,net=net, transform=transform,ms=ms, match=True)
|
state = analysis_video(raft_model, videoPath, '',uuid_barcode,None,net=net, transform=transform,ms=ms, match=True)
|
||||||
result = uuid_barcode+'_'+state #参数修改返回结果
|
result = uuid_barcode+'_'+state #参数修改返回结果
|
||||||
|
try:
|
||||||
|
thread = Thread(target=AddObs, kwargs={'file_path':videoPath, 'status':state})
|
||||||
|
thread.start()
|
||||||
|
logger.info(result)
|
||||||
|
print('result >>>>> {}'.format(result))
|
||||||
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
print('result >>>>> {}'.format(result))
|
||||||
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e) #异常返回00
|
logger.warning(e) #异常返回00
|
||||||
thread = Thread(target=AddObs, kwargs={'file_path':videoPath, 'status':status[3]})
|
try:
|
||||||
thread.start()
|
thread = Thread(target=AddObs, kwargs={'file_path':videoPath, 'status':status[3]})
|
||||||
return uuid_barcode+'_'+status[3] #参数修改返回00
|
thread.start()
|
||||||
thread = Thread(target=AddObs, kwargs={'file_path':videoPath, 'status':state})
|
return uuid_barcode+'_'+status[3] #参数修改返回00
|
||||||
thread.start()
|
except Exception as e:
|
||||||
logger.info(result)
|
return uuid_barcode+'_'+status[3] #参数修改返回00
|
||||||
print('result >>>>> {}'.format(result))
|
#thread = Thread(target=AddObs, kwargs={'file_path':videoPath, 'status':state})
|
||||||
return result
|
#thread.start()
|
||||||
|
#logger.info(result)
|
||||||
|
#print('result >>>>> {}'.format(result))
|
||||||
|
#return result
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0', port=8085)
|
app.run(host='0.0.0.0', port=8085)
|
||||||
|
Reference in New Issue
Block a user