Skip to content

Commit

Permalink
v1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 14, 2023
1 parent e977f66 commit fcb2b86
Show file tree
Hide file tree
Showing 26 changed files with 310 additions and 68 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Enter the path of an MKV file for the example live555 video: <my-video>
Finally, enable the live555 SIO configuration:
```bash
$ ./scripts/sh-services select_example sio live555
$ ./scripts/sh-services select_example sio file-rtsp
```
### Configure SIO
Expand Down
9 changes: 7 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Release Notes

## v1.5.3
## v1.5.4
- Add more sio examples and rename them
- Fix MCPEvents example
- Update SIO to r231204 that fixes hanging issue
- sh-services: add rabbitmq check fn

## v1.5.3
- Add Aqueduct API and UI examples
- Refine Aqueduct runner example
- Add fakeRTSP example configuration
Expand All @@ -10,7 +16,6 @@
- Fix samples' compatibility with DNNCam/DNNNode
- Allow samples to define SIO image version via SIO_RELEASE define


## v1.5.2

- docs: Add anypipe schemas
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.5.3
v1.5.4
11 changes: 11 additions & 0 deletions configurations/camera.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply_to_services disable all
enable live555
enable mcp
enable rabbitmq
enable sio
select_example sio camera
up live555
up rabbitmq
up mcp
test_rtsp_stream rtsp://sh-camera-rtsp:8555/live 5
restart sio
12 changes: 12 additions & 0 deletions configurations/countSensors.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apply_to_services disable all
enable live555
enable mcp
enable rabbitmq
enable sio
clean_media
select_example sio count-sensor-nomedia
up live555
up rabbitmq
up mcp
test_rtsp_stream rtsp://live555/StreetVideo1.mkv 5
restart sio
12 changes: 12 additions & 0 deletions configurations/fakeRTSP-nomedia.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apply_to_services disable all
enable live555
enable mcp
enable rabbitmq
enable sio
clean_media
select_example sio live555-nomedia
up live555
up rabbitmq
up mcp
test_rtsp_stream rtsp://live555/StreetVideo1.mkv 5
restart sio
6 changes: 2 additions & 4 deletions configurations/fakeRTSP.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
select_live555_video
disable amqp-stats
remove_orphans
apply_to_services disable all
enable live555
enable mcp
enable rabbitmq
Expand All @@ -9,5 +7,5 @@ select_example sio live555
up live555
up rabbitmq
up mcp
test_rtsp_stream rtsp://localhost:7554/data/my-video.mkv 5
test_rtsp_stream rtsp://live555/StreetVideo1.mkv 5
restart sio
12 changes: 12 additions & 0 deletions configurations/selectFileRTSP.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
select_live555_video
apply_to_services disable all
enable live555
enable mcp
enable rabbitmq
enable sio
select_example sio file-rtsp
up live555
up rabbitmq
up mcp
test_rtsp_stream rtsp://live555/data/my-video.mkv 5
restart sio
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:

analytics:
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231120}${SIO_DOCKER_TAG_VARIANT}
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231204}${SIO_DOCKER_TAG_VARIANT}
restart: unless-stopped
environment:
# Location where SIO will place generated model engine files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:


analytics:
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231120}${SIO_DOCKER_TAG_VARIANT}
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231204}${SIO_DOCKER_TAG_VARIANT}
restart: unless-stopped
environment:
# Location where SIO will place generated model engine files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "2.3"
services:

analytics:
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231120}${SIO_DOCKER_TAG_VARIANT}
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231204}${SIO_DOCKER_TAG_VARIANT}
restart: unless-stopped
environment:
# Location where SIO will place generated model engine files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:

# The SIO analytics container, consuming the streams and analyzing them
analytics_svc:
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231120}${SIO_DOCKER_TAG_VARIANT}
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231204}${SIO_DOCKER_TAG_VARIANT}
container_name: sample-sio
restart: unless-stopped
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ services:

# The SIO analytics container, consuming the streams and analyzing them
analytics_svc:
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231120}${SIO_DOCKER_TAG_VARIANT}
image: us-central1-docker.pkg.dev/ext-edge-analytics/docker/sio:${SIO_RELEASE-r231204}${SIO_DOCKER_TAG_VARIANT}
container_name: sample-sio
restart: unless-stopped
environment:
Expand Down
2 changes: 1 addition & 1 deletion docs/schemas/anypipe/anypipe.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions examples/MCPEvents/EventSegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def __init__(self, start_ts):
self.end_ts = start_ts
self.videos = []

def add_event(self, event):
self.events_list.append(event)

def set_end_ts(self, end_ts):
self.end_ts = end_ts

def write_json(self, path):
with open(path, 'w') as f:
json.dump(self, f, indent=4, default=vars)
75 changes: 43 additions & 32 deletions examples/MCPEvents/MCPEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def __init__(self, args):
if args.sensors_json:
print("Generating events based on sensors.json")
self.roi_filter = ROIFilter(args.sensors_json)
else:
print("Generating events based on all events")
if args.annotate:
self.annotator = MCPEventAnnotator(capture_dir = capture_dir,
sensors_json = args.sensors_json)
Expand Down Expand Up @@ -99,20 +101,24 @@ def event_segment_complete(self, source, event_segment):
filepath_ts = dirpath / Path(segment.uri)
filepath_ts.parent.mkdir(parents=True, exist_ok=True)
video_name = filepath_ts.relative_to(filepath_ts.parent.parent)
print(f"Downloading {video_name}")
self.mcp_client.download_video(source, video_name, filepath_ts)
vidfile = dirpath / Path(f"{filename_base}.m3u8")
print(f"Writing {vidfile}")
with open(vidfile, "w") as file:
file.write(m3u8_content)
json_file = dirpath_json / Path(f"{filename_base}.json")
print(f"Writing {json_file}")
event_segment.write_json(json_file)
if self.annotator:
self.annotator.create_annotation(json_file, vidfile)
print(f"Event segment complete")

# This method is called when a media event is received from the MCP
def handle_media_event_callback(self, media_event, sourceId):
# Get the type and message of the media event
type = media_event.get("type", "unknown")
msg = media_event.get("msg", "unknown")
# msg = media_event.get("msg", "unknown")
# If the media event is a video_file_closed event, add it to the current event segment
# for the source ID, or to the completed event segments if it's already completed
if type == "video_file_closed":
Expand All @@ -128,14 +134,21 @@ def handle_media_event_callback(self, media_event, sourceId):


def json_callback(self, data):
if 'frameTimestamp' not in data or 'sourceId' not in data:
print(f"Invalid message received: {data}")
return

sourceId = data.get("sourceId", "unknown")
frameTimestamp = data.get("frameTimestamp", 0)
mediaEvents = data.get("mediaEvents", {})

for event in mediaEvents:
self.handle_media_event_callback(event, sourceId)

# Record only sensor events (count, region, etc) and ignore other events
if self.use_events:
if 'sensorEvents' in data:
start_ts = data['frameTimestamp']
start_ts = frameTimestamp
# The end timestamp for all active events
end_ts = None
event_in_progress = False
Expand All @@ -150,42 +163,40 @@ def json_callback(self, data):
else:
event_in_progress = True
if event_in_progress:
if not data['sourceId'] in self.current_event_seg:
self.current_event_seg[data['sourceId']] = EventSegment(start_ts)
elif data['sourceId'] in self.current_event_seg:
current_event_seg = self.current_event_seg[data['sourceId']]
current_event_seg.events_list.append(data)
current_event_seg.end_ts = data['frameTimestamp'] if end_ts is None else end_ts
if not sourceId in self.current_event_seg:
self.current_event_seg[sourceId] = EventSegment(start_ts)
elif sourceId in self.current_event_seg:
current_event_seg = self.current_event_seg[sourceId]
current_event_seg.add_event(data)
current_event_seg.end_ts = frameTimestamp if end_ts is None else end_ts
if end_ts is not None:
self.new_event_segment(data['sourceId'], current_event_seg)
del self.current_event_seg[data['sourceId']]
if data['sourceId'] in self.current_event_seg:
self.current_event_seg[data['sourceId']].events_list.append(data)
self.new_event_segment(sourceId, current_event_seg)
del self.current_event_seg[sourceId]
if sourceId in self.current_event_seg:
self.current_event_seg[sourceId].add_event(data)
else:
if 'frameTimestamp' in data and 'sourceId' in data and \
data['sourceId'] in self.current_event_seg:
current_event_seg = self.current_event_seg[data['sourceId']]
if data['frameTimestamp'] - current_event_seg.start_ts > \
self.group_events_max_length :
if sourceId in self.current_event_seg:
current_event_seg = self.current_event_seg[sourceId]
if frameTimestamp - current_event_seg.start_ts > self.group_events_max_length :
print(f"Event length exceeded {self.group_events_max_length} ms, restarting event segment")
self.new_event_segment(data['sourceId'],current_event_seg)
del self.current_event_seg[data['sourceId']]
self.new_event_segment(sourceId,current_event_seg)
del self.current_event_seg[sourceId]

elif data['frameTimestamp'] - current_event_seg.end_ts > \
self.group_events_separation_ms :
elif frameTimestamp - current_event_seg.end_ts > self.group_events_separation_ms :
print(f"More than {self.group_events_separation_ms} ms between events, restarting event segment")
print(f"Current frame timestamp is {self.frame_timestamp_to_timestr(data['frameTimestamp'])}"\
print(f"Current frame timestamp is {self.frame_timestamp_to_timestr(frameTimestamp)}"\
f" last event timestamp was {self.frame_timestamp_to_timestr(current_event_seg.end_ts)}")
self.new_event_segment(data['sourceId'],current_event_seg)
del self.current_event_seg[data['sourceId']]

if 'metaClasses' in data and 'sourceId' in data:
if not self.roi_filter or self.roi_filter.objects_in_roi(data):
if not data['sourceId'] in self.current_event_seg:
self.current_event_seg[data['sourceId']] = EventSegment(data['frameTimestamp'])
current_event_seg = self.current_event_seg[data['sourceId']]
current_event_seg.events_list.append(data)
current_event_seg.end_ts = data['frameTimestamp']
self.new_event_segment(sourceId,current_event_seg)
del self.current_event_seg[sourceId]

if 'metaClasses' in data:
if not self.roi_filter or self.roi_filter.objects_in_roi(data):
if not sourceId in self.current_event_seg:
self.current_event_seg[sourceId] = EventSegment(frameTimestamp)
current_event_seg = self.current_event_seg[sourceId]
current_event_seg.add_event(data)
current_event_seg.end_ts = frameTimestamp


def start(self):
self.path_prefix.mkdir(parents=True, exist_ok=True)
Expand Down
Loading

0 comments on commit fcb2b86

Please sign in to comment.