Open vstadnytskyi-FDA opened 2 years ago
Here is a simple working example that would allow to get infrared image from L515 camera. It seems
# l515 camera test
import pyrealsense2 as rs
import numpy as np
import time
from PIL import Image as im
import subprocess
def initialize_camera():
ctx = rs.context()
devices = ctx.query_devices()
for device in devices:
print(' ----- Available devices ----- ')
print(' Device PID: ', device.get_info(rs.camera_info.product_id))
print(' Device name: ', device.get_info(rs.camera_info.name))
print(' Serial number: ', device.get_info(rs.camera_info.serial_number))
print(' Firmware version: ', device.get_info(rs.camera_info.firmware_version))
print(' USB: ', device.get_info(rs.camera_info.usb_type_descriptor))
serial=device.get_info(rs.camera_info.serial_number)
if serial == 'SERIALNUMBER':
dev = device
else:
print('device not found')
serial=dev.get_info(rs.camera_info.serial_number)
# start the frames pipe
p = rs.pipeline()
conf = rs.config()
conf.enable_device(serial) #test of enable device
prof = p.start(conf)
print ('camera init complete')
time.sleep(2)
return p, prof
p,q = initialize_camera()
stream_list =q.get_streams()
for i in stream_list:
print(f'stream {i}')
try:
for i in range(10):
f = p.wait_for_frames()
accel = (f[3].as_motion_frame().get_motion_data())
gyro = (f[4].as_motion_frame().get_motion_data())
color = f.get_color_frame()
infrared = f.get_infrared_frame()
depth = f.get_depth_frame()
dist = (depth.get_distance(240, 320))
color_img = np.asanyarray(color.get_data())
ir_img = np.asanyarray(infrared.get_data())
depth_img = np.asanyarray(depth.get_data())
print('--- --- --- --- --- ---')
print("accelerometer: ", accel)
print("gyro: ", gyro)
print('gyro frame #: ',f[3].get_frame_number())
print('distance: ', dist)
print('dist frame #: ',f[0].get_frame_number())
print('mean color: ', color_img.mean())
print('mean depth: ', depth_img.mean())
print('mean infrared: ', ir_img.mean())
#print('color: ', (col[400,400]))
#print(data)
#print('col array shape',col.shape)
#print('infrared: ', (IRcol[240,320]))
#time.sleep(0)
#subprocess.check_call('cls',shell=True)
finally:
pass #p.stop()
It is not clear how to get infrared image from D435i yet. if it is even possible
Is it possible to get infrared images from L515 and D435i, D455 cameras?