37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Same-process downstream example. Run on Orin, which owns the camera/GPU."""
|
|
import sys
|
|
from pathlib import Path
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
from run_camera import CameraPipeline, parse_args
|
|
|
|
|
|
def main():
|
|
# No visualization or disk output by default. CLI flags can enable either.
|
|
pipeline = CameraPipeline(parse_args())
|
|
last_frame = -1
|
|
try:
|
|
pipeline.start()
|
|
while True:
|
|
# Reading the variable is enough for a consumer with its own clock:
|
|
# result = pipeline.latest_result # equivalent to pipeline.latest()
|
|
# This sample waits to avoid busy polling; still only the latest
|
|
# result is returned, without queuing/acknowledging individual frames.
|
|
result = pipeline.wait_for_result(last_frame, timeout=1.0)
|
|
if result is not None:
|
|
last_frame = result['frame_index']
|
|
print(last_frame, result['risk']['risk_type'],
|
|
result['risk']['risk_score'], flush=True)
|
|
# Downstream code uses result['door_risks'], ['skeletons'], ['can'].
|
|
elif not pipeline.running():
|
|
break
|
|
except KeyboardInterrupt:
|
|
pass
|
|
finally:
|
|
pipeline.request_stop()
|
|
pipeline.join() # Also propagates worker errors to the caller.
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|