Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-realsense
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周迅(18研)
python-realsense
Commits
79a0ef56
Commit
79a0ef56
authored
Dec 18, 2019
by
周迅(18研)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加新文件
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
show_video.py
show_video.py
+51
-0
No files found.
show_video.py
0 → 100644
View file @
79a0ef56
import
pyrealsense2
as
rs
import
numpy
as
np
import
cv2
# Configure depth and color streams
pipeline
=
rs
.
pipeline
()
config
=
rs
.
config
()
config
.
enable_stream
(
rs
.
stream
.
depth
,
640
,
480
,
rs
.
format
.
z16
,
30
)
config
.
enable_stream
(
rs
.
stream
.
color
,
640
,
480
,
rs
.
format
.
bgr8
,
30
)
# Start streaming
pipeline
.
start
(
config
)
try
:
while
True
:
# Wait for a coherent pair of frames: depth and color
frames
=
pipeline
.
wait_for_frames
()
depth_frame
=
frames
.
get_depth_frame
()
color_frame
=
frames
.
get_color_frame
()
if
not
depth_frame
or
not
color_frame
:
continue
# Convert images to numpy arrays
depth_image
=
np
.
asanyarray
(
depth_frame
.
get_data
())
color_image
=
np
.
asanyarray
(
color_frame
.
get_data
())
print
(
color_image
.
shape
)
# Apply colormap on depth image (image must be converted to 8-bit per pixel first)
depth_colormap
=
cv2
.
applyColorMap
(
cv2
.
convertScaleAbs
(
depth_image
,
alpha
=
0.03
),
cv2
.
COLORMAP_JET
)
# Stack both images horizontally
images
=
np
.
hstack
((
color_image
,
depth_colormap
))
# Show images
cv2
.
namedWindow
(
'RealSense'
,
cv2
.
WINDOW_AUTOSIZE
)
cv2
.
imshow
(
'RealSense'
,
images
)
key
=
cv2
.
waitKey
(
1
)
# Press esc or 'q' to close the image window
if
key
&
0xFF
==
ord
(
'q'
)
or
key
==
27
:
cv2
.
destroyAllWindows
()
break
finally
:
# Stop streaming
pipeline
.
stop
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment