Camera Examples¶
Cameras¶
The cameras that we tested are:
- Any usb camera or webcam using the ROS2 usb-cam package (see a pixi wrapper here),
- Real Sense which gives amazing ROS2 support,
- and Orbbec.
Check the getting ros2 side ready guide to see some examples with cameras
Run a camera node¶
We first start a camera node that publishes images to ROS2 topics. Check the getting ros2 side ready guide to see other examples with cameras. If you use an usb camera / webcam, you can try pixi_usbcam_ros2 and start it with:
Access images from crisp_py¶
Now in the broadcasted images can be accessed from crisp_py.
Using the Camera class from crisp_py:
"""Simple example for a camera. It shows the camera feed in a matplotlib window."""
import matplotlib.pyplot as plt
from crisp_py.camera import CameraConfig, Camera
camera_config = CameraConfig(
camera_name="primary",
camera_frame="primary_link",
resolution=[256, 256],
camera_color_image_topic="/image_raw",
camera_color_info_topic="/image_raw/camera_info",
)
camera = Camera(config=camera_config, namespace="")
camera.wait_until_ready()
# Display camera feed
plt.ion()
fig, ax = plt.subplots()
ax.axis("off")
frame = camera.current_image
im = ax.imshow(frame)
while True:
im.set_data(camera.current_image)
plt.pause(1.0 / 30.0)
Or by defining a camera in a YAML configuration file:
camera_name: "primary"
camera_frame: "primary_link"
resolution: [256, 256]
camera_color_image_topic: "/image_raw"
camera_color_info_topic: "/image_raw/camera_info"
Then load the configuration and use the make_camera factory method (assuming that you added the config path to the CRISP_CONFIG_PATH environment variable as described in the configuration guide):