点群マッチングによる座標系パラメータ(原点座標,傾きおよびスケール)の算出
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_pfit_coord( int iPntNum, DPNT_T_PTR taOldPnt, DPNT_T_PTR taNewPnt, double dSigmaCoef, f_pfit_calc_mode iCalcMode, ref double dpXc, ref double dpYc, ref double dpQc, ref double dpSc ) |
Visual Basic |
---|
Public Shared Function fnFIE_pfit_coord ( iPntNum As Integer, taOldPnt As DPNT_T_PTR, taNewPnt As DPNT_T_PTR, dSigmaCoef As Double, iCalcMode As f_pfit_calc_mode, ByRef dpXc As Double, ByRef dpYc As Double, ByRef dpQc As Double, ByRef dpSc As Double ) As Integer |
Parameters
- iPntNum
- Type: System..::..Int32
データ(座標)点の数(2点以上)
- taOldPnt
- Type: fvalgcli..::..DPNT_T_PTR
旧座標系上の座標値群(合わされる方)
- taNewPnt
- Type: fvalgcli..::..DPNT_T_PTR
新座標系上の座標値群(合わせる方)
- dSigmaCoef
- Type: System..::..Double
ロバスト推定用重み閾値の係数
- iCalcMode
- Type: fvalgcli..::..f_pfit_calc_mode
処理選択- F_PFIT_LSQ 最小二乗法:スケール推定なし
- F_PFIT_LSQ_SCALE 最小二乗法:スケール推定あり
- F_PFIT_RBST ロバスト推定:スケール推定なし
- F_PFIT_RBST_SCALE ロバスト推定:スケール推定あり
- F_PFIT_MINMAX ミニマックス近似:スケール推定なし
- F_PFIT_MINMAX_SCALE ミニマックス近似:スケール推定あり
- dpXc
- Type: System..::..Double%
旧座標系から見た新座標系の原点x座標
- dpYc
- Type: System..::..Double%
旧座標系から見た新座標系の原点y座標
- dpQc
- Type: System..::..Double%
旧座標系から見た新座標系の傾き(rad:[-π,π])
- dpSc
- Type: System..::..Double%
旧座標系から見た新座標系のスケール(相似比)(処理選択で'スケール推定なし'を選択した場合は、1.0 が返ります。)
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_NOMEMORY | メモリ確保失敗 |
F_ERR_INVALID_PARAM | パラメータ不正 |
F_ERR_CALC_IMPOSSIBLE | ロバスト推定失敗(重み閾値が小さくなりすぎた)または ミニマックス近似失敗(反復回数オーバー) |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Remarks
Examples
C# | Copy |
---|---|
// $Revision: 1.1 $ using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace TC { public partial class FIE { [FvPluginExecute] public void fnFIE_pfit_coord() { int status = (int)f_err.F_ERR_NONE; // 点列(変換前と変換後). DPNT_T_PTR taOldPnt = DPNT_T_PTR.Zero; DPNT_T_PTR taNewPnt = DPNT_T_PTR.Zero; int num = 4; // 点列数. // 変換行列. FMATRIX_PTR mat_rotate = FMATRIX_PTR.Zero; FMATRIX_PTR mat_scale = FMATRIX_PTR.Zero; FMATRIX_PTR mat = FMATRIX_PTR.Zero; // 変換行列生成用パラメータ(回転). double rad = Math.PI / 2; double cx = 75; double cy = 75; // 変換行列生成用パラメータ(スケール). double sx = 2.0; double sy = 2.0; // 座標系パラメータ [out]. double dpXc = 0; double dpYc = 0; double dpTheta = 0; double dpScale = 0; const double ans_Scale = 0.5; try { // 行列の領域確保. mat_rotate = FMATRIX_PTR.alloc(3, 3); mat_scale = FMATRIX_PTR.alloc(3, 3); mat = FMATRIX_PTR.alloc(3, 3); // 点列の領域を確保. taOldPnt = DPNT_T_PTR.alloc(num); taNewPnt = DPNT_T_PTR.alloc(num); // 回転及びスケールの変換行列を求める. api.fnFIE_geotrans_calc_rotate_matrix(mat_rotate,rad, cx, cy); api.fnFIE_geotrans_calc_scale_matrix(mat_scale, sx, sy); // 行列を掛け,1つの行列にまとめる. api.fnFIE_mat_mul_aa(mat_scale, mat_rotate, mat); // 点列の座標を指定する. taOldPnt[0] = DPNT_T.init(50, 50); taOldPnt[1] = DPNT_T.init(100, 50); taOldPnt[2] = DPNT_T.init(50, 100); taOldPnt[3] = DPNT_T.init(100, 100); // 点列をアフィン変換して新座標系での点群とする. api.fnFIE_geotrans_affine_npoints(taOldPnt, taNewPnt, num, mat); // 点群マッチングによる座標系パラメータ(原点座標,傾きおよびスケール)の算出. status = api.fnFIE_pfit_coord(num, taOldPnt, taNewPnt, 3, f_pfit_calc_mode.F_PFIT_RBST_SCALE, ref dpXc, ref dpYc, ref dpTheta, ref dpScale); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 結果を出力する. ConsoleOut.WriteFunctionName(":\n"); Console.WriteLine(" dpXc = {0}\n dpYc = {1}\n dpTheta = {2}\n dpScale = {3}", dpXc, dpYc, dpTheta, dpScale); Console.Write(" ..."); ConsoleOut.IsTrue(ans_Scale == dpScale); } finally { mat_rotate.Dispose(); mat_scale.Dispose(); mat.Dispose(); taOldPnt.Dispose(); taNewPnt.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE <FvPluginExecute> _ Public Sub fnFIE_pfit_coord() Dim status As Integer = CInt(f_err.F_ERR_NONE) ' 点列(変換前と変換後). Dim taOldPnt As DPNT_T_PTR = DPNT_T_PTR.Zero Dim taNewPnt As DPNT_T_PTR = DPNT_T_PTR.Zero Dim num As Integer = 4 ' 点列数. ' 変換行列. Dim mat_rotate As FMATRIX_PTR = FMATRIX_PTR.Zero Dim mat_scale As FMATRIX_PTR = FMATRIX_PTR.Zero Dim mat As FMATRIX_PTR = FMATRIX_PTR.Zero ' 変換行列生成用パラメータ(回転). Dim rad As Double = Math.PI / 2 Dim cx As Double = 75 Dim cy As Double = 75 ' 変換行列生成用パラメータ(スケール). Dim sx As Double = 2.0 Dim sy As Double = 2.0 ' 座標系パラメータ [out]. Dim dpXc As Double = 0 Dim dpYc As Double = 0 Dim dpTheta As Double = 0 Dim dpScale As Double = 0 Const ans_Scale As Double = 0.5 Try ' 行列の領域確保. mat_rotate = FMATRIX_PTR.alloc(3, 3) mat_scale = FMATRIX_PTR.alloc(3, 3) mat = FMATRIX_PTR.alloc(3, 3) ' 点列の領域を確保. taOldPnt = DPNT_T_PTR.alloc(num) taNewPnt = DPNT_T_PTR.alloc(num) ' 回転及びスケールの変換行列を求める. api.fnFIE_geotrans_calc_rotate_matrix(mat_rotate, rad, cx, cy) api.fnFIE_geotrans_calc_scale_matrix(mat_scale, sx, sy) ' 行列を掛け,1つの行列にまとめる. api.fnFIE_mat_mul_aa(mat_scale, mat_rotate, mat) ' 点列の座標を指定する. taOldPnt(0) = DPNT_T.init(50, 50) taOldPnt(1) = DPNT_T.init(100, 50) taOldPnt(2) = DPNT_T.init(50, 100) taOldPnt(3) = DPNT_T.init(100, 100) ' 点列をアフィン変換して新座標系での点群とする. api.fnFIE_geotrans_affine_npoints(taOldPnt, taNewPnt, num, mat) ' 点群マッチングによる座標系パラメータ(原点座標,傾きおよびスケール)の算出. status = api.fnFIE_pfit_coord(num, taOldPnt, taNewPnt, 3, f_pfit_calc_mode.F_PFIT_RBST_SCALE, dpXc, _ dpYc, dpTheta, dpScale) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 結果を出力する. ConsoleOut.WriteFunctionName(":" & vbLf) Console.WriteLine(" dpXc = {0}" & vbLf & " dpYc = {1}" & vbLf & " dpTheta = {2}" & vbLf & " dpScale = {3}", dpXc, dpYc, dpTheta, dpScale) Console.Write(" ...") ConsoleOut.IsTrue(ans_Scale = dpScale) Finally mat_rotate.Dispose() mat_scale.Dispose() mat.Dispose() taOldPnt.Dispose() taNewPnt.Dispose() End Try End Sub End Class |