update
This commit is contained in:
Binary file not shown.
@ -19,7 +19,7 @@ def get_object_location(pfile, mask_path = 'lianhua_1.jpg'):
|
||||
if flag:
|
||||
flag = False
|
||||
print('flag change>>{}>>{}'.format(pfile, nn))
|
||||
return '0'
|
||||
return '1'
|
||||
|
||||
frame = cv.resize(frame, (512, 640), interpolation=cv.INTER_CUBIC)
|
||||
frame = cv.medianBlur(frame, ksize=3)
|
||||
@ -29,10 +29,8 @@ def get_object_location(pfile, mask_path = 'lianhua_1.jpg'):
|
||||
fgmask = fgbg.apply(frame_motion)
|
||||
draw1 = cv.threshold(fgmask, 25, 255, cv.THRESH_BINARY)[1] # 二值化
|
||||
draw1 = cv.dilate(draw1, kernel, iterations=1)
|
||||
if nn<30: #判断20帧内有入侵动作
|
||||
if nn<20: #判断20帧内有入侵动作
|
||||
flag = check_tings(mask_path, draw1)
|
||||
if flag == '1':
|
||||
return '1'
|
||||
T2 = time.time()
|
||||
print('single video >>> {}-->{}-->{}'.format(pfile, nn, (T2 - T1)))
|
||||
return '0'
|
||||
@ -43,19 +41,17 @@ def check_tings(mask_path, img):
|
||||
img = cv.bitwise_and(mask_img[:,:,0], img)
|
||||
contours_m, hierarchy_m = cv.findContours(img.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
|
||||
for contour in contours_m:
|
||||
# print('contour', hierarchy_m)
|
||||
dics[len(contour)] = contour
|
||||
if len(dics.keys()) > 0:
|
||||
cc = sorted(dics.keys())
|
||||
iouArea = cv.contourArea(dics[cc[-1]])
|
||||
# if iouArea>10000 and iouArea<40000:
|
||||
if iouArea>10000 and iouArea<40000:
|
||||
print('>>>>>>{}'.format(iouArea))
|
||||
return '1'
|
||||
#print('iouara>>>>>>> {}'.format(iouArea))
|
||||
if iouArea>15000 and iouArea<40000:
|
||||
return True#'1'
|
||||
else:
|
||||
return '0'
|
||||
return False #'0'
|
||||
else:
|
||||
return '0'
|
||||
return False #'0'
|
||||
|
||||
if __name__ == '__main__':
|
||||
pfile = "videos/20230130-100958_e5910f7d-90dd-4f6b-9468-689ba45fe656.mp4"
|
||||
|
BIN
data/1.mp4
Normal file
BIN
data/1.mp4
Normal file
Binary file not shown.
Reference in New Issue
Block a user