Skip to content

Commit

Permalink
Update for communication disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
KentaYoshioka committed Aug 20, 2024
1 parent f14b1d0 commit 5fb219c
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions people-counter/camera/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,25 @@ def run(

# Dataloader
bs = 1 # batch_size
if webcam:
view_img = check_imshow(warn=True)
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt, vid_stride=vid_stride)
bs = len(dataset)
elif screenshot:
dataset = LoadScreenshots(source, img_size=imgsz, stride=stride, auto=pt)
else:
dataset = LoadImages(source, img_size=imgsz, stride=stride, auto=pt, vid_stride=vid_stride)
vid_path, vid_writer = [None] * bs, [None] * bs
try:
if webcam:
view_img = check_imshow(warn=True)
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt, vid_stride=vid_stride)
bs = len(dataset)
elif screenshot:
dataset = LoadScreenshots(source, img_size=imgsz, stride=stride, auto=pt)
else:
dataset = LoadImages(source, img_size=imgsz, stride=stride, auto=pt, vid_stride=vid_stride)
vid_path, vid_writer = [None] * bs, [None] * bs

if dataset is None:
raise ValueError("Failed to load dataset")
except Exception as e:
LOGGER.error(f"Error loading stream: {e}")
if mqtt_server and mqtt_topic:
mqtt_client = MqttClient(mqtt_server, mqtt_port, mqtt_topic)
mqtt_client.publish("-1") # Send -1 when an error occurs
sys.exit(1)

# Initialize MQTT client
if mqtt_server != '' and mqtt_topic != '':
Expand Down

0 comments on commit 5fb219c

Please sign in to comment.