Yes, that exactly was what I wanted, to get rid of the blue box and you change in-fact made it happen, but the image I was downloading didn’t had without the blue box nor the bbox arround the clock, at least the first tries, but in the fourth attempt the file had the bbox, so I kept investigating, because the next try the file was again without the bounding box.
After that I moved the ‘scene’ and the attachment image always came with the bbox around the detected object
So I think the cause for the image being saved without the bbox could been originated by ‘flickering’ in the detection, I mean when the detection is stable and you are able to ‘see’ the bounding box in the stream all the time while the object is being detected then the file attached in the notification contains the bbox, but when the detection is not stable but quick (you see the bbox arround the detected object multiple times per second in the same second) the detection file saved does not contain the bbox, is something like if the screenshot was taken in one of the miliseconds the bbox is not there…
import degirum as dg, degirum_tools, time
from degirum_tools import streams as dgstreams
import argparse
parser = argparse.ArgumentParser(description="Stream video with object detection.")
parser.add_argument('--input', type=str, default="rtmp://input.server/live/livestream", help='The video source URL.')
parser.add_argument('--output', type=str, default="rtmp://output.server/live/livestream", help='The output URL path.')
parser.add_argument('--model_name', type=str, default="yolo11s_coco--640x640_quant_hailort_hailo8_1", help='The model choosen to do the inference')
parser.add_argument('--hw_location', type=str, default="192.168.20.2:8778", help='IP of AI server')
parser.add_argument('--confidence', type=float, default=0.5, help='Confidence threshold value')
parser.add_argument('--classes', type=str, default="people", help='classes label to search for')
parser.add_argument('--model_zoo_url', type=str, default="aiserver://home/pi/DeGirum/zoo", help='URL path of the model_zoo.')
parser.add_argument('--notification_config', type=str, default="", help='Apprise configuration string')
parser.add_argument('--device', type=str, default="HAILORT/HAILO8", help='Neural Chip type')
parser.add_argument('--clip_save', action='store_true', help='Enable clip saving')
parser.add_argument('--clip_duration', type=int, help='Clip duration in seconds')
parser.add_argument('--bucket_name', type=str, help='Bucket name for saving clips')
args = parser.parse_args()
dg.log.DGLog.set_verbose_state('DEBUG')
hw_location=args.hw_location
model_name = args.model_name
model_zoo_url= args.model_zoo_url
video_source = args.input
video_output= args.output
#classes = set(args.classes)
classes = set(args.classes.split(','))
device_type = args.device
confidence = args.confidence
model_manager = dg.connect(
inference_host_address=hw_location,
zoo_url = model_zoo_url
)
model = model_manager.load_model(
model_name=model_name,
device_type=device_type,
output_confidence_threshold=confidence,
input_pad_method="letterbox",
image_backend='opencv',
overlay_color=[255,0,0],
output_class_set=classes
)
anchor = degirum_tools.AnchorPoint.CENTER
# create object tracker
tracker = degirum_tools.ObjectTracker(
class_list=classes,
track_thresh=0.35,
track_buffer=100,
match_thresh=0.9999,
trail_depth=20,
anchor_point=anchor,
show_only_track_ids = True,
#show_overlay = True,
annotation_color = [255,0,0]
)
cam_source = dgstreams.VideoSourceGizmo(video_source)
#
# create analyzers:
#
event_name = "object_detected"
zone_detector = degirum_tools.EventDetector(
f"""
Trigger: {event_name}
when: ObjectCount
is greater than: 0
during: [10, frames]
for at least: [90, percent]
""",
show_overlay=False,
)
if args.notification_config:
# clip storage config
clip_storage_config = degirum_tools.ObjectStorageConfig(
endpoint=config.S3_SERVER, # path to Server
access_key=config.ACCESS_KEY, # not needed for local storage
secret_key=config.SECRET_KEY, # not needed for local storage
bucket=args.bucket_name, # subdirectory name for local storage
)
holdoff_sec = 3.0
# event notifier
notifier = degirum_tools.EventNotifier(
"AI Detection Service - Object Detected",
event_name,
message="""<h1>AI Detection Alert System:</h1> <br/> <br/>
Object Detected!!! <br/>
Time: **{time}** <br/>
--- <br/>
You can access the detection footage here: <br/>
Download: [Evidence file]({url})""",
holdoff=holdoff_sec,
notification_config=args.notification_config,
clip_save=args.clip_save,
clip_duration=args.clip_duration,
#clip_sub_dir="{time}",
clip_pre_trigger_delay=args.clip_duration // 2,
clip_embed_ai_annotations=True,
show_overlay=False,
storage_config = clip_storage_config,
notification_timeout_s=3.0
)
degirum_tools.attach_analyzers(model, [tracker, zone_detector, notifier])
else:
degirum_tools.attach_analyzers(model, [tracker])
detector = dgstreams.AiSimpleGizmo(model)
# Show in the stream but not in the clip -> show_ai_overlay=True, EventDetector.show_overlay=False, clip_embed_ai_annotations=False
# Show in the stream but not in the clip -> show_ai_overlay=True, EventDetector.show_overlay=False, clip_embed_ai_annotations=False
# Show in the stream but not in the clip -> show_ai_overlay=True, EventDetector.show_overlay=False, clip_embed_ai_annotations=False
streamer = dgstreams.VideoStreamerGizmo(video_output, show_ai_overlay=True)
dgstreams.Composition(cam_source >> detector >> streamer).start()