Skip to content

3. Script Descriptions: C_singleExtrinsicsSolution

burritobrittany edited this page Jul 17, 2020 · 4 revisions
  • C_singleExtrinsicSolution

    • Description:

    This function solves the extrinsics (EO) for a given camera for use in the toolbox. The user will load gcp and intrinsic (IO) information via input files. The user will specify coordinate system information as well as initial extrinsics rough guesses. The function will output the solved extrinsics in the form of the vector extrinsics, metadata information in initialCamSolutionMeta, and a reprojection error figure.

    Note, the extrinsics solution will be in the same coordinate system as the GCPs. Regardless of what the user enters, this will be referred to as the WORLD coordinate system with a subscript W. It is encouraged that the user enter GCPs in a geographic coordinate system (State Plane, UTM, etc). The toolbox will complete a coordinate system rotation in subsequent functions. Also, the nlinfit solver is very sensitive to the initial guess; so it must be an educated guess. It is particularly sensitive to the guessed azimuth, tilt, and swing. If incorrect, nlinfit will error or provide a nonsensical answer. Please check veracity of provided extrinsics. Descriptions of the World Coordinate System and extrinsic definitions (particularly azimuth, tilt, and swing) are in Section 6.

    This function is to be run third in the progression for each camera in a multi-camera fixed station or for each collection for a UAS platform. GCP calibration and geometry solution calculation should occur any time a camera has moved for a fixed station, the first frame in a new UAS collect, or intrinsics has changed.

    • Input:

    Input is entered by user into the script in Sections 1-4.

    Section 1: Saving Information

    Variable Description
    oname Output string for the basename for the Extrinsic/Intrinsic Solution mat files to be saved under.
    odir Output filepath where the Extrinsic/Intrinsic Solution mat file will be saved.

    Section 2: Intrinsics

Variable Description
iopath Filepath of the intrinsics matfile output by A_formatIntrinsics. Matfile should contain at minimum the following variable. Note, the intrinsics should correspond to the recording mode and camera/lens for the image taken in B_gcpSelection, imagePath.
intrinsics A [1x11] vector describing the focal lengths and distortion of the camera/lens combination. Distortion coefficients are defined by [3] and defined in Section 6.

    Section 3: GCP Information

Variable Description
gcpUVdPath Filepath of the Distorted GCP UV Coordinates produced by B_gcpSelection. The intrinsics of the corresponding image from which the UVd GCP coordinates were derived from should match that entered in Section 2. If not produced by B, minimum variables are listed below.
gcp A structure with each entry corresponding to a GCP. Note, the index entry in the structure may not correspond with the GCP identifying number. Required fields of structure are:
UVd [1 x 2] Vector of distorted Image coordinates of GCP
num Identifying GCP number entered by user.
gcpXyzPath filepath of the GCP World coordinates. File should be a four column comma delimted txt file with columns representing gcp number, x coordinate, y coordinate, and z coordinate. Rows will correspond to each GCP. GCP numbers should match with those entered in B_gcpSelection. Example text file structure in Figure 3. It is encouraged to enter GCPs in a geographic coordinate system (State Plane, UTM, etc).
gcpCoord String that describes the coordinate system (World) and units of the entered GCPs in gcpXyzpath
imagePath Filepath of the image you would like GCP reprojection checked against (plotted in). This should be the same image used in B_gcpSelection (imagePath) if you are doing a UAS collect or a moving camera. For a fixed camera, it can be any image where the GCPs are visible.
gcpsUsed The numbers of GCPs you would like to use for the solution. Numbers must match gcp.num values found in gpcUvPath and gcpXyzPath files. You do not have to use all of the clicked GCPS or GCPS listed in the file.




Figure 3: Example GCP input txt file for C_singleExtrinsicSolution

    Section 4: Solution Information
    Variable Description
    extrinsicsInitialGuess A [1x6] vector of the initial guess of extrinsics, the EO solution, for the corresponding camera image. Extrinsics is formatted as [ x y z azimuth tilt swing] where xyz correspond to the same world coordinate system as gcps entered in gcpXyzPath in Section 3. Azimuth, tilt and swing should be in radians. For UAS, this information can be estimated from the autopilot. For fixed camera stations it is suggested you survey in the location of the cameras. Further descriptions of the extrinsics vector and world coordinate systems can be found in Section 6.
    extrinsicsKnownsFlag Enter the number of knowns, or what you would like fixed in your EO solution. 1 represents fixed where 0 represents floating (solvable) for each value in extrinsics. Review [4] for a discussion of which extrinsics may float relative to the number of GCPs and the effect on rectification accuracy.
    • Output:

    A .mat file saved as oname_IOEOInitial.mat in odir. Will contain following variables.

Variable Description
initialCamSolutionMeta Structure with metadata about extrinsic solution. Fields are listed below. Those left blank are the same entered in the input sections.
gcpUsed
gcpRMSE A [1 x 3] vector with the root mean squared error between the entered world XYZ coordinates of the GCPs in gcpXyzPath and world XYZ coordinates found using the extrinsic solution and UVd coordinates in gcpUvdPath. All GCPS used, not just those specified in gcpsUsed. Units are in units entered in gcpXYZPath.
extrinsicsInitialGuess
extrinsicsKnownsFlag
extrinsicsUncert A [ 1 x 6] vector with the uncertainty value of each solved extrinsic value provided by nlinfit. Units are in units entered in gcpXYZPath for position and radians for pose.
imagePath
worldCoordSys Description of world coordinate system, same as gcpCoord.
gcp Same as entered in Section 3 but with the additional fields
x XYZ coordinates as entered in gcpXyzPath
y
z
CoordSys Description of world coordinate system, same as gcpCoord.
xReprojError Difference between the entered world XYZ coordinates of the GCPs in gcpXyzPath and world XYZ coordinates found using the extrinsic solution and UVd coordinates in gcpUvdPath.
yReprojError
intrinsics A [1x11] vector describing the focal lengths and distortion of the camera/lens combination. Distortion coefficients are defined by [3] and defined in Section 6.
extrinsics A [1x6] vector describing the camera pose and position in WORLD coordinates (whatever coordinate system GCPs were entered in). Extrinsic values are defined in Section 6 along with coordinate systems.



    A figure with the original ‘clicked’ GCPs plotted on the imagePath in red along with the reprojected GCP values using the extrinsic solution in yellow. Example from uasDemoData shown In Figure 4. Note, red is difficult to see because it is a high accuracy solution and yellow is directly on top.


Figure 4: Example reprojection figure in C_singelExtrinsicSolution for uasDemoData to observe extrinsic solution accuracy.

    • Required Core Sub-Functions:

      • extrinsicsSolver

      • xyz2DistUV

      • intrinsicsExtrinsics2P

      • distortUV

      • distUV2XYZ

      • undistortUV

      • Requires Also: MATLAB Statistics and Machine Learning Toolbox

Clone this wiki locally