5 from cv_bridge
import CvBridge, CvBridgeError
9 from sensor_msgs.msg
import Image
16 self.
pub = rospy.Publisher(
"/test_edge_image", Image)
26 self.edgemsg.header.stamp = rospy.Time.now()
28 except CvBridgeError
as e:
33 if msg1.encoding ==
"8UC3":
38 if msg1.width != msg2.width:
40 if msg1.height != msg2.height:
42 if msg1.header.stamp != msg2.header.stamp:
44 receivedimg = self.bridge.imgmsg_to_cv2(msg2)
45 for x
in range(self.edgeimg.shape[1]):
46 for y
in range(self.edgeimg.shape[0]):
47 if not (self.
edgeimg[y,x] == receivedimg[y,x]).any():
48 rospy.loginfo(self.
edgeimg[y,x])
49 rospy.loginfo(receivedimg[y,x])
67 rospy.loginfo(
"waiting for subscribe...")
75 imgpath = p.join(p.dirname(__file__),
"../sample/edge_image_test_240x180.bmp")
77 self.assertTrue(ei.checkSparseImage())
80 imgpath = p.join(p.dirname(__file__),
"../sample/edge_image_test_640x480.bmp")
82 self.assertTrue(ei.checkSparseImage())
85 if __name__ ==
"__main__":
87 rospy.init_node(
"sparse_image_test_py")
88 rostest.rosrun(
"jsk_perception",
"test_sparse_image", TestSparseImage)
def __init__(self, imgpath)
def test_encode_decode_data16(self)
def test_encode_decode_data32(self)
def _check_img_msg_diff(self, msg1, msg2)
def checkSparseImage(self)