ROS:运行usb摄像头报错 No JPEG data found in image

博客讲述了将usb_cam功能包从GitHub克隆到ROS工作空间,编译运行报错的解决办法。原因是节点usb_cam_node.cpp文件中读取图片格式设置有误,原设为mjpeg格式,而摄像头获取的是yuyv格式,修改后保存、编译、source并重新运行,问题解决。

将usb_cam功能包从GitHub上clone到ROS的工作空间,编译后运行如下命令:

rosrun usb_cam usb_cam_node

然后报错如下;

[mjpeg @ 0x55e5f4e34120] No JPEG data found in image
[ERROR] [1606796392.974436443]: Error while decoding frame.

解决方法:

这是由于节点usb_cam_node.cpp文件中设置的读取图片格式有问题,在源代码段的103行左右:

// possible values: yuyv, uyvy, mjpeg, yuvmono10, rgb24
node_.param("pixel_format", pixel_format_name_, std::string("mjpeg"));

代码中原来设置的是mjpeg格式,而我这个摄像头获取的是yuyv格式的,所以相应的修改为;

// possible values: yuyv, uyvy, mjpeg, yuvmono10, rgb24
node_.param("pixel_format", pixel_format_name_, std::string("yuyv"));

之后保存、编译、source、重新运行,问题解决

yangxt@yangxt-virtual-machine:~$ ros2 run usb_cam usb_cam_node_exe [INFO] [1751043644.845571090] [usb_cam]: camera_name value: default_cam [WARN] [1751043644.845882400] [usb_cam]: framerate: 30.000000 [INFO] [1751043644.849258499] [usb_cam]: using default calibration URL [INFO] [1751043644.849384773] [usb_cam]: camera calibration URL: file:///home/yangxt/.ros/camera_info/default_cam.yaml [ERROR] [1751043644.849559623] [camera_calibration_parsers]: Unable to open camera calibration file [/home/yangxt/.ros/camera_info/default_cam.yaml] [WARN] [1751043644.849661869] [usb_cam]: Camera calibration file /home/yangxt/.ros/camera_info/default_cam.yaml not found [INFO] [1751043644.949032231] [usb_cam]: Starting 'default_cam' (/dev/video0) at 640x480 via mmap (yuyv) at 30 FPS This device supports the following formats: Motion-JPEG 1280 x 720 (30 Hz) Motion-JPEG 1280 x 720 (25 Hz) Motion-JPEG 1280 x 720 (15 Hz) Motion-JPEG 1280 x 720 (10 Hz) Motion-JPEG 640 x 480 (30 Hz) Motion-JPEG 640 x 480 (25 Hz) Motion-JPEG 640 x 480 (15 Hz) Motion-JPEG 640 x 480 (10 Hz) Motion-JPEG 320 x 240 (30 Hz) Motion-JPEG 320 x 240 (25 Hz) Motion-JPEG 320 x 240 (15 Hz) Motion-JPEG 320 x 240 (10 Hz) Motion-JPEG 320 x 180 (30 Hz) Motion-JPEG 320 x 180 (25 Hz) Motion-JPEG 320 x 180 (15 Hz) Motion-JPEG 320 x 180 (10 Hz) Motion-JPEG 800 x 600 (30 Hz) Motion-JPEG 800 x 600 (25 Hz) Motion-JPEG 800 x 600 (15 Hz) Motion-JPEG 800 x 600 (10 Hz) Motion-JPEG 848 x 480 (30 Hz) Motion-JPEG 848 x 480 (25 Hz) Motion-JPEG 848 x 480 (15 Hz) Motion-JPEG 848 x 480 (10 Hz) Motion-JPEG 640 x 360 (30 Hz) Motion-JPEG 640 x 360 (25 Hz) Motion-JPEG 640 x 360 (15 Hz) Motion-JPEG 640 x 360 (10 Hz) Motion-JPEG 1280 x 800 (30 Hz) Motion-JPEG 1280 x 800 (25 Hz) Motion-JPEG 1280 x 800 (15 Hz) Motion-JPEG 1280 x 800 (10 Hz) YUYV 4:2:2 1280 x 720 (10 Hz) YUYV 4:2:2 1280 x 720 (5 Hz) YUYV 4:2:2 640 x 480 (30 Hz) YUYV 4:2:2 640 x 480 (25 Hz) YUYV 4:2:2 640 x 480 (15 Hz) YUYV 4:2:2 640 x 480 (10 Hz
最新发布
06-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

地球被支点撬走啦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值