jakaskerl
This is for saving a single frame. Hope it makes sense:
with dai.Device(pipeline) as device:
isRunning = True
def key_callback(vis, action, mods):
global isRunning
if action == 0:
isRunning = False
q = device.getOutputQueue(name="out", maxSize=4, blocking=False)
pcd = o3d.geometry.PointCloud()
coordinateFrame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=1000, origin=[0,0,0])
first = True
fpsCounter = FPSCounter()
while isRunning:
inMessage = q.get()
inColor = inMessage["rgb"]
inPointCloud = inMessage["pcl"]
cvColorFrame = inColor.getCvFrame()
# Convert the frame to RGB
cvRGBFrame = cv2.cvtColor(cvColorFrame, cv2.COLOR_BGR2RGB)
fps = fpsCounter.tick()
# Display the FPS on the frame
cv2.putText(cvColorFrame, f"FPS: {fps:.2f}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
cv2.imshow("color", cvColorFrame)
key = cv2.waitKey(1)
if key == ord('q'):
break
if inPointCloud:
t_before = time.time()
points = inPointCloud.getPoints().astype(np.float64)
pcd.points = o3d.utility.Vector3dVector(points)
colors = (cvRGBFrame.reshape(-1, 3) / 255.0).astype(np.float64)
pcd.colors = o3d.utility.Vector3dVector(colors)
# save the point cloud to a file
o3d.io.write_point_cloud("pointcloud.pcd", pcd)
Thanks,
Jaka