ROS中UVC_Camera的使用。
阿新 • • 發佈:2018-11-11
ROS中UVC_Camera的使用
最近新買了usb攝像頭,發現用usb_cam來啟動始終無法調到1280*760模式,試著改過了pixel_format為mjpeg也不行。這裡最後終於探索出一條解決方法。
步驟(主要參考wiki libuvc_camera)
- 安裝libuvc ,
sudo apt-get install ros-kinetic-libuvc-camera
; - 確認usb的
idVendor
和idProduct
,Terminal 執行 lsusb
, 檢視到你攝像頭對應的資訊,比如:Bus 002 Device 002: ID 05a3:9422 ARC International
idVendor
為0x05a3
,idProduct
為0x9422
。 - 寫啟動檔案:這裡不再通過
device /dev/video0
來指定攝像頭了,而是通過idVendor
和idProduct
來訪問了。
<launch> <group ns="camera"> <node pkg="libuvc_camera" type="camera_node" name="mycam"> <!-- Parameters used to find the camera --> <param name="vendor" value="0x05a3"/> <param name="product" value="0x9422"/> <param name="serial" value="3"/> <!-- If the above parameters aren't unique, choose the first match: --> <param name="index" value="0"/> <!-- Image size and type --> <param name="width" value="1280"/> <param name="height" value="720"/> <!-- choose whichever uncompressed format the camera supports: --> <param name="video_mode" value="mjpeg"/> <!-- or yuyv/nv12/mjpeg --> <param name="frame_rate" value="30"/> <param name="timestamp_method" value="start"/> <!-- start of frame --> <param name="camera_info_url" value="file://$(find usb_cam)/example.yaml"/> <param name="auto_white_balance" value="true"/> </node> </group> <node pkg="image_view" type="image_view" name="image_view_test" output="screen"> <remap from="image" to="/camera/image_raw"/> </node> </launch>
這裡需要注意width/height/video_mode
需要正確對應。如我的攝像頭不支援yuyv/1280/720
4. roslaunch
,OK,你可能會遇到報錯,Permission denied /etc/bus/usb/002/006...
5. 賦予許可權:sudo chmod o+w /etc/bus/usb/002/006
這裡填被拒絕的埠。
6. 然後就OK啦,可以顯示了。