[ROS] usb_cam 실시간 스트리밍

최재혁·2022년 1월 19일
0

calibration

목록 보기
2/3

github : https://github.com/ros-drivers/usb_cam

~/catkin/src/ 에 git clone

usb_cam 연결 port 확인

1. directory로 확인하기

	$ ls -ltr /dev/video*

2. v4l-utils로 확인하기

	$ sudo apt-get install v4l-utils 

	$ v4l2-ctl --list-devices

launch file, node file 수정

cam 세부 정보 확인 (pixel format, resolution)

$ v4l2-ctl --list-formats-ext

특정 디바이스 정보 확인

$ v4l2-ctl -d /dev/video1 --list-formats

/launch/usb_cam-test.launch

<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="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>

/nodes/usb_cam_node.cpp

auto focus 해제

    // advertise the main image topic
    image_transport::ImageTransport it(node_);
    image_pub_ = it.advertiseCamera("image_raw", 1);

    // grab the parameters 
    node_.param("video_device", video_device_name_, std::string("/dev/video0"));
    node_.param("brightness", brightness_, -1); //0-255, -1 "leave alone"
    node_.param("contrast", contrast_, -1); //0-255, -1 "leave alone"
    node_.param("saturation", saturation_, -1); //0-255, -1 "leave alone"
    node_.param("sharpness", sharpness_, -1); //0-255, -1 "leave alone"
    // possible values: mmap, read, userptr
    node_.param("io_method", io_method_name_, std::string("mmap"));
    node_.param("image_width", image_width_, 640);
    node_.param("image_height", image_height_, 480);
    node_.param("framerate", framerate_, 30);
    // possible values: yuyv, uyvy, mjpeg, yuvmono10, rgb24
    node_.param("pixel_format", pixel_format_name_, std::string("yuyv"));
    // enable/disable autofocus
    node_.param("autofocus", autofocus_, false);
    node_.param("focus", focus_, -1); //0-255, -1 "leave alone"
    // enable/disable autoexposure
    node_.param("autoexposure", autoexposure_, true);
    node_.param("exposure", exposure_, 100);
    node_.param("gain", gain_, -1); //0-100?, -1 "leave alone"
    // enable/disable auto white balance temperature
    node_.param("auto_white_balance", auto_white_balance_, true);
    node_.param("white_balance", white_balance_, 4000);

수정 후

cd ~/catkin_ws
catkin_make
source devel/setup.bash 
창 띄우기 관련 package
$ sudo apt-get install ros-melodic-image-view

실행 하기

roslaunch usb_cam usb_cam-test.launch

topic
/usb_cam/camera_info
/usb_cam/img_raw
수정 중...

roslaunch usb_cam

profile
Autonomous driving vision

0개의 댓글