Ros-opencv after few computations cannot see the image
Hi ,
So i'm trying to detect lines with turtlebot via kinect rgb camera. Everything was working until i added cv2.HoughLinesP() i think it still works but image window comes up as menubar only :) canny and gaussianblur works fine with a bit latency but at least i can see the image
i tried to add rospy.sleep() . im not sure where to go from this point. any suggestions?
thanks
def __init__(self):
rospy.init_node('test_node')
self.bridge=CvBridge()
self.image_sub = rospy.Subscriber("/camera/rgb/image_color", Image, self.callback)
def callback(self,data):
try:
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
except CvBridgeError as e:
print(e)
cv_image=(255-cv_image)
g_img=cv2.cvtColor(cv_image,cv2.COLOR_BGR2GRAY)
g_img=cv2.GaussianBlur(g_img,(5,5),200)
thresh=cv2.Canny(g_img,5,150,5)
lines = cv2.HoughLinesP(thresh,2,np.pi/180,100,100,1)
print lines.shape
for i in range(0,lines.shape[0]):
for x1,y1,x2,y2 in lines[i]:
cv2.line(cv_image,(x1,y1),(x2,y2),(0,255,0),2)
cv2.imshow("image",lines)
cv2.waitKey(3)
#rospy.sleep(10)