-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture_png.py
More file actions
32 lines (23 loc) · 742 Bytes
/
capture_png.py
File metadata and controls
32 lines (23 loc) · 742 Bytes
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
"""
Example: save the first color and depth frames to PNG images.
This example uses only one sensor.
"""
import sys
import pyRecFusionSDK as rf
print(f"Using RecFusionSDK v{rf.sdk.version()}")
rf.sdk.init()
sensor_manager = rf.SensorManager()
sensor = sensor_manager.open_any()
if not sensor:
rf.sdk.deinit()
sys.exit("ERROR: no sensor was opened!")
img_color = rf.ColorImage.allocate_for_sensor(sensor)
img_depth = rf.DepthImage.allocate_for_sensor(sensor)
if sensor.read_image(img_depth, img_color):
img_color.to_image("color.png")
img_depth.to_image("depth.png")
print("Saved images to `color.png` and `depth.png` files")
else:
print("Failed to read color and depth images")
sensor.close()
rf.sdk.deinit()