Well here is the code I use to get the image:
from realsense_camera import *
import cv2
import os
rs = RealsenseCamera()
while True:
ret,bgr_frame, depth_frame = rs.get_frame_stream()
distance = depth_frame[100,100]
print(depth_frame)
cv2.imshow("Depth Frame", depth_frame)
key = cv2.waitKey(1)
if key == 27:
break
You can get realsense_camera module following this link :
The second code i try to adapt to stream depth is:
# Part 01 using opencv access webcam and transmit the video in HTML
import cv2
import pyshine as ps # pip3 install pyshine==0.0.9
from realsense_camera import *
HTML="""
<html>
<body>
<center><img src="stream.mjpg" width='640' height='480' autoplay playsinline></center>
</body>
</html>
"""
StreamProps = ps.StreamProps
StreamProps.set_Page(StreamProps,HTML)
address = ('10.112.45.31',9000) # Enter your IP address
rs = RealsenseCamera()
while True:
StreamProps.set_Mode(StreamProps,'cv2')
ret,bgr_frame, depth_frame = rs.get_frame_stream()
#distance = depth_frame[100,100]
#print(distance)
#cv2.imshow("Depth Frame", depth_frame)
print(depth_frame)
Input_video = depth_frame
capture = cv2.VideoCapture(Input_video)
print(capture.read())
StreamProps.set_Capture(StreamProps,capture)
StreamProps.set_Quality(StreamProps,90)
server = ps.Streamer(address,StreamProps)
print('Server started at','http://'+address[0]+':'+str(address[1]))
server.serve_forever()
key = cv2.waitKey(1)
if key == 27:
break