Skip to content

Commit

Permalink
force next image to go to ALPR even if vehicle not detected
Browse files Browse the repository at this point in the history
  • Loading branch information
pliablepixels committed Jul 5, 2019
1 parent 77ec681 commit 9ee856d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions hook/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def append_suffix(filename, token):
g.logger.debug ('Skipping {} as we earlier matched {}'.format(filename, matched_file))
continue
g.logger.debug('Using model: {} with {}'.format(model, filename))
image = image1 if filename==filename1 else image2

image = image1 if filename==filename2 else image2

b, l, c = m.detect(image)
g.logger.debug('|--> model:{} detection took: {}s'.format(model,(datetime.datetime.now() - t_start).total_seconds()))
t_start = datetime.datetime.now()
Expand All @@ -203,10 +205,10 @@ def append_suffix(filename, token):
b, l, c = img.processIntersection(b, l, c, match)
if use_alpr:
vehicle_labels = ['car','motorbike', 'bus','truck', 'boat']
if not set(l).isdisjoint(vehicle_labels):
if not set(l).isdisjoint(vehicle_labels) or try_next_image:
# if this is true, that ,means l has vehicle labels
# this happens after match, so no need to add license plates to filter
g.logger.debug ('Invoking ALPR as detected object is a vehicle')
g.logger.debug ('Invoking ALPR as detected object is a vehicle or, we are trying hard to look for plates...')
alpr_obj = alpr.ALPRPlateRecognizer(url=g.config['alpr_url'], apikey=g.config['alpr_key'], regions=g.config['alpr_regions'])
# don't pass resized image - may be too small
alpr_b, alpr_l, alpr_c = alpr_obj.detect(filename)
Expand Down
2 changes: 1 addition & 1 deletion hook/objectconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ alpr_stats=yes
# minimal confidence for actually detecting a plate
alpr_min_dscore=0.5
# minimal conficende for the translated text
alpr_min_score=0.5
alpr_min_score=0.3
2 changes: 1 addition & 1 deletion hook/zmes_hook_helpers/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ def detect(self, image):
bbox.append( [int(round(x)), int(round(y)), int(round(x + w)), int(round(y + h))])
label.append(str(self.classes[class_ids[i]]))
conf.append(confidences[i])
#g.logger.debug ("YOLO bbox={}".format(bbox))
#g.logger.debug ("YOLO label={} bbox={}".format(str(self.classes[class_ids[i]]), box))
return bbox, label, conf

0 comments on commit 9ee856d

Please sign in to comment.