What is the best way to convert recorded kinect rosbag into video file
What is the best way to convert recorded kinect rosbag into a video file? I am writing the video using OpenCV as following:
import rospy
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
class image_converter:
def __init__(self):
self.bridge = CvBridge()
self.image_sub = rospy.Subscriber(self.kinect_topic_name, Image, self.callback)
self.video_writer = cv2.VideoWriter(self.video_file_name,-1,1,(self.width, self.height))
def callback(self,data):
try:
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
except CvBridgeError as e:
print(e)
cv2.imshow("Image window", cv_image)
cv2.waitKey(3)
self.video_writer.write(cv_image)
def __del__(self):
self.video_writer.release()
def main(args):
ic = image_converter()
rospy.init_node('save_video', anonymous=True)
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
Asked by ravijoshi on 2017-02-23 04:54:53 UTC
Comments