@ -12,16 +12,32 @@ from frigate.util import create_mask
# get info on the video
# cap = cv2.VideoCapture("debug/front_cam_2023_05_23_08_41__2023_05_23_08_43.mp4")
# cap = cv2.VideoCapture("debug/motion_test_clips/rain_1.mp4")
cap = cv2 . VideoCapture ( " debug/motion_test_clips/ir_off .mp4 " )
cap = cv2 . VideoCapture ( " debug/motion_test_clips/lawn_mower_night_1 .mp4 " )
# cap = cv2.VideoCapture("airport.mp4")
width = int ( cap . get ( cv2 . CAP_PROP_FRAME_WIDTH ) )
height = int ( cap . get ( cv2 . CAP_PROP_FRAME_HEIGHT ) )
fps = cap . get ( cv2 . CAP_PROP_FPS )
frame_shape = ( height , width , 3 )
# Nick back:
# "1280,0,1280,316,1170,216,1146,126,1016,127,979,82,839,0",
# "310,350,300,402,224,405,241,354",
# "378,0,375,26,0,23,0,0",
# Front door:
# "1080,0,1080,339,1010,280,1020,169,777,163,452,170,318,299,191,365,186,417,139,470,108,516,40,530,0,514,0,0",
# "336,833,438,1024,346,1093,103,1052,24,814",
# Back
# "1855,0,1851,100,1289,96,1105,161,1045,119,890,121,890,0",
# "505,95,506,138,388,153,384,114",
# "689,72,689,122,549,134,547,89",
# "261,134,264,176,169,195,167,158",
# "145,159,146,202,70,220,65,183",
mask = create_mask (
( height , width ) ,
[ ] ,
[
" 1080,0,1080,339,1010,280,1020,169,777,163,452,170,318,299,191,365,186,417,139,470,108,516,40,530,0,514,0,0 " ,
" 336,833,438,1024,346,1093,103,1052,24,814 " ,
] ,
)
# create the motion config
@ -29,7 +45,7 @@ motion_config_1 = MotionConfig()
motion_config_1 . mask = np . zeros ( ( height , width ) , np . uint8 )
motion_config_1 . mask [ : ] = mask
# motion_config_1.improve_contrast = 1
# motion_config_1.frame_height = 150
motion_config_1 . frame_height = 150
# motion_config_1.frame_alpha = 0.02
# motion_config_1.threshold = 30
# motion_config_1.contour_area = 10
@ -38,10 +54,11 @@ motion_config_2 = MotionConfig()
motion_config_2 . mask = np . zeros ( ( height , width ) , np . uint8 )
motion_config_2 . mask [ : ] = mask
# motion_config_2.improve_contrast = 1
# motion_config_2.frame_height = 150
motion_config_2 . frame_height = 150
# motion_config_2.frame_alpha = 0.01
# motion_config_2.threshold = 20
motion_config_2 . threshold = 20
# motion_config.contour_area = 10
save_images = True
improved_motion_detector_1 = ImprovedMotionDetector (
@ -52,8 +69,6 @@ improved_motion_detector_1 = ImprovedMotionDetector(
threshold = mp . Value ( " i " , motion_config_1 . threshold ) ,
contour_area = mp . Value ( " i " , motion_config_1 . contour_area ) ,
name = " default " ,
clipLimit = 2.0 ,
tileGridSize = ( 8 , 8 ) ,
)
improved_motion_detector_1 . save_images = save_images