mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
make the threshold configurable per region. fixes #31
This commit is contained in:
parent
6900e140d5
commit
3019b0218c
@ -19,11 +19,14 @@ cameras:
|
||||
x_offset: 0
|
||||
y_offset: 300
|
||||
min_person_area: 5000
|
||||
threshold: 0.5
|
||||
- size: 400
|
||||
x_offset: 350
|
||||
y_offset: 250
|
||||
min_person_area: 2000
|
||||
threshold: 0.5
|
||||
- size: 400
|
||||
x_offset: 750
|
||||
y_offset: 250
|
||||
min_person_area: 2000
|
||||
threshold: 0.5
|
||||
|
@ -38,7 +38,7 @@ class PreppedQueueProcessor(threading.Thread):
|
||||
frame = self.prepped_frame_queue.get()
|
||||
|
||||
# Actual detection.
|
||||
objects = self.engine.DetectWithInputTensor(frame['frame'], threshold=0.5, top_k=3)
|
||||
objects = self.engine.DetectWithInputTensor(frame['frame'], threshold=frame['region_threshold'], top_k=3)
|
||||
# parse and pass detected objects back to the camera
|
||||
parsed_objects = []
|
||||
for obj in objects:
|
||||
@ -59,7 +59,7 @@ class PreppedQueueProcessor(threading.Thread):
|
||||
class FramePrepper(threading.Thread):
|
||||
def __init__(self, camera_name, shared_frame, frame_time, frame_ready,
|
||||
frame_lock,
|
||||
region_size, region_x_offset, region_y_offset,
|
||||
region_size, region_x_offset, region_y_offset, region_threshold,
|
||||
prepped_frame_queue):
|
||||
|
||||
threading.Thread.__init__(self)
|
||||
@ -71,6 +71,7 @@ class FramePrepper(threading.Thread):
|
||||
self.region_size = region_size
|
||||
self.region_x_offset = region_x_offset
|
||||
self.region_y_offset = region_y_offset
|
||||
self.region_threshold = region_threshold
|
||||
self.prepped_frame_queue = prepped_frame_queue
|
||||
|
||||
def run(self):
|
||||
@ -103,6 +104,7 @@ class FramePrepper(threading.Thread):
|
||||
'frame_time': frame_time,
|
||||
'frame': frame_expanded.flatten().copy(),
|
||||
'region_size': self.region_size,
|
||||
'region_threshold': self.region_threshold,
|
||||
'region_x_offset': self.region_x_offset,
|
||||
'region_y_offset': self.region_y_offset
|
||||
})
|
||||
|
@ -159,13 +159,19 @@ class Camera:
|
||||
# for each region, create a separate thread to resize the region and prep for detection
|
||||
self.detection_prep_threads = []
|
||||
for region in self.config['regions']:
|
||||
# set a default threshold of 0.5 if not defined
|
||||
if not 'threshold' in region:
|
||||
region['threshold'] = 0.5
|
||||
if not isinstance(region['threshold'], float):
|
||||
print('Threshold is not a float. Setting to 0.5 default.')
|
||||
region['threshold'] = 0.5
|
||||
self.detection_prep_threads.append(FramePrepper(
|
||||
self.name,
|
||||
self.shared_frame_np,
|
||||
self.shared_frame_time,
|
||||
self.frame_ready,
|
||||
self.frame_lock,
|
||||
region['size'], region['x_offset'], region['y_offset'],
|
||||
region['size'], region['x_offset'], region['y_offset'], region['threshold'],
|
||||
prepped_frame_queue
|
||||
))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user