WIL説明書(C++)  3.0.0
関数

詳解

関数

FVCL_API INT FVCL::FPM2::CreateFeature (FVCL::FPM2::CFvFPM2Feature *dst, const FVCL::Edge::CFvEdgeResultD64 &edges, INT match_mode, INT width, INT height)
 FPM特徴量オブジェクトの生成 [詳解]
 
FVCL_API INT FVCL::FPM2::CreateTemplate (FVCL::FPM2::CFvFPM2Template *dst, const FVCL::Edge::CFvEdgeResultD64 &edges, INT match_mode, const FVCL::Data::CFvPoint &offset, const FVCL::Data::CFvImage *src)
 FPMオブジェクトの生成 (エッジ点群指定) [詳解]
 
FVCL_API INT FVCL::FPM2::CreateShapeEllipse (FVCL::FPM2::CFvFPM2Template *dst, DOUBLE a, DOUBLE b, bool is_white, INT match_mode)
 FPMオブジェクトの生成 (形状指定:楕円) [詳解]
 
FVCL_API INT FVCL::FPM2::CreateShapeRetangle (FVCL::FPM2::CFvFPM2Template *dst, DOUBLE width, DOUBLE height, bool is_white, INT match_mode)
 FPMオブジェクトの生成 (形状指定:矩形) [詳解]
 
FVCL_API INT FVCL::FPM2::CreateShapeCross (FVCL::FPM2::CFvFPM2Template *dst, DOUBLE a, DOUBLE b, bool is_close, bool is_white, INT match_mode)
 FPMオブジェクトの生成 (形状指定:十字) [詳解]
 
FVCL_API INT FVCL::FPM2::GetFeatureEdges (const FVCL::FPM2::CFvFPM2Feature &src, FVCL::Edge::CFvEdgeResultD64 *edges)
 特徴量の取得 (マッチング対象) [詳解]
 
FVCL_API INT FVCL::FPM2::GetFeatureEdgesCount (const FVCL::FPM2::CFvFPM2Feature &src)
 特徴量数の取得 (マッチング対象) [詳解]
 
FVCL_API INT FVCL::FPM2::GetTemplateEdges (const FVCL::FPM2::CFvFPM2Template &src, FVCL::Edge::CFvEdgeResultD64 *edges)
 特徴量の取得 (テンプレート) [詳解]
 
FVCL_API INT FVCL::FPM2::GetTemplateEdgesCount (const FVCL::FPM2::CFvFPM2Template &src)
 特徴量数の取得 (テンプレート) [詳解]
 
FVCL_API INT FVCL::FPM2::GetMatchingEdges (const FVCL::FPM2::CFvFPM2Template &src, FVCL::Edge::CFvEdgeResultD64 *edges)
 マッチングで使用した特徴量の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::GetMatchingEdgesCount (const FVCL::FPM2::CFvFPM2Template &src)
 マッチングで使用した特徴量数の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::GetRelativeEdges (const FVCL::FPM2::CFvFPM2Template &src, INT no, INT err_wide, FVCL::Edge::CFvEdgeResultD64 *edges)
 指定ポーズ下の対応点の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::GetCompressedTemplateEdges (const FVCL::FPM2::CFvFPM2Template &templ, FVCL::Edge::CFvEdgeResultD64 *edges)
 圧縮特徴量の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::GetCompressedMatchingEdges (const FVCL::FPM2::CFvFPM2Template &templ, FVCL::Edge::CFvEdgeResultD64 *edges)
 圧縮特徴量の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::GetCompressedFeatureEdges (const FVCL::FPM2::CFvFPM2Template &templ, const FVCL::FPM2::CFvFPM2Feature &target, FVCL::Edge::CFvEdgeResultD64 *edges)
 圧縮特徴量の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::SetTemplateEdgelessMask (FVCL::FPM2::CFvFPM2Template &templ, const FVCL::Data::CFvImage &mask)
 エッジ減点領域情報の設定 [詳解]
 
FVCL_API INT FVCL::FPM2::GetTemplateEdgelessMask (const FVCL::FPM2::CFvFPM2Template &templ, FVCL::Data::CFvImage *mask)
 エッジ減点領域情報の取得 [詳解]
 
FVCL_API INT FVCL::FPM2::MatchingRecalcWithEdgelessMask (const FVCL::FPM2::CFvFPM2Template &templ, const FVCL::FPM2::CFvFPM2Feature &target, INT err_wide, DOUBLE noise_weight, INT threshold, INT required_num, CFvFPM2Result *result)
 特定領域エッジ減点スコア計算 [詳解]
 

関数詳解

FVCL::FPM2::CreateFeature ( FVCL::FPM2::CFvFPM2Feature dst,
const FVCL::Edge::CFvEdgeResultD64 edges,
INT  match_mode,
INT  width,
INT  height 
)

FPM特徴量オブジェクトの生成

エッジ点群を指定してオブジェクトを生成します。

引数
[out]dst対象のオブジェクト
[in]edges元になるエッジ点群
[in]match_modeマッチングモード [範囲:FVCL::FPM2::MatchMode に定義された定数]
[in]width元になるエッジ点群の座標範囲(幅)
[in]height元になるエッジ点群の座標範囲(高さ)
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
24 FVCL_ErrorCode::NOT_ENOUGH バッファが不足しています。
FVCL::FPM2::CreateTemplate ( FVCL::FPM2::CFvFPM2Template dst,
const FVCL::Edge::CFvEdgeResultD64 edges,
INT  match_mode,
const FVCL::Data::CFvPoint offset,
const FVCL::Data::CFvImage src 
)

FPMオブジェクトの生成 (エッジ点群指定)

エッジ点群を指定してオブジェクトを生成します。

引数
[out]dst対象のオブジェクト
[in]edges元になるエッジ点群
[in]match_modeマッチングモード [範囲:FVCL::FPM2::MatchMode に定義された定数]
[in]offsetマッチング回答オフセット値 (マスターパタン画像の左上位置からの相対値)
[in]srcedges を取得したマスターパタン画像 (type:UC8,ch:1) [省略時は null]
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
24 FVCL_ErrorCode::NOT_ENOUGH バッファが不足しています。
12 FVCL_ErrorCode::INVALID_OBJECT 画像オブジェクトが異常です。
FVCL::FPM2::CreateShapeEllipse ( FVCL::FPM2::CFvFPM2Template dst,
DOUBLE  a,
DOUBLE  b,
bool  is_white,
INT  match_mode 
)

FPMオブジェクトの生成 (形状指定:楕円)

形状を指定してオブジェクトを生成します。

引数
[out]dst対象のオブジェクト
[in]a楕円の方程式 パラメータ a (3.0≦a, 単位:画素)
[in]b楕円の方程式 パラメータ b (3.0≦b, 単位:画素)
[in]is_white楕円パタンの色 (true:白(背景より明るい)、false:黒(背景より暗い))
[in]match_modeマッチングモード [範囲:FVCL::FPM2::MatchMode に定義された定数]
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
24 FVCL_ErrorCode::NOT_ENOUGH バッファが不足しています。
FVCL::FPM2::CreateShapeRetangle ( FVCL::FPM2::CFvFPM2Template dst,
DOUBLE  width,
DOUBLE  height,
bool  is_white,
INT  match_mode 
)

FPMオブジェクトの生成 (形状指定:矩形)

形状を指定してオブジェクトを生成します。

引数
[out]dst対象のオブジェクト
[in]width矩形のX方向幅(3.0≦width, 単位:画素)
[in]height矩形のY方向高さ(3.0≦height, 単位:画素)
[in]is_white矩形パタンの色 (true:白(背景より明るい)、false:黒(背景より暗い))
[in]match_modeマッチングモード [範囲:FVCL::FPM2::MatchMode に定義された定数]
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
24 FVCL_ErrorCode::NOT_ENOUGH バッファが不足しています。
FVCL::FPM2::CreateShapeCross ( FVCL::FPM2::CFvFPM2Template dst,
DOUBLE  a,
DOUBLE  b,
bool  is_close,
bool  is_white,
INT  match_mode 
)

FPMオブジェクトの生成 (形状指定:十字)

形状を指定してオブジェクトを生成します。

引数
[out]dst対象のオブジェクト
[in]a十字パタンのパラメータ a (3.0≦a, 単位:画素)
[in]b十字パタンのパラメータ b (1.0≦b, b<a,単位:画素)
[in]is_close十字パタンの開閉状態 (true:閉じている、false:開いている)
[in]is_white十字パタンの色 (true:白(背景より明るい)、false:黒(背景より暗い))
[in]match_modeマッチングモード [範囲:FVCL::FPM2::MatchMode に定義された定数]
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
24 FVCL_ErrorCode::NOT_ENOUGH バッファが不足しています。
FVCL::FPM2::GetFeatureEdges ( const FVCL::FPM2::CFvFPM2Feature src,
FVCL::Edge::CFvEdgeResultD64 edges 
)

特徴量の取得 (マッチング対象)

エッジ点群を取得します。

引数
[in]src対象のオブジェクト
[out]edges取得したエッジ点群を格納するオブジェクト
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT FPMオブジェクトが異常です。Create を実行してください。
FVCL::FPM2::GetFeatureEdgesCount ( const FVCL::FPM2::CFvFPM2Feature src)

特徴量数の取得 (マッチング対象)

引数
[in]src対象のオブジェクト
戻り値
エッジ点群の数を返します。
FVCL::FPM2::GetTemplateEdges ( const FVCL::FPM2::CFvFPM2Template src,
FVCL::Edge::CFvEdgeResultD64 edges 
)

特徴量の取得 (テンプレート)

エッジ点群を取得します。

引数
[in]src対象のオブジェクト
[out]edges取得したエッジ点群を格納するオブジェクト
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT FPMオブジェクトが異常です。Create を実行してください。
FVCL::FPM2::GetTemplateEdgesCount ( const FVCL::FPM2::CFvFPM2Template src)

特徴量数の取得 (テンプレート)

引数
[in]src対象のオブジェクト
戻り値
エッジ点群の数を返します。
FVCL::FPM2::GetMatchingEdges ( const FVCL::FPM2::CFvFPM2Template src,
FVCL::Edge::CFvEdgeResultD64 edges 
)

マッチングで使用した特徴量の取得

エッジ点群を取得します。

引数
[in]src対象のオブジェクト
[out]edges取得したエッジ点群を格納するオブジェクト
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT FPMオブジェクトが異常です。Create を実行してください。
FVCL::FPM2::GetMatchingEdgesCount ( const FVCL::FPM2::CFvFPM2Template src)

マッチングで使用した特徴量数の取得

引数
[in]src対象のオブジェクト
戻り値
エッジ点群の数を返します。
FVCL::FPM2::GetRelativeEdges ( const FVCL::FPM2::CFvFPM2Template src,
INT  no,
INT  err_wide,
FVCL::Edge::CFvEdgeResultD64 edges 
)

指定ポーズ下の対応点の取得

エッジ点群を取得します。

引数
[in]src対象のオブジェクト
[in]no対応するエッジを取得するサーチ回答番号 (0~)
[in]err_wide誤差範囲 (0~)
[out]edges取得したエッジ点群を格納するオブジェクト
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT FPMオブジェクトが異常です。Create を実行してください。
FVCL::FPM2::GetCompressedTemplateEdges ( const FVCL::FPM2::CFvFPM2Template templ,
FVCL::Edge::CFvEdgeResultD64 edges 
)

圧縮特徴量の取得

マスターパタンの特徴量から圧縮特徴量を取得します。

引数
[in]templ特徴量オブジェクト (テンプレート)
[out]edges取得した特徴量を格納するオブジェクト
※ 内部で再確保されます。
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT 特徴量オブジェクトが異常です。
52 FVCL_ErrorCode::UNEXPECTED_ERROR 特徴量が見つかりません。
FIE:
fnFIE_fpm_get_compressed_feature_edges
サンプルコード:
ソースコード:
void GetCompressedEdges()
{
_tprintf(_T("%s\n"), __TFUNCTION__);
double msec;
// 1) インスタンスの準備.
// 2-1) 処理対象画像の取り込み.
src.Load( _T(".\\key_UC8_M.png") );
// 2-2) パタン画像の読み込み.
pattern.Load( _T(".\\key1.pat") );
// 3) パラメータ準備.
// ※パラメータを既定値から変更した部分は、コメントに [*] を記述しています.
//
// 3-1) (FPM2) 基本パラメータ設定
FVCL::FPM2::CFvFPM2Param param = matching.GetParam();
param.SetCount( 10 ); // [*] 検索個数.
param.SetAngleMin( FVCL::Data::CFvAngle(-180) ); // [ ] 回転角(下限)
param.SetAngleMax( FVCL::Data::CFvAngle(180) ); // [ ] 回転角(上限)
param.SetScaleMin( 100 ); // [ ] スケール(下限) (%)
param.SetScaleMax( 100 ); // [ ] スケール(上限) (%)
param.SetCompressionLevel( 3 ); // [ ] 圧縮レベル (3: 1/8)
param.SetErrorRange( 1 ); // [ ] 誤差範囲 (画素)
param.SetScoreThresholdL( 50 ); // [ ] 低圧縮処理時のスコア閾値.
param.SetScoreThresholdH( 50 ); // [ ] 高圧縮処理時のスコア閾値.
// 3-4) (FPM2) 特徴量
// (ソーベル) 特徴量抽出用パラメータ生成
edge_param.SetEdgeThreshold( 120 ); // [ ] エッジ強度値に対する閾値.
edge_param.SetNmsLength( 3 ); // [ ] 非極大抑制処理のフィルタ片幅.
// 3-4-1) (FPM2) 特徴量(テンプレート) 生成
templ.Create(pattern, FVCL::FPM2::MatchMode::Normal, edge_param);
// 3-4-2) (FPM2) 特徴量(処理対象画像) 生成
target.Create(src, FVCL::FPM2::MatchMode::Normal, edge_param, false);
// 4) 画像処理準備.
// 4-1) 処理対象オブジェクトの設定.
matching.SetParam( param ); // 3-1 基本パラメータ.
matching.SetTarget( &target ); // 3-4-1 特徴量(処理対象画像)
matching.SetTemplate( &templ ); // 3-4-2 特徴量(テンプレート)
matching.SetEnableAreaScore( false ); // [ ] 領域スコア算出 (false:行わない)
matching.SetEnableEssential( false ); // [ ] 不可欠領域スコア計算 (false:行わない)
// 5) 画像処理実行.
timer.Start();
if (!matching.Execute())
{
_tprintf(_T("Failed to execute. code=%d\n"), matching.GetErrorCode());
}
msec = timer.Stop();
_tprintf(_T("execute. %f msec, count=%d \n"), msec, matching.GetResultSize());
// 確認用) パタンのエッジ点
{
_tprintf(_T("pattern edges=%d \n"), edges_pattern.size());
}
// 確認用) 処理対象画像のエッジ点
{
_tprintf(_T("image edges=%d \n"), edges_image.size());
}
// 圧縮特徴量の取得 (マスターパタンの特徴量)
{
int status = FVCL::FPM2::GetCompressedTemplateEdges(templ, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedTemplateEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedTemplateEdges: edges = %d\n"), edges.GetCount());
}
// 圧縮特徴量の取得 (最後にマッチングに使用した特徴量)
{
int status = FVCL::FPM2::GetCompressedMatchingEdges(templ, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedMatchingEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedMatchingEdges: edges = %d\n"), edges.GetCount());
}
// 圧縮特徴量の取得 (マッチング対象の特徴量オブジェクト)
{
int status = FVCL::FPM2::GetCompressedFeatureEdges(templ, target, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedFeatureEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedFeatureEdges: edges = %d\n"), edges.GetCount());
}
}
出力結果)
User::SampleCode::FPM2::GetCompressedEdges
execute. 4.448200 msec, count=3 
pattern edges=396 
image edges=1888 
GetCompressedTemplateEdges: edges = 51
GetCompressedMatchingEdges: edges = 301
GetCompressedFeatureEdges: edges = 301
FVCL::FPM2::GetCompressedMatchingEdges ( const FVCL::FPM2::CFvFPM2Template templ,
FVCL::Edge::CFvEdgeResultD64 edges 
)

圧縮特徴量の取得

最後にマッチングに使用した特徴量から圧縮特徴量を取得します。

引数
[in]templ特徴量オブジェクト (テンプレート)
[out]edges取得した特徴量を格納するオブジェクト
※ 内部で再確保されます。
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT 特徴量オブジェクトが異常です。
52 FVCL_ErrorCode::UNEXPECTED_ERROR 特徴量が見つかりません。
FIE:
fnFIE_fpm_get_compressed_feature_edges
サンプルコード:
ソースコード:
void GetCompressedEdges()
{
_tprintf(_T("%s\n"), __TFUNCTION__);
double msec;
// 1) インスタンスの準備.
// 2-1) 処理対象画像の取り込み.
src.Load( _T(".\\key_UC8_M.png") );
// 2-2) パタン画像の読み込み.
pattern.Load( _T(".\\key1.pat") );
// 3) パラメータ準備.
// ※パラメータを既定値から変更した部分は、コメントに [*] を記述しています.
//
// 3-1) (FPM2) 基本パラメータ設定
FVCL::FPM2::CFvFPM2Param param = matching.GetParam();
param.SetCount( 10 ); // [*] 検索個数.
param.SetAngleMin( FVCL::Data::CFvAngle(-180) ); // [ ] 回転角(下限)
param.SetAngleMax( FVCL::Data::CFvAngle(180) ); // [ ] 回転角(上限)
param.SetScaleMin( 100 ); // [ ] スケール(下限) (%)
param.SetScaleMax( 100 ); // [ ] スケール(上限) (%)
param.SetCompressionLevel( 3 ); // [ ] 圧縮レベル (3: 1/8)
param.SetErrorRange( 1 ); // [ ] 誤差範囲 (画素)
param.SetScoreThresholdL( 50 ); // [ ] 低圧縮処理時のスコア閾値.
param.SetScoreThresholdH( 50 ); // [ ] 高圧縮処理時のスコア閾値.
// 3-4) (FPM2) 特徴量
// (ソーベル) 特徴量抽出用パラメータ生成
edge_param.SetEdgeThreshold( 120 ); // [ ] エッジ強度値に対する閾値.
edge_param.SetNmsLength( 3 ); // [ ] 非極大抑制処理のフィルタ片幅.
// 3-4-1) (FPM2) 特徴量(テンプレート) 生成
templ.Create(pattern, FVCL::FPM2::MatchMode::Normal, edge_param);
// 3-4-2) (FPM2) 特徴量(処理対象画像) 生成
target.Create(src, FVCL::FPM2::MatchMode::Normal, edge_param, false);
// 4) 画像処理準備.
// 4-1) 処理対象オブジェクトの設定.
matching.SetParam( param ); // 3-1 基本パラメータ.
matching.SetTarget( &target ); // 3-4-1 特徴量(処理対象画像)
matching.SetTemplate( &templ ); // 3-4-2 特徴量(テンプレート)
matching.SetEnableAreaScore( false ); // [ ] 領域スコア算出 (false:行わない)
matching.SetEnableEssential( false ); // [ ] 不可欠領域スコア計算 (false:行わない)
// 5) 画像処理実行.
timer.Start();
if (!matching.Execute())
{
_tprintf(_T("Failed to execute. code=%d\n"), matching.GetErrorCode());
}
msec = timer.Stop();
_tprintf(_T("execute. %f msec, count=%d \n"), msec, matching.GetResultSize());
// 確認用) パタンのエッジ点
{
_tprintf(_T("pattern edges=%d \n"), edges_pattern.size());
}
// 確認用) 処理対象画像のエッジ点
{
_tprintf(_T("image edges=%d \n"), edges_image.size());
}
// 圧縮特徴量の取得 (マスターパタンの特徴量)
{
int status = FVCL::FPM2::GetCompressedTemplateEdges(templ, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedTemplateEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedTemplateEdges: edges = %d\n"), edges.GetCount());
}
// 圧縮特徴量の取得 (最後にマッチングに使用した特徴量)
{
int status = FVCL::FPM2::GetCompressedMatchingEdges(templ, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedMatchingEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedMatchingEdges: edges = %d\n"), edges.GetCount());
}
// 圧縮特徴量の取得 (マッチング対象の特徴量オブジェクト)
{
int status = FVCL::FPM2::GetCompressedFeatureEdges(templ, target, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedFeatureEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedFeatureEdges: edges = %d\n"), edges.GetCount());
}
}
出力結果)
User::SampleCode::FPM2::GetCompressedEdges
execute. 4.448200 msec, count=3 
pattern edges=396 
image edges=1888 
GetCompressedTemplateEdges: edges = 51
GetCompressedMatchingEdges: edges = 301
GetCompressedFeatureEdges: edges = 301
FVCL::FPM2::GetCompressedFeatureEdges ( const FVCL::FPM2::CFvFPM2Template templ,
const FVCL::FPM2::CFvFPM2Feature target,
FVCL::Edge::CFvEdgeResultD64 edges 
)

圧縮特徴量の取得

マッチング対象の特徴量オブジェクト (target) から圧縮特徴量を取得します。

引数
[in]templ特徴量オブジェクト (テンプレート)
[in]target特徴量オブジェクト (マッチング対象)
[out]edges取得した特徴量を格納するオブジェクト
※ 内部で再確保されます。
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT 特徴量オブジェクトが異常です。
52 FVCL_ErrorCode::UNEXPECTED_ERROR 特徴量が見つかりません。
FIE:
fnFIE_fpm_get_compressed_feature_edges
サンプルコード:
ソースコード:
void GetCompressedEdges()
{
_tprintf(_T("%s\n"), __TFUNCTION__);
double msec;
// 1) インスタンスの準備.
// 2-1) 処理対象画像の取り込み.
src.Load( _T(".\\key_UC8_M.png") );
// 2-2) パタン画像の読み込み.
pattern.Load( _T(".\\key1.pat") );
// 3) パラメータ準備.
// ※パラメータを既定値から変更した部分は、コメントに [*] を記述しています.
//
// 3-1) (FPM2) 基本パラメータ設定
FVCL::FPM2::CFvFPM2Param param = matching.GetParam();
param.SetCount( 10 ); // [*] 検索個数.
param.SetAngleMin( FVCL::Data::CFvAngle(-180) ); // [ ] 回転角(下限)
param.SetAngleMax( FVCL::Data::CFvAngle(180) ); // [ ] 回転角(上限)
param.SetScaleMin( 100 ); // [ ] スケール(下限) (%)
param.SetScaleMax( 100 ); // [ ] スケール(上限) (%)
param.SetCompressionLevel( 3 ); // [ ] 圧縮レベル (3: 1/8)
param.SetErrorRange( 1 ); // [ ] 誤差範囲 (画素)
param.SetScoreThresholdL( 50 ); // [ ] 低圧縮処理時のスコア閾値.
param.SetScoreThresholdH( 50 ); // [ ] 高圧縮処理時のスコア閾値.
// 3-4) (FPM2) 特徴量
// (ソーベル) 特徴量抽出用パラメータ生成
edge_param.SetEdgeThreshold( 120 ); // [ ] エッジ強度値に対する閾値.
edge_param.SetNmsLength( 3 ); // [ ] 非極大抑制処理のフィルタ片幅.
// 3-4-1) (FPM2) 特徴量(テンプレート) 生成
templ.Create(pattern, FVCL::FPM2::MatchMode::Normal, edge_param);
// 3-4-2) (FPM2) 特徴量(処理対象画像) 生成
target.Create(src, FVCL::FPM2::MatchMode::Normal, edge_param, false);
// 4) 画像処理準備.
// 4-1) 処理対象オブジェクトの設定.
matching.SetParam( param ); // 3-1 基本パラメータ.
matching.SetTarget( &target ); // 3-4-1 特徴量(処理対象画像)
matching.SetTemplate( &templ ); // 3-4-2 特徴量(テンプレート)
matching.SetEnableAreaScore( false ); // [ ] 領域スコア算出 (false:行わない)
matching.SetEnableEssential( false ); // [ ] 不可欠領域スコア計算 (false:行わない)
// 5) 画像処理実行.
timer.Start();
if (!matching.Execute())
{
_tprintf(_T("Failed to execute. code=%d\n"), matching.GetErrorCode());
}
msec = timer.Stop();
_tprintf(_T("execute. %f msec, count=%d \n"), msec, matching.GetResultSize());
// 確認用) パタンのエッジ点
{
_tprintf(_T("pattern edges=%d \n"), edges_pattern.size());
}
// 確認用) 処理対象画像のエッジ点
{
_tprintf(_T("image edges=%d \n"), edges_image.size());
}
// 圧縮特徴量の取得 (マスターパタンの特徴量)
{
int status = FVCL::FPM2::GetCompressedTemplateEdges(templ, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedTemplateEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedTemplateEdges: edges = %d\n"), edges.GetCount());
}
// 圧縮特徴量の取得 (最後にマッチングに使用した特徴量)
{
int status = FVCL::FPM2::GetCompressedMatchingEdges(templ, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedMatchingEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedMatchingEdges: edges = %d\n"), edges.GetCount());
}
// 圧縮特徴量の取得 (マッチング対象の特徴量オブジェクト)
{
int status = FVCL::FPM2::GetCompressedFeatureEdges(templ, target, &edges);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetCompressedFeatureEdges failed. (%d)\n"), status);
_tprintf(_T("GetCompressedFeatureEdges: edges = %d\n"), edges.GetCount());
}
}
出力結果)
User::SampleCode::FPM2::GetCompressedEdges
execute. 4.448200 msec, count=3 
pattern edges=396 
image edges=1888 
GetCompressedTemplateEdges: edges = 51
GetCompressedMatchingEdges: edges = 301
GetCompressedFeatureEdges: edges = 301
FVCL::FPM2::SetTemplateEdgelessMask ( FVCL::FPM2::CFvFPM2Template templ,
const FVCL::Data::CFvImage mask 
)

エッジ減点領域情報の設定

マスターパタンに対するエッジ減点領域情報を設定します。

引数
[in]templ特徴量オブジェクト (テンプレート)
[in]maskエッジ減点領域情報を指定する画像オブジェクト (type:bin, uc8 / ch: 1)
画像のサイズはマスターパタンのサイズと合わせてください。
画素の設定値は以下の通りです。
  • 1: エッジ減点領域に指定します。
  • 0: エッジ減点領域に指定しません。
これら以外の値が設定されていた場合には INVALID_OBJECT が戻ります。
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT 特徴量オブジェクトが異常です。
FIE:
fnFIE_fpm_set_pattern_edgeless_mask
参照
GetTemplateEdgelessMask
MatchingRecalcWithEdgelessMask
FVCL::FPM2::GetTemplateEdgelessMask ( const FVCL::FPM2::CFvFPM2Template templ,
FVCL::Data::CFvImage mask 
)

エッジ減点領域情報の取得

マスターパタンのエッジ減点領域情報を取得します。

引数
[in]templ特徴量オブジェクト (テンプレート)
[out]mask取得したエッジ減点領域情報を格納する画像オブジェクト
※ 内部で再確保されます。
  • サイズ: マスターパタンと同一
  • 画像種別:UC8
  • チャネル数:1
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT 特徴量オブジェクトが異常です。
FIE:
fnFIE_fpm_get_pattern_edgeless_mask
参照
SetTemplateEdgelessMask
MatchingRecalcWithEdgelessMask
FVCL::FPM2::MatchingRecalcWithEdgelessMask ( const FVCL::FPM2::CFvFPM2Template templ,
const FVCL::FPM2::CFvFPM2Feature target,
INT  err_wide,
DOUBLE  noise_weight,
INT  threshold,
INT  required_num,
CFvFPM2Result result 
)

特定領域エッジ減点スコア計算

指定されたエッジ減点領域情報を使用して特定領域エッジ減点スコアを計算します。

引数
[in]templ特徴オブジェクト (テンプレート)
[in]target特徴オブジェクト (マッチング対象)
[in]err_wide対応点誤差範囲 [0~]
[in]noise_weightエッジ減点重み係数 [0~]
※ エッジ減点領域内の 1 つのエッジに対する減点値の重みを表します。
[in]thresholdスコアしきい値 [0~100]
[in]required_num結果取得数 [1~]
[out]resultマッチング結果
戻り値
正常に終了した場合は FVCL_ErrorCode::_SUCCESS (0) を返します。
異常が有れば以下のエラーコードを返します。
エラーコード:
定数 内容
51 FVCL_ErrorCode::LICENSE_ERROR ライセンスエラー
1 FVCL_ErrorCode::FAILED_TO_ALLOCATE メモリが不足しています。
11 FVCL_ErrorCode::INVALID_PARAMETER パラメータが不正です。
12 FVCL_ErrorCode::INVALID_OBJECT 特徴量オブジェクトが異常です。
FIE:
fnFIE_fpm_matching_recalc_with_edgeless_mask
サンプルコード:
ソースコード:
{
_tprintf(_T("%s\n"), __TFUNCTION__);
double msec;
// 1) インスタンスの準備.
// 2-1) 処理対象画像の取り込み.
src.Load( _T(".\\key_UC8_M.png") );
// 2-2) パタン画像の読み込み.
pattern.Load( _T(".\\key1.pat") );
// 2-3) マスク画像の読み込み.
mask.Load( _T(".\\key-pattern-mask.png") );
// 3) パラメータ準備.
// ※パラメータを既定値から変更した部分は、コメントに [*] を記述しています.
//
// 3-1) (FPM2) 基本パラメータ設定
FVCL::FPM2::CFvFPM2Param param = matching.GetParam();
param.SetCount( 10 ); // [*] 検索個数.
param.SetAngleMin( FVCL::Data::CFvAngle(-180) ); // [ ] 回転角(下限)
param.SetAngleMax( FVCL::Data::CFvAngle(180) ); // [ ] 回転角(上限)
param.SetScaleMin( 100 ); // [ ] スケール(下限) (%)
param.SetScaleMax( 100 ); // [ ] スケール(上限) (%)
param.SetCompressionLevel( 3 ); // [ ] 圧縮レベル (3: 1/8)
param.SetErrorRange( 1 ); // [ ] 誤差範囲 (画素)
param.SetScoreThresholdL( 50 ); // [ ] 低圧縮処理時のスコア閾値.
param.SetScoreThresholdH( 50 ); // [ ] 高圧縮処理時のスコア閾値.
// 3-4) (FPM2) 特徴量
// (ソーベル) 特徴量抽出用パラメータ生成
edge_param.SetEdgeThreshold( 120 ); // [ ] エッジ強度値に対する閾値.
edge_param.SetNmsLength( 3 ); // [ ] 非極大抑制処理のフィルタ片幅.
// 3-4-1) (FPM2) 特徴量(テンプレート) 生成
templ.Create(pattern, FVCL::FPM2::MatchMode::Normal, edge_param);
// 3-4-2) (FPM2) 特徴量(処理対象画像) 生成
target.Create(src, FVCL::FPM2::MatchMode::Normal, edge_param, false);
// 4) 画像処理準備.
// 4-1) 処理対象オブジェクトの設定.
matching.SetParam( param ); // 3-1 基本パラメータ.
matching.SetTarget( &target ); // 3-4-1 特徴量(処理対象画像)
matching.SetTemplate( &templ ); // 3-4-2 特徴量(テンプレート)
matching.SetEnableAreaScore( false ); // [ ] 領域スコア算出 (false:行わない)
matching.SetEnableEssential(false); // [ ] 不可欠領域スコア計算 (false:行わない)
// 5) 画像処理実行.
{
timer.Start();
if (!matching.Execute())
{
_tprintf(_T("Failed to execute. code=%d\n"), matching.GetErrorCode());
}
msec = timer.Stop();
_tprintf(_T("execute. %f msec, count=%d \n"), msec, matching.GetResultSize());
for (int i = 0; i <(int)matching.GetResultSize(); i++)
{
FVCL::FPM2::CFvFPM2Data data = matching[i];
F_SEARCH_RESULT item = data.ToF_SEARCH_RESULT();
_tprintf(_T("%d: x,y=%.1f,%.1f score=%d s=%.1f q=%.1f\n"), i, item.x, item.y, item.score, item.s, item.q);
}
}
// 6-1) エッジ減点領域情報の設定.
// 6-2) エッジ減点領域情報の取得.
{
FVCL::Data::CFvImage edgeless_mask;
int status = FVCL::FPM2::GetTemplateEdgelessMask(templ, &edgeless_mask);
if (status != FVCL_ErrorCode::_SUCCESS)
_tprintf(_T("GetTemplateEdgelessMask failed. (%d)\n"), status);
else
{
bool ans = edgeless_mask.Compare(mask, 0.0, 1);
_tprintf(_T("GetTemplateEdgelessMask %s\n"), (ans) ? "OK" : "NG");
}
}
// 6-3) 特定領域エッジ減点スコア計算.
{
FVCL::FPM2::CFvFPM2Result edgeless_result;
timer.Start();
int err_wide = 0;
double noise_weight = 0.0;
int threshold = 60;
int required_num = 10;
FVCL::FPM2::MatchingRecalcWithEdgelessMask(templ, target, err_wide, noise_weight, threshold, required_num, &edgeless_result);
msec = timer.Stop();
_tprintf(_T("MatchingRecalcWithEdgelessMask. %f msec, count=%d \n"), msec, edgeless_result.GetCount());
for (int i = 0; i <(int)edgeless_result.GetCount(); i++)
{
F_SEARCH_RESULT item = edgeless_result[i];
_tprintf(_T("%d: x,y=%.1f,%.1f score=%d s=%.1f q=%.1f\n"), i, item.x, item.y, item.score, item.s, item.q);
}
}
}
出力結果)
User::SampleCode::FPM2::MatchingRecalcWithEdgelessMask
execute. 4.201200 msec, count=3 
0: x,y=178.0,156.0 score=100 s=100.0 q=0.0
1: x,y=249.1,137.9 score=81 s=100.0 q=26.3
2: x,y=18.3,55.4 score=79 s=100.0 q=139.1
GetTemplateEdgelessMask OK
MatchingRecalcWithEdgelessMask. 0.823600 msec, count=3 
0: x,y=178.0,156.0 score=100 s=100.0 q=0.0
1: x,y=249.1,137.9 score=75 s=100.0 q=26.3
2: x,y=18.3,55.4 score=60 s=100.0 q=139.1
参照
SetTemplateEdgelessMask
GetTemplateEdgelessMask

Documentation copyright © 2007 FAST Corporation. [B-001864]
Generated on 2023年11月02日(木) 10時12分56秒 for WIL説明書(C++) by doxygen 1.8.11