HALCON Reference Manual 10.0.2
Table of Contents / Tools / Mosaicking ClassesClassesClasses | | | Operators

bundle_adjust_mosaicT_bundle_adjust_mosaicbundle_adjust_mosaicBundleAdjustMosaicBundleAdjustMosaic (Operator)

Name

bundle_adjust_mosaicT_bundle_adjust_mosaicbundle_adjust_mosaicBundleAdjustMosaicBundleAdjustMosaic — Perform a bundle adjustment of an image mosaic.

Signature

bundle_adjust_mosaic( : : NumImages, ReferenceImage, MappingSource, MappingDest, HomMatrices2D, Rows1, Cols1, Rows2, Cols2, NumCorrespondences, Transformation : MosaicMatrices2D, Rows, Cols, Error)

Herror T_bundle_adjust_mosaic(const Htuple NumImages, const Htuple ReferenceImage, const Htuple MappingSource, const Htuple MappingDest, const Htuple HomMatrices2D, const Htuple Rows1, const Htuple Cols1, const Htuple Rows2, const Htuple Cols2, const Htuple NumCorrespondences, const Htuple Transformation, Htuple* MosaicMatrices2D, Htuple* Rows, Htuple* Cols, Htuple* Error)

Herror bundle_adjust_mosaic(const HTuple& NumImages, const HTuple& ReferenceImage, const HTuple& MappingSource, const HTuple& MappingDest, const HTuple& HomMatrices2D, const HTuple& Rows1, const HTuple& Cols1, const HTuple& Rows2, const HTuple& Cols2, const HTuple& NumCorrespondences, const HTuple& Transformation, HTuple* MosaicMatrices2D, HTuple* Rows, HTuple* Cols, HTuple* Error)

void HOperatorSetX.BundleAdjustMosaic(
[in] VARIANT NumImages, [in] VARIANT ReferenceImage, [in] VARIANT MappingSource, [in] VARIANT MappingDest, [in] VARIANT HomMatrdces2D, [in] VARIANT Rows1, [in] VARIANT Cols1, [in] VARIANT Rows2, [in] VARIANT Cols2, [in] VARIANT NumCorrespondences, [in] VARIANT Transformation, [out] VARIANT* MosaicMatrices2D, [out] VARIANT* Rows, [out] VARIANT* Cols, [out] VARIANT* Error)

IHHomMat2DX* HHomMat2DX.BundleAdjustMosaic(
[in] Hlong NumImages, [in] Hlong ReferenceImage, [in] VARIANT MappingSource, [in] VARIANT MappingDest, [in] IHHomMat2DX* HomMatrdces2D, [in] VARIANT Rows1, [in] VARIANT Cols1, [in] VARIANT Rows2, [in] VARIANT Cols2, [in] VARIANT NumCorrespondences, [in] BSTR Transformation, [out] VARIANT* Rows, [out] VARIANT* Cols, [out] VARIANT* Error)

static void HOperatorSet.BundleAdjustMosaic(HTuple numImages, HTuple referenceImage, HTuple mappingSource, HTuple mappingDest, HTuple homMatrices2D, HTuple rows1, HTuple cols1, HTuple rows2, HTuple cols2, HTuple numCorrespondences, HTuple transformation, out HTuple mosaicMatrices2D, out HTuple rows, out HTuple cols, out HTuple error)

static HHomMat2D[] HHomMat2D.BundleAdjustMosaic(int numImages, int referenceImage, HTuple mappingSource, HTuple mappingDest, HHomMat2D[] homMatrices2D, HTuple rows1, HTuple cols1, HTuple rows2, HTuple cols2, HTuple numCorrespondences, string transformation, out HTuple rows, out HTuple cols, out HTuple error)

static HHomMat2D[] HHomMat2D.BundleAdjustMosaic(int numImages, int referenceImage, HTuple mappingSource, HTuple mappingDest, HHomMat2D[] homMatrices2D, HTuple rows1, HTuple cols1, HTuple rows2, HTuple cols2, HTuple numCorrespondences, string transformation, out HTuple rows, out HTuple cols, out double error)

Description

bundle_adjust_mosaicbundle_adjust_mosaicbundle_adjust_mosaicBundleAdjustMosaicBundleAdjustMosaic performs a bundle adjustment of an image mosaic. This can be used to determine the geometry of a mosaic as robustly as possible, and hence to determine the transformations of the images in the mosaic more accurately than with single image pairs.

To achieve this, the projective transformation for each overlapping image pair in the mosaic should be determined with proj_match_points_ransacproj_match_points_ransacproj_match_points_ransacProjMatchPointsRansacProjMatchPointsRansac. For example, for a 2x2 block of images in the following layout

+---+---+
| 1 | 2 |
+---+---+
| 3 | 4 |
+---+---+

the following projective transformations should be determined, assuming that all images overlap each other: 1->2, 1->3, 1->4, 2->3, 2->4 and 3->4. The indices of the images that determine the respective transformation are given by MappingSourceMappingSourceMappingSourceMappingSourcemappingSource and MappingDestMappingDestMappingDestMappingDestmappingDest. The indices are start at 1. Consequently, in the above example MappingSourceMappingSourceMappingSourceMappingSourcemappingSource = [1,1,1,2,2,3] and MappingDestMappingDestMappingDestMappingDestmappingDest = [2,3,4,3,4,4] must be used. The number of images in the mosaic is given by NumImagesNumImagesNumImagesNumImagesnumImages. It is used to check whether each image can be reached by a chain of transformations. The index of the reference image is given by ReferenceImageReferenceImageReferenceImageReferenceImagereferenceImage. On output, this image has the identity matrix as its transformation matrix.

The 3x3 projective transformation matrices that correspond to the image pairs are passed in HomMatrices2DHomMatrices2DHomMatrices2DHomMatrices2DhomMatrices2D. Additionally, the coordinates of the matched point pairs in the image pairs must be passed in Rows1Rows1Rows1Rows1rows1, Cols1Cols1Cols1Cols1cols1, Rows2Rows2Rows2Rows2rows2, and Cols2Cols2Cols2Cols2cols2. They can be determined from the output of proj_match_points_ransacproj_match_points_ransacproj_match_points_ransacProjMatchPointsRansacProjMatchPointsRansac with tuple_selecttuple_selecttuple_selectTupleSelectTupleSelect or with the HDevelop function subset. To enable bundle_adjust_mosaicbundle_adjust_mosaicbundle_adjust_mosaicBundleAdjustMosaicBundleAdjustMosaic to determine which point pair belongs to which image pair, NumCorrespondencesNumCorrespondencesNumCorrespondencesNumCorrespondencesnumCorrespondences must contain the number of found point matches for each image pair.

The parameter TransformationTransformationTransformationTransformationtransformation determines the class of transformations that is used in the bundle adjustment to transform the image points. This can be used to restrict the allowable transformations. For TransformationTransformationTransformationTransformationtransformation = 'projective'"projective""projective""projective""projective", projective transformations are used (see vector_to_proj_hom_mat2dvector_to_proj_hom_mat2dvector_to_proj_hom_mat2dVectorToProjHomMat2dVectorToProjHomMat2d). For TransformationTransformationTransformationTransformationtransformation = 'affine'"affine""affine""affine""affine", affine transformations are used (see vector_to_hom_mat2dvector_to_hom_mat2dvector_to_hom_mat2dVectorToHomMat2dVectorToHomMat2d), for TransformationTransformationTransformationTransformationtransformation = 'similarity'"similarity""similarity""similarity""similarity", similarity transformations (see vector_to_similarityvector_to_similarityvector_to_similarityVectorToSimilarityVectorToSimilarity), and for TransformationTransformationTransformationTransformationtransformation = 'rigid'"rigid""rigid""rigid""rigid" rigid transformations (see vector_to_rigidvector_to_rigidvector_to_rigidVectorToRigidVectorToRigid).

The resulting bundle-adjusted transformations are retuned as an array of 3x3 projective transformation matrices in MosaicMatrices2DMosaicMatrices2DMosaicMatrices2DMosaicMatrices2DmosaicMatrices2D. In addition, the points reconstructed by the bundle adjustment are returned in (RowsRowsRowsRowsrows, ColsColsColsColscols). The average projection error of the reconstructed points is returned in ErrorErrorErrorErrorerror. This can be used to check whether the optimization has converged to useful values.

Parallelization

Parameters

NumImagesNumImagesNumImagesNumImagesnumImages (input_control)  integer HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Number of different images that are used for the calibration.

Restriction: NumImages >= 2

ReferenceImageReferenceImageReferenceImageReferenceImagereferenceImage (input_control)  integer HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Index of the reference image.

MappingSourceMappingSourceMappingSourceMappingSourcemappingSource (input_control)  integer-array HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Indices of the source images of the transformations.

MappingDestMappingDestMappingDestMappingDestmappingDest (input_control)  integer-array HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Indices of the target images of the transformations.

HomMatrices2DHomMatrices2DHomMatrices2DHomMatrices2DhomMatrices2D (input_control)  hom_mat2d-array HHomMat2D, HTupleHTupleHHomMat2DX, VARIANTHtuple (real) (double) (double) (double) (double)

Array of 3x3 projective transformation matrices.

Rows1Rows1Rows1Rows1rows1 (input_control)  point.x-array HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Row coordinates of corresponding points in the respective source images.

Cols1Cols1Cols1Cols1cols1 (input_control)  point.y-array HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Column coordinates of corresponding points in the respective source images.

Rows2Rows2Rows2Rows2rows2 (input_control)  point.x-array HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Row coordinates of corresponding points in the respective destination images.

Cols2Cols2Cols2Cols2cols2 (input_control)  point.y-array HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Column coordinates of corresponding points in the respective destination images.

NumCorrespondencesNumCorrespondencesNumCorrespondencesNumCorrespondencesnumCorrespondences (input_control)  integer-array HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Number of point correspondences in the respective image pair.

TransformationTransformationTransformationTransformationtransformation (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Transformation class to be used.

Default value: 'projective' "projective" "projective" "projective" "projective"

List of values: 'projective'"projective""projective""projective""projective", 'affine'"affine""affine""affine""affine", 'similarity'"similarity""similarity""similarity""similarity", 'rigid'"rigid""rigid""rigid""rigid"

MosaicMatrices2DMosaicMatrices2DMosaicMatrices2DMosaicMatrices2DmosaicMatrices2D (output_control)  hom_mat2d-array HHomMat2D, HTupleHTupleHHomMat2DX, VARIANTHtuple (real) (double) (double) (double) (double)

Array of 3x3 projective transformation matrices that determine the position of the images in the mosaic.

RowsRowsRowsRowsrows (output_control)  point.x-array HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Row coordinates of the points reconstructed by the bundle adjustment.

ColsColsColsColscols (output_control)  point.y-array HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Column coordinates of the points reconstructed by the bundle adjustment.

ErrorErrorErrorErrorerror (output_control)  real(-array) HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Average error per reconstructed point.

Example (HDevelop)

* Assume that Images contains the four images of the mosaic in the
* layout given in the above description.  Then the following example
* computes the bundle-adjusted transformation matrices.
From := [1,1,1,2,2,3]
To := [2,3,4,3,4,4]
HomMatrices2D := []
Rows1 := []
Cols1 := []
Rows2 := []
Cols2 := []
NumMatches := []
for J := 0 to |From|-1 by 1
    select_obj (Images, ImageF, From[J])
    select_obj (Images, ImageT, To[J])
    points_foerstner (ImageF, 1, 2, 3, 100, 0.1, 'gauss', 'true', \
                      RowsF, ColsF, _, _, _, _, _, _, _, _)
    points_foerstner (ImageT, 1, 2, 3, 100, 0.1, 'gauss', 'true', \
                      RowsT, ColsT, _, _, _, _, _, _, _, _)
    proj_match_points_ransac (ImageF, ImageT, RowsF, ColsF, RowsT, ColsT, \
                              'ncc', 10, 0, 0, 480, 640, 0, 0.5, \
                              'gold_standard', 2, 42, HomMat2D, \
                              Points1, Points2)
    HomMatrices2D := [HomMatrices2D,HomMat2D]
    Rows1 := [Rows1,subset(RowsF,Points1)]
    Cols1 := [Cols1,subset(ColsF,Points1)]
    Rows2 := [Rows2,subset(RowsT,Points2)]
    Cols2 := [Cols2,subset(ColsT,Points2)]
    NumMatches := [NumMatches,|Points1|]
endfor
bundle_adjust_mosaic (4, 1, From, To, HomMatrices2D, Rows1, Cols1, \
                      Rows2, Cols2, NumMatches, 'rigid', MosaicMatrices, \
                      Rows, Columns, Error)
gen_bundle_adjusted_mosaic (Images, MosaicImage, HomMatrices2D, \
                            'default', 'false', TransMat2D)

Result

If the parameters are valid, the operator bundle_adjust_mosaicbundle_adjust_mosaicbundle_adjust_mosaicBundleAdjustMosaicBundleAdjustMosaic returns the value 2 (H_MSG_TRUE). If necessary an exception is raised.

Possible Predecessors

proj_match_points_ransacproj_match_points_ransacproj_match_points_ransacProjMatchPointsRansacProjMatchPointsRansac, proj_match_points_ransac_guidedproj_match_points_ransac_guidedproj_match_points_ransac_guidedProjMatchPointsRansacGuidedProjMatchPointsRansacGuided

Possible Successors

gen_bundle_adjusted_mosaicgen_bundle_adjusted_mosaicgen_bundle_adjusted_mosaicGenBundleAdjustedMosaicGenBundleAdjustedMosaic

See also

gen_projective_mosaicgen_projective_mosaicgen_projective_mosaicGenProjectiveMosaicGenProjectiveMosaic

Module

Matching


Table of Contents / Tools / Mosaicking ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH