Esempio n. 1
0
    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
Esempio n. 2
0
#! /usr/bin/env python
import roslib
roslib.load_manifest('pano_py')
import rospy
import os
import pano_opencv as cv
from pano_opencv import Mat, Size
import pano_py as pano

K = Mat(3, 3, cv.CV_32FC1)
K.fromarray([620.2, 0, 320, 0, 620.2, 240, 0, 0, 1])
D = Mat()
camera = pano.Camera()
camera.setCameraIntrinsics(K, D, Size(640, 480))
camera.write("camera.yml")

options = pano.Options()
options.directory = "/temp/pano"
options.image_names.assign(["image.1.jpg", "image.2"])

params = options.fitter_params
params.error_thresh = 6
params.inliers_thresh = 15
params.maxiters = 100
params.nNeeded = 2

options.stitch_name = "/temp/pano/stitched.jpg"
 def setupCamera(self,camera_info):
     self.camera = pano.Camera()
     K = pcv.Mat(3,3,pcv.CV_32FC1)
     K.fromarray(camera_info.K)
     img_size = pcv.Size( camera_info.width, camera_info.height)                
     self.camera.setCameraIntrinsics(K,pcv.Mat(),img_size)