Skip to content

Commit

Permalink
translucent line for visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mucunwuxian committed Jan 11, 2024
1 parent 9abbef5 commit 9454713
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import sys
from pathlib import Path

import numpy as np
import torch

FILE = Path(__file__).resolve()
Expand Down Expand Up @@ -91,6 +92,7 @@ def run(
name="exp", # save results to project/name
exist_ok=False, # existing project/name ok, do not increment
line_thickness=3, # bounding box thickness (pixels)
line_alpha=0.5, # bounding box transparency: 0.0:transparent - 1.0:opaque
hide_labels=False, # hide labels
hide_conf=False, # hide confidences
half=False, # use FP16 half-precision inference
Expand Down Expand Up @@ -223,6 +225,7 @@ def write_to_csv(image_name, prediction, confidence):

# Stream results
im0 = annotator.result()
im0 = ((im0.astype(np.float32) * (1 - opt.line_alpha)) + (im0s.astype(np.float32) * opt.line_alpha)).astype(np.uint8)
if view_img:
if platform.system() == "Linux" and p not in windows:
windows.append(p)
Expand Down Expand Up @@ -288,6 +291,7 @@ def parse_opt():
parser.add_argument("--name", default="exp", help="save results to project/name")
parser.add_argument("--exist-ok", action="store_true", help="existing project/name ok, do not increment")
parser.add_argument("--line-thickness", default=3, type=int, help="bounding box thickness (pixels)")
parser.add_argument("--line-alpha", default=0.5, type=float, help="bounding box transparency: 0.0:transparent - 1.0:opaque")
parser.add_argument("--hide-labels", default=False, action="store_true", help="hide labels")
parser.add_argument("--hide-conf", default=False, action="store_true", help="hide confidences")
parser.add_argument("--half", action="store_true", help="use FP16 half-precision inference")
Expand Down

0 comments on commit 9454713

Please sign in to comment.