parameter | 타입 | 기본값 | 의미 |
---|---|---|---|
video_device | string | "/dev/video0" | 디바이스 위치 |
image_width | integer | 640 | 이미지 너비 |
image_height | integer | 480 | 이미지 높이 |
pixel_format | string | "mjpeg" | mjepeg, yuvy, uyvy |
io_method | string | "mmap" | mmap, read, userptr |
camera_frame_id | string | "head_camera" | 카메라의 tf frame |
framerate | integer | 30 | fps |
contrast | integer | 32 | 이미지의 대비값 (0-255) |
brightness | integer | 32 | 이미지 밝기 (0-255) |
saturation | integer | 32 | 이미지 채도 (0-255) |
sharpness | integer | 22 | 이미지 선명도 (0-255) |
autofocus | boolean | false | 자동 초점 |
focus | integer | 51 | autofocus="false"인 경우 초점 거리 (0=at infinity) |
autoexposure | boolean | ? | 자동 노출 |
exposure | integer | ? | autoexposure="false"인 경우 노출 값 |
<launch> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="/dev/video0" /> <param name="image_width" value="640" /> <param name="image_height" value="480" /> <param name="autoexposure" value="false" /> <param name="exposure" value="50" /> <param name="pixel_format" value="yuyv" /> <param name="camera_frame_id" value="usb_cam" /> <param name="io_method" value="mmap"/> </node> <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen"> <remap from="image" to="/usb_cam/image_raw"/> <param name="autosize" value="true" /> </node> </launch>
usb_cam/image_raw
, usb_cam/image_raw/compressed
토픽을 발행
sensor_msgs/Image
타입의 메시지를 사용
data
field에 프레임 정보가 리스트로 담겨있다.rosrun image_view video_recorder image:='usb_cam/image_raw' _filename='video.avi' _fps=30
from cv_bridge import CvBridge
bridge = CvBridge()
cv_image = bridge.imgmsg_to_cv2(image_message, desired_encoding='passthrough')
from cv_bridge import CvBridge
bridge = CvBridge()
image_message = bridge.cv2_to_imgmsg(cv_image, encoding="passthrough")
passthrough
: msg.encoding에서 설정된 값 그대로 사용
mono8
: CV_8UC1, grayscale image
mono16
: CV_16UC1, 16-bit grayscale image
bgr8
: CV_8UC3, color image with blue-green-red color order
rgb8
: CV_8UC3, color image with red-green-blue color order
bgra8
: CV_8UC4, BGR color image with an alpha channel
rgba8
: CV_8UC4, RGB color image with an alpha channel
import cv2 import rospy import numpy as np from sensor_msgs.msg import Image from cv_bridge import CvBridge bridge = CvBridge() cv_image = np.empy(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("display", cv_image) cv2.waitKey(33)