Welcome to Jetson ORIN NANO SUPER repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
02.Camera preview (CSI)
Camera preview (CSI)
1. Compile the function package
cd ~/yahboom_ws
xxxxxxxxxxcolcon build
xxxxxxxxxxsource install/setup.bash

2. Start the camera
Start the camera
xxxxxxxxxxros2 run camera camera_csi
View nodes and topics
xxxxxxxxxxros2 node list
xxxxxxxxxxros2 topic list

3. Preview screen
Use rqt to view the screen corresponding to the camera: rqt → Plugins → Visualization → Image View
xxxxxxxxxxrqt


4. Main code
ximport rclpyfrom rclpy.node import Nodefrom sensor_msgs.msg import Imagefrom cv_bridge import CvBridgeimport cv2from jetcam.csi_camera import CSICameraclass CameraNode(Node):def __init__(self):super().__init__('camera_csi')self.publisher = self.create_publisher(Image, 'image_raw', 10)self.bridge = CvBridge()self.cap = CSICamera(capture_device=0, width=640, height=480)self.timer = self.create_timer(0.05, self.timer_callback)def timer_callback(self):frame = self.cap.read()if frame is not None:image_msg = self.bridge.cv2_to_imgmsg(frame, encoding="bgr8")self.publisher.publish(image_msg)else:self.get_logger().warn('Failed to capture image')def main(args=None):rclpy.init(args=args)node = CameraNode()rclpy.spin(node)node.cap.release()rclpy.shutdown()if __name__ == '__main__':main()