Esempio n. 1
0
    def loads(self, stream, fileroot):
        self.wipe_slate()

        design = PropertyNode()
        if props_json.loads(stream, design, ""):
            print("json parse successful")
        else:
            error = QErrorMessage(self)
            error.showMessage("json parse failed")
            return False
        # design.pretty_print()

        self.setWindowTitle(self.default_title + " - " + fileroot)

        node = design.getChild('overview', True)
        self.overview.load(node)

        design.setLen('wing', 1)  # force to be enumerated if not already
        num_wings = design.getLen('wing')
        for i in range(num_wings):
            wing_node = design.getChild('wing[%d]' % i)
            wing = WingUI(changefunc=self.onChange)
            wing.load(wing_node)
            self.wings.append(wing)
            self.tabs.addTab(wing.get_widget(), "Wing: " + wing.get_name())
        self.rebuildWingLists()
        self.setClean()
Esempio n. 2
0
    def loads(self, stream, fileroot):
        self.wipe_slate()

        design = PropertyNode()
        if props_json.loads(stream, design, ""):
            print "json parse successful"
        else:
            error = QErrorMessage(self)
            error.showMessage( "json parse failed" )
            return False
        # design.pretty_print()

        self.setWindowTitle( self.default_title + " - " + fileroot )

        node = design.getChild('overview', True)
        self.overview.load(node)

        design.setLen('wing', 1) # force to be enumerated if not already
        num_wings = design.getLen('wing')
        for i in range(num_wings):
            wing_node = design.getChild('wing[%d]' % i)
            wing = WingUI(changefunc=self.onChange)
            wing.load(wing_node)
            self.wings.append(wing)
            self.tabs.addTab( wing.get_widget(), "Wing: " + wing.get_name() )
        self.rebuildWingLists()
        self.setClean()
def set_camera(project_dir,
               camera,
               yaw_deg=0.0,
               pitch_deg=-90.0,
               roll_deg=0.0):
    proj = ProjectMgr.ProjectMgr(project_dir)

    if camera:
        # specified on command line
        camera_file = camera
    else:
        # auto detect camera from image meta data
        camera, make, model, lens_model = proj.detect_camera()
        camera_file = os.path.join("..", "cameras", camera + ".json")
    print("Camera:", camera_file)

    # copy/overlay/update the specified camera config into the existing
    # project configuration
    cam_node = getNode('/config/camera', True)
    tmp_node = PropertyNode()
    if props_json.load(camera_file, tmp_node):
        for child in tmp_node.getChildren(expand=False):
            if tmp_node.isEnum(child):
                # print(child, tmp_node.getLen(child))
                for i in range(tmp_node.getLen(child)):
                    cam_node.setFloatEnum(child, i,
                                          tmp_node.getFloatEnum(child, i))
            else:
                # print(child, type(tmp_node.__dict__[child]))
                child_type = type(tmp_node.__dict__[child])
                if child_type is float:
                    cam_node.setFloat(child, tmp_node.getFloat(child))
                elif child_type is int:
                    cam_node.setInt(child, tmp_node.getInt(child))
                elif child_type is str:
                    cam_node.setString(child, tmp_node.getString(child))
                else:
                    print('Unknown child type:', child, child_type)

        proj.cam.set_mount_params(yaw_deg, pitch_deg, roll_deg)

        # note: dist_coeffs = array[5] = k1, k2, p1, p2, k3

        # ... and save
        proj.save()
    else:
        # failed to load camera config file
        if not camera:
            print("Camera autodetection failed.")
            print(
                "Consider running the new camera script to create a camera config"
            )
            print("and then try running this script again.")
        else:
            print("Provided camera config not found:", camera)
parser.add_argument('--roll-deg', required=True, type=float,
                    help='camera roll mounting offset from aircraft')

args = parser.parse_args()

proj = ProjectMgr.ProjectMgr(args.project)

# copy/overlay/update the specified camera config into the existing
# project configuration
cam_node = getNode('/config/camera', True)
tmp_node = PropertyNode()
props_json.load(args.camera, tmp_node)
for child in tmp_node.getChildren(expand=False):
    if tmp_node.isEnum(child):
        # print(child, tmp_node.getLen(child))
        for i in range(tmp_node.getLen(child)):
            cam_node.setFloatEnum(child, i, tmp_node.getFloatEnum(child, i))
    else:
        # print(child, type(tmp_node.__dict__[child]))
        child_type = type(tmp_node.__dict__[child])
        if child_type is float:
            cam_node.setFloat(child, tmp_node.getFloat(child))
        elif child_type is int:
            cam_node.setInt(child, tmp_node.getInt(child))
        elif child_type is str:
            cam_node.setString(child, tmp_node.getString(child))
        else:
            print('Unknown child type:', child, child_type)

proj.cam.set_mount_params(args.yaw_deg, args.pitch_deg, args.roll_deg)
Esempio n. 5
0
# setup camera calibration and distortion coefficients
if args.select_cam:
    # set the camera calibration from known preconfigured setups
    name, K, dist = cam_calib.set_camera_calibration(args.select_cam)
    config.setString('name', name)
    config.setFloat("fx", K[0][0])
    config.setFloat("fy", K[1][1])
    config.setFloat("cu", K[0][2])
    config.setFloat("cv", K[1][2])
    for i, d in enumerate(dist):
        config.setFloatEnum("dist_coeffs", i, d)
    props_json.save(camera_config, config)
else:
    # load the camera calibration from the config file
    name = config.getString('name')
    size = config.getLen("dist_coeffs")
    dist = []
    for i in range(size):
        dist.append(config.getFloatEnum("dist_coeffs", i))
    K = np.zeros((3, 3))
    K[0][0] = config.getFloat("fx")
    K[1][1] = config.getFloat("fy")
    K[0][2] = config.getFloat("cu")
    K[1][2] = config.getFloat("cv")
    K[2][2] = 1.0
    print 'Camera:', name

K = K * args.scale
K[2, 2] = 1.0

print "Opening ", args.movie