From f54fa2e56c6f14f6ed75a306cbee1436e8912eb9 Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Tue, 19 Feb 2019 21:15:57 -0600 Subject: [PATCH] add the ability to apply a masking image --- config/mask-0-300.bmp | Bin 0 -> 245056 bytes config/mask-350-250.bmp | Bin 0 -> 320056 bytes config/mask-750-250.bmp | Bin 0 -> 320056 bytes detect_objects.py | 11 +++++++++-- 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 config/mask-0-300.bmp create mode 100644 config/mask-350-250.bmp create mode 100644 config/mask-750-250.bmp diff --git a/config/mask-0-300.bmp b/config/mask-0-300.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f451c61b1c1e2bc39ef4c9594f6ac244765e1e3f GIT binary patch literal 245056 zcmeI(FKpXb90%}B7hv55RHp!gk$_4U5D>7F0xF#h3MySdKtVu=K|nx&L4d)?!NS7O zz`?@Mz=MINgN22=dQmlPs&v}w=T&;2R&H8X@-Of6`}XPiPqV-O+W*q2KmL5&{&?IL zZ%*5r&RM;?^Xud9fB&uXdHcNM@yn<8ZG6sGtI<=%re1gbV!AEbc=u|=E3n@b(=2H! zvtN#LNN;ERO}wr~9$uha56{0OuF3C)=V@M*;YXlCoB~yOcO7EZt^WoF-SMS$L!7y4 zW7ON?X58dl`}MJg=aXd{qfjG8fi(Z;bgKAu=o!@MEsZ@nxtLLmmHm z)!=+Bd>>=1ur02JgKk5U?6Zftzp&zsF{{=((aHE~gr9fsFJw2qT(vRc@atXKZKIDd)(C%{;Vd)n#+a<| zW3I~CRo;8{B&(sFuJ4BLVyqP=%VZGl3h$s>OwGHoW-Ii#>zOy)UE#cUoVzC+x`*)| ze_MQb7wW$7@O-|CSJueG3zX|H>CFiXrxFg&+TZljhCN zzPrBv`3c`Q6;1;C&2j$mZ8I0g@}B>hkgGNYs`6ox3|^kzEIG?OKh|dF)cW+kDv$G* zJ{LLYet1`|X%c8#V86M$e#y!qOK!%J+jiH~I|=MJ4~y04$FBM2J#(%c{Y-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V>{y)#>uYO`)_zzwOh+HRZkXL)7$oWFE7nqG( z`!CJA*XP3OJ&kIk8rBVy-H<8u_#>iqG3g9X`%!n^K53n_=Iy9^+7Cybjl=B8UA5<< zz}|HN^|;qu9p!IPo8?J!XWkwkWOt0;BUZzj{`er-4fhuwdYv7)*9@7`@0}lZhCkk| zUgx2nz@xx29Un}ihnRZ5pCMY$wnCnSGfHO|&M50LWtoQSq}g~j4%bQPXpnS<^|&5) zhM|P5Z2MuW9*5jmw{Dq@sareS%FbrDN1@c?u(}g^5X#+g_?{hakc841-X4WDpsa)^ z&BB^cR&I~v+G7Njdn>GJyye{EJvu);?e}}F z{hPhZ&Pl7+tTnE;L%FD*ZJljh)U)!q9ad`|&l)csKjdjx+X?T~+(~xl?VG*UemL4m ztGSaMC9M9$Uqi{BFbmI^J#J+yL&FA{OHW9OV@6xE2Jvxl;kj#W#_YB%Y5EE zDtmMo-(u45z4hwH=Z)vL?wR;0yFhrhV40rw zU17kx!Egroc^lb=M~qk zNCNUBZ+;c&Q`XnK0`fzCh$GYfHe|sc9^5;jT@;~A@?{xqG literal 0 HcmV?d00001 diff --git a/config/mask-750-250.bmp b/config/mask-750-250.bmp new file mode 100644 index 0000000000000000000000000000000000000000..392422cedeac353186c3a501892ba5d523c95be2 GIT binary patch literal 320056 zcmeI(AxtY>769P>n~EljXf}un%!npiff&JND=-y^CX1**RMb>dR3Iu470)0mRv@uR zBod26RwC9Qk;u32yqif2KY;>m-=qJ>gmwx;d*_>b=bm$BX#MBk|0|c`>t8><|M}zl zzkj6fKT6g3ap`YAe*cfZmwtZ#{K1ch@82v02oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV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+ihCj7N^x|_i4X> z{wn2csUBaPmm-(V4{mC!Q%`#sQAAWg?{`xE68V0oeb$+FstT%0+sBek@|Z^%X;(kbX4Mg#aTW5e00`nH!ik+)%@`Fd&*yP z53+Knz4{qsz4hJVNJfs8A56OuPhIY9W*%GYtLIe-H0n>|koU|Bi*9>2Uf=b>r%sUz zFLEcu)4%eHKq1iITE{)F=c8(CeOCyJee+DT?9uY~ z>lav04eM?^?Y0}MzP7M_J)gMg0_zzc-@nEGM>Xn3$fozF&Dy{9#8)ZyiaF$_wpo7m zX0rwQTg}01nZt5_cYSi(+-y&Kw^;)1#_H?4voUrz?zA_{&)#gZzv_Tcf^?`%7lyjo!Z+@-7XaCb~zTYppK0aRWz3#tO*r$J8fzxWI N{nB0Fi}mzU>HqR6L81Tv literal 0 HcmV?d00001 diff --git a/detect_objects.py b/detect_objects.py index 6e9f30605..60569614c 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -190,11 +190,14 @@ def main(): regions = [] for region_string in REGIONS.split(':'): region_parts = region_string.split(',') + region_mask_image = cv2.imread("/config/{}".format(region_parts[4]), cv2.IMREAD_GRAYSCALE) + region_mask = np.where(region_mask_image==[0]) regions.append({ 'size': int(region_parts[0]), 'x_offset': int(region_parts[1]), 'y_offset': int(region_parts[2]), 'min_object_size': int(region_parts[3]), + 'mask': region_mask, # Event for motion detection signaling 'motion_detected': mp.Event(), # create shared array for storing 10 detected objects @@ -259,7 +262,7 @@ def main(): motion_changed, frame_shape, region['size'], region['x_offset'], region['y_offset'], - region['min_object_size'], + region['min_object_size'], region['mask'], True)) motion_process.daemon = True motion_processes.append(motion_process) @@ -426,7 +429,7 @@ def process_frames(shared_arr, shared_output_arr, shared_frame_time, frame_lock, # do the actual motion detection def detect_motion(shared_arr, shared_frame_time, frame_lock, frame_ready, motion_detected, motion_changed, - frame_shape, region_size, region_x_offset, region_y_offset, min_motion_area, debug): + frame_shape, region_size, region_x_offset, region_y_offset, min_motion_area, mask, debug): # shape shared input array into frame for processing arr = tonumpyarray(shared_arr).reshape(frame_shape) @@ -455,6 +458,10 @@ def detect_motion(shared_arr, shared_frame_time, frame_lock, frame_ready, motion # convert to grayscale gray = cv2.cvtColor(cropped_frame, cv2.COLOR_BGR2GRAY) + + # apply image mask + gray[mask] = [255] + # apply gaussian blur gray = cv2.GaussianBlur(gray, (21, 21), 0)