diff --git a/.checkobject.py.swp b/.segtrain.py.swp similarity index 53% rename from .checkobject.py.swp rename to .segtrain.py.swp index 969e242..49e87bb 100644 Binary files a/.checkobject.py.swp and b/.segtrain.py.swp differ diff --git a/checkobject.py b/checkobject.py index d5ae905..f601d05 100644 --- a/checkobject.py +++ b/checkobject.py @@ -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" diff --git a/data/1.mp4 b/data/1.mp4 new file mode 100644 index 0000000..19d07d2 Binary files /dev/null and b/data/1.mp4 differ