我可以使用 Orbbec Astra Stereo S USB 3 相机的默认设置 640x400@30FPS 成功捕获深度流。但是,当我将分辨率更改为 1280x800 时,我得到以下损坏的深度图像。看起来 depth_stream.set_video_mode() 没有带来任何效果。如何解决这个问题? 我使用以下 python 代码来捕获深度流。
from openni import openni2
from openni import _openni2 as c_api
# Initialize OpenNI
openni2.initialize("./OpenNI_2.3.0.63/Linux/OpenNI-Linux-x64-2.3.0.63/Redist")
list_devices = openni2.Device.enumerate_uris()
if len(list_devices) == 0:
print("ERROR: No device connected.")
sys.exit()# exit if no device connected
else:
print("\nConnected devices: {}".format(list_devices))
# Open the detph device
dev = openni2.Device.open_any()# open_all, open_file
# start the depth device
#FWIDTH = 320
#FHEIGHT = 200
#FWIDTH = 640
#FHEIGHT = 400
FWIDTH = 1280
FHEIGHT = 800
FPS = 30
try:
depth_stream = dev.create_depth_stream()
depth_stream.set_video_mode(c_api.OniVideoMode(
pixelFormat = c_api.OniPixelFormat.ONI_PIXEL_FORMAT_DEPTH_1_MM, resolutionX = FWIDTH, resolutionY = FHEIGHT, fps = FPS))# DEFAULT 640x400
depth_stream.start()
except:
print('ERROR: Fail to either create or start depth stream.')
sys.exit()
while True:
# Grab a new depth frame
d_frame = depth_stream.read_frame() # VideoFrame object
d_frame_data = d_frame.get_buffer_as_uint16()# to uint16
depth, d_img = ToBGR_uint8(d_frame_data)# depth image uint8
d_frame_rgb = cv2.cvtColor(d_img, cv2.COLOR_BGR2RGB)# convert to rgb
# display
cv2.imshow("Orbbec Astra Stero S USB3", d_frame_rgb)
key = cv2.waitKey(1) & 0xFF
# If the 'c' key is pressed, break the while loop
if key == ord("c"):
break
# Close all windows and unload the depth device
depth_stream.close()
dev.close()
openni2.unload()
cv2.destroyAllWindows()
cap.release()