-
Notifications
You must be signed in to change notification settings - Fork 6
/
try.py
34 lines (29 loc) · 1.13 KB
/
try.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# First import the library
import pyrealsense2 as rs
try:
# Create a context object. This object owns the handles to all connected realsense devices
pipeline = rs.pipeline()
pipeline.start()
while True:
# Create a pipeline object. This object configures the streaming camera and owns it's handle
frames = pipeline.wait_for_frames()
depth = frames.get_depth_frame()
if not depth:
continue
# Print a simple text-based representation of the image, by breaking it into 10x20 pixel regions and approximating the coverage of pixels within one meter
coverage = [0]*64
# for y in xrange(480):
# for x in xrange(640):
# dist = depth.get_distance(x, y)
# if 0 < dist and dist < 1:
# coverage[x/10] += 1
# if y%20 is 19:
# line = ""
# for c in coverage:
# line += " .:nhBXWW"[c/25]
# coverage = [0]*64
# print(line)
dist = depth.get_distance(320, 240)
print(dist)
except Exception as e:
print(e)