testfitting.py
Go to the documentation of this file.
00001 import roslib; roslib.load_manifest('opencv_fitting')
00002 import rospy
00003 import nose
00004 from geometry_msgs.msg import Pose2D
00005 from image_msgs.msg import Image
00006 import cv
00007 from cv_bridge import CvBridge
00008 
00009 class TestImageResults(object):
00010     def setup(self):
00011         self.realpose = None
00012         self.received = False
00013         rospy.init_node('testfitting', anonymous=True)
00014         self.subellipse = rospy.Subscriber("ellipse", Pose2D, self.posecb)
00015         self.pub = rospy.Publisher('image', Image)
00016         self.bridge = CvBridge()
00017 
00018     def teardown(self):
00019         self.subellipse.unregister()
00020 
00021     def posecb(self,msg):
00022         assert( abs(msg.x - self.received.x) <= 0.5)
00023         assert( abs(msg.y - self.received.y) <= 0.5)
00024         assert( abs(msg.theta - self.received.theta) <= 0.2)
00025         self.received = True
00026 
00027     def test_sendimage(self):
00028         self.realpose = Pose2D(100,100,0.5)
00029         I = cv.CreateImage([256,256],cv.IPL_DEPTH_8U,1)
00030         cv.Ellipse(I,center=(self.realpose.x,self.realpose.y),axes=(100,50),angle=self.realpose.theta,start_angle=0,end_angle=6.28,color=(0,0,0))
00031         self.pub.publish(bridge.cv_to_imgmsg(I))
00032         # wait for results
00033 
00034 


opencv_fitting
Author(s): rtm-ros-robotics
autogenerated on Mon Oct 6 2014 12:08:28