I am trying to create a point cloud and save the data as a list of (x, y, z) coordinates and an list of (r, g, b) values. I am having an issue when using OakCamera.create_pointcloud () because I get an error saying the method got an unexpected argument 'stereo'. I don't know if I have the wrong version of depthai-sdk downloaded or if there is a bug in the code. I have version 1.15.0 installed right now.
My code looks like this:
from depthai_sdk import OakCamera
import numpy as np
with OakCamera() as oak:
color = oak.create_camera('color')
stereo = oak.create_stereo()
stereo.config_stereo(align=color)
pcl = oak.create_pointcloud(stereo=stereo, colorize=color)
# Start the camera
oak.start(blocking=False)
# Capture a single frame of point cloud data
frame = pcl.get()
# Extract XYZ coordinates and RGB colors
xyz = frame['xyz'] # Shape: (H, W, 3)
rgb = frame['rgb'] # Shape: (H, W, 3)
# Reshape to a list of points
xyz_points = xyz.reshape(-1, 3)
rgb_colors = rgb.reshape(-1, 3)
# Save to a file or process as needed
np.savetxt('point_cloud_xyz.txt', xyz_points, fmt='%.6f', delimiter=',')
np.savetxt('point_cloud_rgb.txt', rgb_colors, fmt='%d', delimiter=',')
print("Point cloud data saved.")