画像比較

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static int fnFIE_img_compare(
	FHANDLE hsrc1,
	FHANDLE hsrc2,
	ref bool result
)
Visual Basic
Public Shared Function fnFIE_img_compare ( 
	hsrc1 As FHANDLE,
	hsrc2 As FHANDLE,
	ByRef result As Boolean
) As Integer

Parameters

hsrc1
Type: fvalgcli..::..FHANDLE
入力画像ハンドル( type: bin, uc8, s16, us16, i32, ui32, i64, float, double, rgbq, rgbtri )
hsrc2
Type: fvalgcli..::..FHANDLE
入力画像ハンドル( type: bin, uc8, s16, us16, i32, ui32, i64, float, double, rgbq, rgbtri )
result
Type: System..::..Boolean%
比較結果
  • true: 画像が等しい
  • false: 画像が異なる

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_IMAGE画像オブジェクトの異常
F_ERR_INVALID_PARAMパラメータ異常
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Examples

C# Copy imageCopy
//    $Revision: 1.1 $
#define COMPARE_OK

using System;
using System.Collections.Generic;
using System.Text;

using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// 画像比較.
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_img_compare()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hsrc1 = FHANDLE.Zero;    // 入力画像ハンドル.
            FHANDLE hsrc2 = FHANDLE.Zero;    // 入力画像ハンドル.
            bool result = new bool();        // 比較結果.

            bool ans_result;

            try
            {
                // 入力画像1 の確保.
                api.fnFIE_load_bmp(TestImageDir + "/testdata/lena256.bmp", ref hsrc1, f_color_img_type.F_COLOR_IMG_TYPE_UC8);

                // 入力画像2 の確保.
                hsrc2 = api.fnFIE_img_root_alloc
                    (
                        api.fnFIE_img_get_type(hsrc1), 1,
                        api.fnFIE_img_get_width(hsrc1),
                        api.fnFIE_img_get_height(hsrc1)
                    );

#if COMPARE_OK
                // 2つの入力画像が等しい.
                api.fnFIE_img_copy(hsrc1, hsrc2);
                ans_result = true;
#else
            // 2つの入力画像が異なる.
            api.fnFIE_img_clear(hsrc2, 0);
            ans_result = false;
#endif



                // 処理の実行.
                status = api.fnFIE_img_compare(hsrc1, hsrc2, ref result);

                // エラー判定.
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);

                // 比較結果を出力する.
                ConsoleOut.WriteFunctionName(":\t");
                Console.Write("result = {0} ...", result);
                ConsoleOut.IsTrue(ans_result == result);
            }
            finally
            {
                // オブジェクトの開放.
                hsrc1.Dispose();
                hsrc2.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $
#Const COMPARE_OK = True

Imports System.Collections.Generic
Imports System.Text

Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' 画像比較.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_img_compare()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hsrc1 As FHANDLE = FHANDLE.Zero
        ' 入力画像ハンドル.
        Dim hsrc2 As FHANDLE = FHANDLE.Zero
        ' 入力画像ハンドル.
        Dim result As New Boolean()
        ' 比較結果.
        Dim ans_result As Boolean

        Try
            ' 入力画像1 の確保.
            api.fnFIE_load_bmp(TestImageDir & "/testdata/lena256.bmp", hsrc1, f_color_img_type.F_COLOR_IMG_TYPE_UC8)

            ' 入力画像2 の確保.
            hsrc2 = api.fnFIE_img_root_alloc(api.fnFIE_img_get_type(hsrc1), 1, api.fnFIE_img_get_width(hsrc1), api.fnFIE_img_get_height(hsrc1))

            #If COMPARE_OK Then
            ' 2つの入力画像が等しい.
            api.fnFIE_img_copy(hsrc1, hsrc2)
            ans_result = True
            #Else
            ' 2つの入力画像が異なる.
            api.fnFIE_img_clear(hsrc2, 0)
            ans_result = False
            #End If



            ' 処理の実行.
            status = api.fnFIE_img_compare(hsrc1, hsrc2, result)

            ' エラー判定.
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))

            ' 比較結果を出力する.
            ConsoleOut.WriteFunctionName(":" & vbTab)
            Console.Write("result = {0} ...", result)
            ConsoleOut.IsTrue(ans_result = result)
        Finally
            ' オブジェクトの開放.
            hsrc1.Dispose()
            hsrc2.Dispose()
        End Try
    End Sub
End Class

See Also