当前位置:   article > 正文

ros订阅图片python_ROS与Python入门教程-CompressedImage类型的订阅器和发布器

compressedimage的ros发布 python

ROS与Python入门教程-CompressedImage类型的订阅器和发布器

说明

这一节介绍订阅包含sensor_msgs::CompressedImage的主题,转换CompressedImage为numpy.ndarray,从而做检测和标记,再发布为CompressedImage类型的主题。

实现

在beginner_tutorials/scripts目录,新建subscriber_publisher_CompressedImage.py

$ roscd beginner_tutorials/scripts/

$ touch subscriber_publisher_CompressedImage.py

$ chmod +x subscriber_publisher_CompressedImage.py

$ rosed beginner_tutorials subscriber_publisher_CompressedImage.py

手工输入如下完整示例代码:(忽略注释部分)

#!/usr/bin/env python

"""OpenCV feature detectors with ros CompressedImage Topics in python.

This example subscribes to a ros topic containing sensor_msgs

CompressedImage. It converts the CompressedImage into a numpy.ndarray,

then detects and marks features in that image. It finally displays

and publishes the new image - again as CompressedImage topic.

"""

__author__ = 'Simon Haller '

__version__= '0.1'

__license__ = 'BSD'

# Python libs

import sys, time

# numpy and scipy

import numpy as np

from scipy.ndimage import filters

# OpenCV

import cv2

# Ros libraries

import roslib

import rospy

# Ros Messages

from sensor_msgs.msg import CompressedImage

# We do not use cv_bridge it does not support Compresse

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/845607
推荐阅读
相关标签
  

闽ICP备14008679号