Exemple #1
0
def plotoptions_measurement_boundaries(**optimization_inputs):
    r'''Return the 'set' plot options for gnuplotlib to show the measurement boundaries

SYNOPSIS

    import numpy as np
    import gnuplotlib as gp
    import mrcal

    model               = mrcal.cameramodel('xxx.cameramodel')
    optimization_inputs = model.optimization_inputs()

    x = mrcal.optimizer_callback(**optimization_inputs)[1]

    gp.plot( np.abs(x),
             _set = mrcal.plotoptions_measurement_boundaries(**optimization_inputs) )

    # a plot pops up showing the magnitude of each measurement, with boundaries
    # between the different measurements denoted

When plotting the measurement vector (or anything relating to it, such as
columns of the Jacobian), it is usually very useful to infer at a glance the
meaning of each part of the plot. This function returns a list of 'set'
directives passable to gnuplotlib that show the boundaries inside the
measurement vector.

ARGUMENTS

**optimization_inputs: a dict() of arguments passable to mrcal.optimize() and
mrcal.optimizer_callback(). These define the full optimization problem, and can
be obtained from the optimization_inputs() method of mrcal.cameramodel

RETURNED VALUE

A list of 'set' directives passable as plot options to gnuplotlib

    '''

    imeas0 = []

    try:
        imeas0.append(mrcal.measurement_index_boards(0, **optimization_inputs))
    except:
        pass
    try:
        imeas0.append(mrcal.measurement_index_points(0, **optimization_inputs))
    except:
        pass
    try:
        imeas0.append(
            mrcal.measurement_index_regularization(0, **optimization_inputs))
    except:
        pass

    return [f"arrow nohead from {x},graph 0 to {x},graph 1" for x in imeas0]
Exemple #2
0
                        8 * 2, "state_index_intrinsics()")
testutils.confirm_equal(mrcal.state_index_extrinsics(2, **optimization_inputs),
                        8 * Ncameras + 6 * 2, "state_index_extrinsics()")
testutils.confirm_equal(mrcal.state_index_frames(2, **optimization_inputs),
                        8 * Ncameras + 6 * (Ncameras - 1) + 6 * 2,
                        "state_index_frames()")
testutils.confirm_equal(
    mrcal.state_index_calobject_warp(**optimization_inputs),
    8 * Ncameras + 6 * (Ncameras - 1) + 6 * Nframes,
    "state_index_calobject_warp()")

testutils.confirm_equal(
    mrcal.measurement_index_boards(2, **optimization_inputs),
    object_width_n * object_height_n * 2 * 2, "measurement_index_boards()")
testutils.confirm_equal(
    mrcal.measurement_index_regularization(**optimization_inputs),
    object_width_n * object_height_n * 2 * Nframes * Ncameras,
    "measurement_index_regularization()")

############# Calibration computed. Now I see how well I did
models_solved = \
    [ mrcal.cameramodel( optimization_inputs = optimization_inputs,
                         icam_intrinsics     = i )
      for i in range(Ncameras)]

# if 0:
#     for i in range(1,Ncameras):
#         models_solved[i].write(f'/tmp/tst{i}.cameramodel')

testutils.confirm_equal(rmserr, 0, eps=2.5, msg="Converged to a low RMS error")
Exemple #3
0
                         8*2,
                         "state_index_intrinsics()")
testutils.confirm_equal( mrcal.state_index_extrinsics(2, **optimization_inputs),
                         8*Ncameras + 6*2,
                         "state_index_extrinsics()")
testutils.confirm_equal( mrcal.state_index_frames(2, **optimization_inputs),
                         8*Ncameras + 6*(Ncameras-1) + 6*2,
                         "state_index_frames()")
testutils.confirm_equal( mrcal.state_index_calobject_warp(**optimization_inputs),
                         8*Ncameras + 6*(Ncameras-1) + 6*Nframes,
                         "state_index_calobject_warp()")

testutils.confirm_equal( mrcal.measurement_index_boards(2, **optimization_inputs),
                         object_width_n*object_height_n*2* 2,
                         "measurement_index_boards()")
testutils.confirm_equal( mrcal.measurement_index_regularization(**optimization_inputs),
                         object_width_n*object_height_n*2*Nframes*Ncameras,
                         "measurement_index_regularization()")


############# Calibration computed. Now I see how well I did
models_solved = \
    [ mrcal.cameramodel( optimization_inputs = optimization_inputs,
                         icam_intrinsics     = i )
      for i in range(Ncameras)]

# if 0:
#     for i in range(1,Ncameras):
#         models_solved[i].write(f'/tmp/tst{i}.cameramodel')