-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1066 from luxonis/refactor_xout
Refactor xout
- Loading branch information
Showing
87 changed files
with
2,700 additions
and
2,784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"platform": "pc", | ||
"frame_shape": [720, 1280], | ||
"config": { | ||
"output": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
{ | ||
"platform": { | ||
"type": "string", | ||
"enum": [ | ||
"pc", | ||
"robothub" | ||
] | ||
}, | ||
"frame_shape": { | ||
"type": "array", | ||
"items": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from depthai_sdk import OakCamera | ||
|
||
with OakCamera() as oak: | ||
color = oak.create_camera('color', encode='h265') | ||
|
||
oak.visualize(color.out.encoded, fps=True, scale=2/3) | ||
# By default, it will stream non-encoded frames | ||
oak.visualize(color, fps=True, scale=2/3) | ||
oak.start(blocking=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
from depthai_sdk import OakCamera | ||
|
||
with OakCamera(rotation=90) as oak: | ||
color = oak.create_camera('color', resolution='1080p') | ||
left = oak.create_camera('left', resolution='400p') | ||
right = oak.create_camera('right', resolution='400p') | ||
oak.visualize([color, left, right], fps=True) | ||
all_cams = oak.create_all_cameras() | ||
oak.visualize(all_cams, fps=True) | ||
oak.start(blocking=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,9 @@ | ||
import cv2 | ||
from depthai_sdk import OakCamera | ||
from depthai_sdk.classes.packets import PointcloudPacket, FramePacket | ||
import rerun as rr | ||
import subprocess | ||
import time | ||
|
||
subprocess.Popen(["rerun", "--memory-limit", "200MB"]) | ||
time.sleep(1) # Wait til rerun spins up | ||
rr.init("Rerun ", spawn=False) | ||
rr.connect() | ||
|
||
def callback(packet: PointcloudPacket): | ||
colors = packet.color_frame.getCvFrame()[..., ::-1] # BGR to RGB | ||
rr.log_image('Color Image', colors) | ||
points = packet.points.reshape(-1, 3) | ||
rr.log_points("Pointcloud", points, colors=colors.reshape(-1, 3)) | ||
|
||
|
||
with OakCamera() as oak: | ||
pcl = oak.create_pointcloud() | ||
oak.callback(pcl, callback=callback) | ||
color = oak.camera('color') | ||
stereo = oak.create_stereo() | ||
stereo.config_stereo(align=color) | ||
pcl = oak.create_pointcloud(stereo=stereo, colorize=color) | ||
oak.visualize(pcl, visualizer='depthai-viewer') | ||
oak.start(blocking=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from depthai_sdk import OakCamera | ||
from depthai_sdk.classes.packets import FramePacket | ||
from datetime import timedelta | ||
from typing import Dict | ||
import cv2 | ||
|
||
def cb_1(packet: FramePacket): | ||
# Called from main thread, so we can call cv2.imshow | ||
cv2.imshow('Color frames from cb', packet.frame) | ||
|
||
def cb_2(packets: Dict[str, FramePacket]): | ||
print(packets) | ||
# Sycned packets. | ||
ts_color = packets['color'].get_timestamp() | ||
ts_left = packets['left'].get_timestamp() | ||
ts_imu = packets['imu'].get_timestamp() | ||
print(f"---- New synced packets. Diff between color and left: {abs(ts_color-ts_left) / timedelta(milliseconds=1)} ms, color and IMU: {abs(ts_imu-ts_color) / timedelta(milliseconds=1)} ms") | ||
|
||
for name, packet in packets.items(): | ||
print(f'Packet {name}, timestamp: {packet.get_timestamp()}, Seq number: {packet.get_sequence_num()}') | ||
|
||
with OakCamera() as oak: | ||
color = oak.create_camera('color', fps=32, name='color') | ||
left = oak.create_camera('left', fps=30, name='left') | ||
right = oak.create_camera('right', fps=30, name='right') | ||
imu = oak.create_imu() | ||
|
||
oak.callback( | ||
color, # Outputs whose packets we want to receive via callback | ||
callback=cb_1, # Callback function | ||
main_thread=True # Whether to call the callback in the main thread. For OpenCV's imshow to work, it must be called in the main thread. | ||
) | ||
|
||
cb_handler = oak.callback( | ||
[left, right, color, imu], | ||
callback=cb_2, | ||
main_thread=False # Will be called from a different thread, instead of putting packets into queue and waiting for main thread to pick it up. | ||
) | ||
# Timestamp syncing all 3 streams. We selected (1000/30) / 2 as threshold_ms, because | ||
# left/right are slower (30FPS), so threshold should be about 16ms. This means SDK will discard some | ||
# color packets (2 per second), but we will have synced frames. | ||
cb_handler.configure_syncing(threshold_ms=int((1000/30) / 2)) | ||
|
||
# oak.show_graph() | ||
oak.start(blocking=True) |
Oops, something went wrong.