Skip to content

Commit

Permalink
154 Bbox solely owned area (#155)
Browse files Browse the repository at this point in the history
* implemented solely owned area computation for bboxes
* unified package versions and upgraded PyO3 to 0.22
* fixed opentelemetry init for null output (was to stdout)
* implemented bbox association function
* implemented ordering and fixed review comments
  • Loading branch information
bwsw authored Oct 24, 2024
1 parent 096588a commit 0bed517
Show file tree
Hide file tree
Showing 43 changed files with 550 additions and 1,320 deletions.
16 changes: 15 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,25 @@ members = [
]

[workspace.dependencies]
anyhow = "1.0"
evalexpr = { version = "11", features = ["rand", "regex_support"] }
geo = "0.28"
lazy_static = "1.5"
log = "0.4"
savant_core = { path = "savant_core" }
savant_core_py = { path = "savant_core_py" }
hashbrown = { version = "0.15", features = ["serde"] }
opentelemetry = "0.24"
opentelemetry-otlp = { version = "0.17", features = ["http-json", "http-proto", "tls", "reqwest-rustls"] }
parking_lot = { version = "0.12", features = ["deadlock_detection"] }
pyo3 = "0.22"
pyo3-build-config = "0.22"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"

[workspace.package]
version = "0.4.0"
version = "0.4.1"
edition = "2021"
authors = ["Ivan Kudriavtsev <ivan.a.kudryavtsev@gmail.com>"]
description = "Savant Rust core functions library"
Expand Down
92 changes: 73 additions & 19 deletions python/frame_pipeline_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,96 @@

set_log_level(LogLevel.Trace)

from savant_rs.pipeline import VideoPipelineStagePayloadType, VideoPipeline, VideoPipelineConfiguration, StageFunction
from savant_rs.primitives import VideoFrame, VideoFrameContent, VideoFrameTranscodingMethod, VideoFrameTransformation, \
Attribute, AttributeValue
from savant_rs.pipeline import (
VideoPipelineStagePayloadType,
VideoPipeline,
VideoPipelineConfiguration,
StageFunction,
)
from savant_rs.primitives import (
VideoFrame,
VideoFrameContent,
VideoFrameTranscodingMethod,
VideoFrameTransformation,
Attribute,
AttributeValue,
)
from savant_rs.utils import gen_frame, TelemetrySpan, enable_dl_detection
from savant_rs import init_jaeger_tracer

if __name__ == "__main__":
savant_rs.version()
enable_dl_detection() # enables internal DL detection (checks every 5 secs)
log(LogLevel.Info, "root", "Begin operation", dict(savant_rs_version=savant_rs.version()))
init_jaeger_tracer("demo-pipeline", "localhost:6831")
log(
LogLevel.Info,
"root",
"Begin operation",
dict(savant_rs_version=savant_rs.version()),
)

conf = VideoPipelineConfiguration()
conf.append_frame_meta_to_otlp_span = True

frame = VideoFrame(source_id="test", framerate="30/1", width=1400, height=720,
content=VideoFrameContent.internal(bytes("this is it", 'utf-8')),
transcoding_method=VideoFrameTranscodingMethod.Encoded, codec="h264", keyframe=True,
time_base=(1, 1000000), pts=10000, dts=10000, duration=10)
frame = VideoFrame(
source_id="test",
framerate="30/1",
width=1400,
height=720,
content=VideoFrameContent.internal(bytes("this is it", "utf-8")),
transcoding_method=VideoFrameTranscodingMethod.Encoded,
codec="h264",
keyframe=True,
time_base=(1, 1000000),
pts=10000,
dts=10000,
duration=10,
)
frame.add_transformation(VideoFrameTransformation.initial_size(1920, 1080))
frame.add_transformation(VideoFrameTransformation.scale(1280, 720))
frame.add_transformation(VideoFrameTransformation.padding(120, 0, 0, 0))
frame.add_transformation(VideoFrameTransformation.resulting_size(1400, 720))

frame.set_attribute(Attribute("Configuration", "CamMode",
[AttributeValue.string("fisheye"), AttributeValue.integers([180, 180])],
"PlatformConfig", True))
frame.set_attribute(
Attribute(
"Configuration",
"CamMode",
[AttributeValue.string("fisheye"), AttributeValue.integers([180, 180])],
"PlatformConfig",
True,
)
)

print(frame.json_pretty)

p = VideoPipeline("video-pipeline-root", [
("input", VideoPipelineStagePayloadType.Frame, StageFunction.none(), StageFunction.none()),
("proc1", VideoPipelineStagePayloadType.Batch, StageFunction.none(), StageFunction.none()),
("proc2", VideoPipelineStagePayloadType.Batch, StageFunction.none(), StageFunction.none()),
("output", VideoPipelineStagePayloadType.Frame, StageFunction.none(), StageFunction.none()),
], conf)
p = VideoPipeline(
"video-pipeline-root",
[
(
"input",
VideoPipelineStagePayloadType.Frame,
StageFunction.none(),
StageFunction.none(),
),
(
"proc1",
VideoPipelineStagePayloadType.Batch,
StageFunction.none(),
StageFunction.none(),
),
(
"proc2",
VideoPipelineStagePayloadType.Batch,
StageFunction.none(),
StageFunction.none(),
),
(
"output",
VideoPipelineStagePayloadType.Frame,
StageFunction.none(),
StageFunction.none(),
),
],
conf,
)
p.sampling_period = 10

root_span = TelemetrySpan("new-telemetry")
Expand Down
41 changes: 41 additions & 0 deletions python/primitives/bbox/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from savant_rs.primitives.geometry import (
RBBox,
solely_owned_areas,
associate_bboxes,
)
from savant_rs.utils import BBoxMetricType

red = RBBox.ltrb(0.0, 2.0, 2.0, 4.0)
green = RBBox.ltrb(1.0, 3.0, 5.0, 5.0)
yellow = RBBox.ltrb(1.0, 1.0, 3.0, 6.0)
purple = RBBox.ltrb(4.0, 0.0, 7.0, 2.0)

areas = solely_owned_areas([red, green, yellow, purple], parallel=True)

red = areas[0]
green = areas[1]
yellow = areas[2]
purple = areas[3]

assert red == 2.0
assert green == 4.0
assert yellow == 5.0
assert purple == 6.0

lp1 = RBBox.ltrb(0.0, 1.0, 2.0, 2.0)
lp2 = RBBox.ltrb(5.0, 2.0, 8.0, 3.0)
lp3 = RBBox.ltrb(100.0, 0.0, 6.0, 3.0)
owner1 = RBBox.ltrb(1.0, 0.0, 6.0, 3.0)
owner2 = RBBox.ltrb(6.0, 1.0, 9.0, 4.0)

associations_iou = associate_bboxes(
[lp1, lp2, lp3], [owner1, owner2], BBoxMetricType.IoU, 0.01
)

lp1_associations = associations_iou[0]
lp2_associations = associations_iou[1]
lp3_associations = associations_iou[2]

assert list(map(lambda t: t[0], lp1_associations)) == [0]
assert list(map(lambda t: t[0], lp2_associations)) == [1, 0]
assert lp3_associations == []
39 changes: 0 additions & 39 deletions savant_algebra/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions savant_algebra/build.rs

This file was deleted.

67 changes: 0 additions & 67 deletions savant_algebra/python/frame_objs_from_np.py

This file was deleted.

51 changes: 0 additions & 51 deletions savant_algebra/python/numpy_ops.py

This file was deleted.

49 changes: 0 additions & 49 deletions savant_algebra/src/conversions.rs

This file was deleted.

Loading

0 comments on commit 0bed517

Please sign in to comment.