rospy 识别物体颜色、面积、距离

#!/usr/bin/env python
# This final piece fo skeleton code will be centred around gettign the students to follow a colour and stop upon sight of another one.

from __future__ import division
import cv2
import numpy as np
import rospy
import sys

from geometry_msgs.msg import Twist, Vector3
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError

class colourIdentifier():
	def __init__(self):
		# Initialise a publisher to publish messages to the robot base
		# We covered which topic receives messages that move the robot in the 2nd Lab Session
		self.pub = rospy.Publisher('mobile_base/commands/velocity', Twist)
		
		# Initialise any flags that signal a colour has been detected in view
		self.flags = [False, False, False]
		
		# Initialise the value you wish to use for sensitivity in the colour detection (10 should be enough)
		self.sensitivity = 10

		# Initialise some standard movement messages such as a simple move 

猜你喜欢

转载自blog.csdn.net/blowfire123/article/details/102966355