这是Kathir。使用cv和ros桥时,我无法在计算机中使用ardrone的相机输出。有人可以帮我解决这个问题吗?我没有从python代码中得到任何错误。
import roslib
import sys
import rospy
import cv2
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
class image_converter:
def __init__(self):
print('Image converter constructor ')
self.image_pub = rospy.Publisher("image_topic_2",Image,queue_size=1)
self.bridge = CvBridge()
self.image_sub = rospy.Subscriber("image_topic",Image,self.callback)
def callback(self,data):
try:
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
except CvBridgeError as e:
print(e)
(rows,cols,channels) = cv_image.shape
if cols > 60 and rows > 60 :
cv2.circle(cv_image, (50,50), 10, 255)
print('Above imshow function')
cv2.imshow("Image window", cv_image)
cv2.waitKey(3)
try:
self.image_pub.publish(self.bridge.cv2_to_imgmsg(cv_image, "bgr8"))
except CvBridgeError as e:
print(e)
def main(args):
ic = image_converter()
print('inside main ')
rospy.init_node('image_converter', anonymous=True)
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == '__main__':
print('Function call started ')
main(sys.argv)
代码中没有错误。但我没有从笔记本电脑中获得ARDRONE的输出?
任何建议都很明显。