Skip to content

Commit

Permalink
detect.py: Use a higher presence threshold to eliminate false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewearl committed Apr 26, 2016
1 parent 271f2ec commit a1f3920
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ def detect(im, param_vals):
# To obtain pixel coordinates, the window coordinates are scaled according
# to the stride size, and pixel coordinates.
for i, (scaled_im, y_val) in enumerate(zip(scaled_ims, y_vals)):
for window_coords in numpy.argwhere(y_val[0, :, :, 0] > 0.1):
for window_coords in numpy.argwhere(y_val[0, :, :, 0] >
-math.log(1./0.99 - 1)):
letter_probs = (y_val[0,
window_coords[0],
window_coords[1], 1:].reshape(
7, len(common.CHARS)))
letter_probs = common.softmax(letter_probs)

if numpy.all(numpy.max(letter_probs, axis=1) > 0.5):
img_scale = float(im.shape[0]) / scaled_im.shape[0]
img_scale = float(im.shape[0]) / scaled_im.shape[0]

bbox_tl = window_coords * (8, 4) * img_scale
bbox_size = numpy.array(model.WINDOW_SHAPE) * img_scale
bbox_tl = window_coords * (8, 4) * img_scale
bbox_size = numpy.array(model.WINDOW_SHAPE) * img_scale

yield bbox_tl, bbox_tl + bbox_size
yield bbox_tl, bbox_tl + bbox_size


if __name__ == "__main__":
Expand All @@ -69,7 +69,8 @@ def detect(im, param_vals):
pt1 = tuple(reversed(map(int, pt1)))
pt2 = tuple(reversed(map(int, pt2)))

cv2.rectangle(im, pt1, pt2, (0.0, 255.0, 0.0))
color = (0.0, 255.0, 0.0)
cv2.rectangle(im, pt1, pt2, color)

cv2.imwrite(sys.argv[3], im)

0 comments on commit a1f3920

Please sign in to comment.