Ask Your Question

Revision history [back]

Likely the issue is that your rgb_frame is None because the video_capture.read() call didn't properly return an image. You should be checking the return value of that call instead of just dumping it as _. Is it possible that after ~15 seconds you've just reached the end of the input video? Also, note that it's probably good practice to be wrapping the cv2_to_imgmsg with a try-except anyway (as in the tutorials, although perhaps you'd also want to catch a TypeError).

PS. This really isn't a ROS problem, it's an OpenCV problem. I realize the traceback points to something from cv_bridge, but it's not the problem here. The problem is the data you are feeding into cv_bridge. Perhaps the https://answers.opencv.org/questions/ would be a better place to ask follow-up questions.