Skip to content

Instantly share code, notes, and snippets.

@OlegJakushkin
Created December 5, 2020 10:01
Show Gist options
  • Save OlegJakushkin/91dfcf14db16daa319d2f0ce0ff8905d to your computer and use it in GitHub Desktop.
Save OlegJakushkin/91dfcf14db16daa319d2f0ce0ff8905d to your computer and use it in GitHub Desktop.
# python3 stream.py | cvlc --demux=rawvideo --rawvid-fps=15 --rawvid-width=640 --rawvid-height=480 --rawvid-chroma=RV24 - --sout=#transcode\{vcodec=theo,vb=1024,channels=2,samplerate=44100,ab=128,acodec=vorb\}:http\{mux=ogg,dst=:8080/stream\} :sout-all :sout-keep -I dummy
import pyrealsense2 as rs
import numpy as np
import cv2
import sys
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480 , rs.format.z16, 15)
pipeline.start(config)
try:
while True:
frames = pipeline.wait_for_frames()
depth_frame = frames.get_depth_frame()
if not depth_frame: #or not ir1_frame:
continue
depth_image = np.asanyarray(depth_frame.get_data())
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
sys.stdout.buffer.write(depth_colormap.tobytes())
finally:
pipeline.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment