패키지명: usb/cam
패지키 위치: xycar_ws/src/usb_cam
토픽명:
토픽 타입: sensor_msgs/image
구성:
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" />
<param name="autoexposure" value="false" />
<param name="exposure" value="48" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
세팅 값:
<param name="exposure" value="48"/>
<param name="video_device" value="/dev/video0" />
#!/usr/bin/env python
# - *- coding: utf-8 -* -
import cv2
import rospy
import numpy as np
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
bridge = CVBridge()
cv_image = np.empty(shape=[0])
def img_callback(data):
global cv_image
cv_image = bridge.imgmsg_to_cv2(data, "bgr8")
rospy.init_node('cam_tune', anonymous=True)
rospy.Subscriber("/usb_cam/image_raw", Image, img_callback)
while not rospy.is_shutdown ():
if cv_image.size != (640*480*3):
continue
cv2.imshow("original", cv_image)
cv2. waitkey(1)
$ rosbag record -a$
: 발행되고 있는 모든 토픽을 저장
$ rosbag record -O camera /usb_cam/image_raw$
: 카메라 토픽을 camera.bag 파일로 저장
$ rosbag info camera.bag$
: camera.bag 파일의 각종 정보들을 보여줌
$ rosbag play camera.bag
: 저장한 토픽 재생
$ rosbag play -r 2 camera.bag
: 2배속으로 재생하기
$ rosbag record -O cam_topic /usb_cam/image_raw
$ rosbag play full_topic.bag
$ rosrun image_view video_recorder image:='/usb_cam/image_raw' _filename:='track2.avi' _fps:=30
$ rosbag play cam_topic.bag