mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Merge pull request #26 from blakeblackshear/mask
add the ability to mask the standing location of a person
This commit is contained in:
commit
f95d8b6210
BIN
config/back-mask.bmp
Normal file
BIN
config/back-mask.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
@ -13,27 +13,7 @@ cameras:
|
||||
# values that begin with a "$" will be replaced with environment variable
|
||||
password: $RTSP_PASSWORD
|
||||
path: /cam/realmonitor?channel=1&subtype=2
|
||||
regions:
|
||||
- size: 350
|
||||
x_offset: 0
|
||||
y_offset: 300
|
||||
min_person_area: 5000
|
||||
- size: 400
|
||||
x_offset: 350
|
||||
y_offset: 250
|
||||
min_person_area: 2000
|
||||
- size: 400
|
||||
x_offset: 750
|
||||
y_offset: 250
|
||||
min_person_area: 2000
|
||||
back2:
|
||||
rtsp:
|
||||
user: viewer
|
||||
host: 10.0.10.10
|
||||
port: 554
|
||||
# values that begin with a "$" will be replaced with environment variable
|
||||
password: $RTSP_PASSWORD
|
||||
path: /cam/realmonitor?channel=1&subtype=2
|
||||
mask: back-mask.bmp
|
||||
regions:
|
||||
- size: 350
|
||||
x_offset: 0
|
||||
|
@ -171,6 +171,13 @@ class Camera:
|
||||
mqtt_publisher = MqttObjectPublisher(self.mqtt_client, self.mqtt_topic_prefix, self.objects_parsed, self.detected_objects)
|
||||
mqtt_publisher.start()
|
||||
|
||||
# load in the mask for person detection
|
||||
if 'mask' in self.config:
|
||||
self.mask = cv2.imread("/config/{}".format(self.config['mask']), cv2.IMREAD_GRAYSCALE)
|
||||
else:
|
||||
self.mask = np.zeros((self.frame_shape[0], self.frame_shape[1], 1), np.uint8)
|
||||
self.mask[:] = 255
|
||||
|
||||
def start(self):
|
||||
self.capture_process.start()
|
||||
# start the object detection prep threads
|
||||
@ -207,6 +214,15 @@ class Camera:
|
||||
if region and region['min_person_area'] > person_area:
|
||||
continue
|
||||
|
||||
# compute the coordinates of the person and make sure
|
||||
# the location isnt outide the bounds of the image (can happen from rounding)
|
||||
y_location = min(int(obj['ymax']), len(self.mask)-1)
|
||||
x_location = min(int((obj['xmax']-obj['xmin'])/2.0), len(self.mask[0])-1)
|
||||
|
||||
# if the person is in a masked location, continue
|
||||
if self.mask[y_location][x_location] == [0]:
|
||||
continue
|
||||
|
||||
self.detected_objects.append(obj)
|
||||
|
||||
with self.objects_parsed:
|
||||
|
Loading…
Reference in New Issue
Block a user