def setupStitch(self): options = pano.Options() options.camera = self.camera options.stitch_size = pcv.Size(4000,2000) #options.image_names.assign(image_names) params = options.fitter_params params.error_thresh = 6; params.inliers_thresh = 15; params.maxiters = 100; params.nNeeded = 2; self.stitcher = pano.StitchEngine(options)
def stitch(self): bag = rosbag.Bag(self.bag_name) saved_camera_info = False img_n = 0 pano_dir = tempfile.mkdtemp("pano") image_names = [] camera = pano.Camera() blur_detector = pano.BlurDetector() for topic, msg, t in bag.read_messages(topics=['camera_info']): if ('camera_info' in topic): print "reading camera info" K = pcv.Mat(3, 3, pcv.CV_32FC1) K.fromarray(msg.K) img_size = pcv.Size(msg.width, msg.height) camera.setCameraIntrinsics(K, pcv.Mat(), img_size) break options = pano.Options() options.camera = camera options.stitch_size = pcv.Size(4000, 2000) options.directory = pano_dir #options.image_names.assign(image_names) params = options.fitter_params params.error_thresh = 6 params.inliers_thresh = 15 params.maxiters = 100 params.nNeeded = 2 options.stitch_output = self.stitch_file_name stitcher = pano.StitchEngine(options) for topic, msg, t in bag.read_messages(topics=['image']): if ('image' in topic): try: cv_image = self.bridge.imgmsg_to_cv(msg, "rgb8") b_prob = blur_detector.checkBlur(cv_image) print "image blur prob = %f" % b_prob pano_image = pcv.convertCvMat2Mat(cv_image) stitcher.addNewImage(pano_image) img_n += 1 except CvBridgeError, e: print e