|
@ -51,7 +51,7 @@ def handle_camera_status(status: int): |
|
|
class ConnectionTracker: |
|
|
class ConnectionTracker: |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|
self.last_message_time = time.time() |
|
|
self.last_message_time = time.time() |
|
|
self.timeout = 30 # 30-second timeout |
|
|
|
|
|
|
|
|
self.timeout = 15 # 15-second timeout |
|
|
self.last_client_ip = None # Track last connected client IP |
|
|
self.last_client_ip = None # Track last connected client IP |
|
|
|
|
|
|
|
|
def update_last_message_time(self, client_ip=None): |
|
|
def update_last_message_time(self, client_ip=None): |
|
@ -73,6 +73,7 @@ class ConnectionThread(threading.Thread): |
|
|
|
|
|
|
|
|
def run(self): |
|
|
def run(self): |
|
|
while self.running: |
|
|
while self.running: |
|
|
|
|
|
sleep(0.5) |
|
|
|
|
|
|
|
|
if connection_tracker.last_client_ip: |
|
|
if connection_tracker.last_client_ip: |
|
|
print(f"Checking if last client {connection_tracker.last_client_ip} is still available...") |
|
|
print(f"Checking if last client {connection_tracker.last_client_ip} is still available...") |
|
@ -211,11 +212,21 @@ if __name__ == '__main__': |
|
|
m.msgType = MessageType.MESSAGE_TYPE_IMAGE |
|
|
m.msgType = MessageType.MESSAGE_TYPE_IMAGE |
|
|
m.image.timestamp = int(ctime.value) |
|
|
m.image.timestamp = int(ctime.value) |
|
|
for bbox in bboxes: |
|
|
for bbox in bboxes: |
|
|
box = m.image.boxes.add() |
|
|
|
|
|
box.x = bbox[0] |
|
|
|
|
|
box.y = bbox[1] |
|
|
|
|
|
box.w = bbox[2] |
|
|
|
|
|
box.h = bbox[3] |
|
|
|
|
|
|
|
|
# Check if bbox is not None and has exactly 4 elements |
|
|
|
|
|
if bbox is not None and len(bbox) == 4: |
|
|
|
|
|
# Check if all elements in bbox are not None |
|
|
|
|
|
if all(element is not None for element in bbox): |
|
|
|
|
|
box = m.image.boxes.add() |
|
|
|
|
|
box.x = bbox[0] |
|
|
|
|
|
box.y = bbox[1] |
|
|
|
|
|
box.w = bbox[2] |
|
|
|
|
|
box.h = bbox[3] |
|
|
|
|
|
else: |
|
|
|
|
|
# Skip if any element in bbox is None |
|
|
|
|
|
pass |
|
|
|
|
|
else: |
|
|
|
|
|
# Skip if bbox is None or does not have exactly 4 elements |
|
|
|
|
|
pass |
|
|
m.image.camType = id_ |
|
|
m.image.camType = id_ |
|
|
if isDetection: |
|
|
if isDetection: |
|
|
m.image.trackMode = TrackMode.TRACK_MODE_DETECT |
|
|
m.image.trackMode = TrackMode.TRACK_MODE_DETECT |
|
|