REGION境界点抽出

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

Syntax

C#
public static int fnFIE_region_calc_boundary(
	FHANDLE hreg,
	ref PNT_T_PTR pnts,
	ref uint pnum
)
Visual Basic
Public Shared Function fnFIE_region_calc_boundary ( 
	hreg As FHANDLE,
	ByRef pnts As PNT_T_PTR,
	ByRef pnum As UInteger
) As Integer

Parameters

hreg
Type: fvalgcli..::..FHANDLE
REGIONハンドル
pnts
Type: fvalgcli..::..PNT_T_PTR%
出力点列の先頭ポインタを格納するアドレス。(IntPtr.Zero で初期化してください。)
pnum
Type: System..::..UInt32%
出力点列の点の数

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_NOMEMORYメモリ不足
F_ERR_INVALID_OBJECT不正なハンドル
F_ERR_INVALID_PARAMパラメータ異常
  • パラメータに IntPtr.Zero が渡された。
  • pnts が IntPtr.Zero でない
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Remarks

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

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

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFIE_region_calc_boundary()
        {
            FHANDLE hreg = FHANDLE.Zero;
            FHANDLE himage = FHANDLE.Zero;
            FHANDLE himaged = FHANDLE.Zero;
            PNT_T_PTR pnts = PNT_T_PTR.Zero;

            try
            {
                // 2値画像を読み込む.
                api.fnFIE_load_img_file(TestImageDir + "/TC/SampleCode/blob_BIN.png", ref himage, f_color_img_type.F_COLOR_IMG_TYPE_UC8);
                Assert.IsTrue(himage != FHANDLE.Zero, "himage が異常です.");

                int width = api.fnFIE_img_get_width(himage);
                int height = api.fnFIE_img_get_height(himage);
                int type = api.fnFIE_img_get_type(himage);
                int channels = api.fnFIE_img_get_channels(himage);
                himaged = api.fnFIE_img_root_alloc(type, channels, width, height);

                // 画像からリージョンを作成する.
                // --- オフセット.
                PNT_T offset = new PNT_T();
                offset.x = 0;
                offset.y = 0;
                // --- 作成.
                hreg = api.fnFIE_region_encode(himage, offset);

                // リージョンオブジェクトの連結性設定.
                int connection = 4;
                int iCon = api.fnFIE_region_set_connection(hreg, connection);
                Assert.IsTrue(iCon == (int)f_err.F_ERR_NONE, "set_connectionでエラーが発生しました。({0})", (f_err)iCon);

                // --- リージョンの演算(リージョン境界点抽出)
                uint pnum = 0;
                int status = api.fnFIE_region_calc_boundary(hreg, ref pnts, ref pnum);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "calc_boundaryでエラーが発生しました。({0})", (f_err)status);

                // 値の確認.
                Console.WriteLine("pnum={0}", pnum);
                {
                    for (int i = 0; i < pnum; i++)
                    {
                        Console.WriteLine("_pnts[{0}]={1},{2}", i, pnts[i].x, pnts[i].y);
                    }
                }
            }
            finally
            {
                hreg.Dispose();
                himage.Dispose();
                himaged.Dispose();
                pnts.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_region_calc_boundary()
        Dim hreg As FHANDLE = FHANDLE.Zero
        Dim himage As FHANDLE = FHANDLE.Zero
        Dim himaged As FHANDLE = FHANDLE.Zero
        Dim pnts As PNT_T_PTR = PNT_T_PTR.Zero

        Try
            ' 2値画像を読み込む.
            api.fnFIE_load_img_file(TestImageDir & "/TC/SampleCode/blob_BIN.png", himage, f_color_img_type.F_COLOR_IMG_TYPE_UC8)
            Assert.IsTrue(himage <> FHANDLE.Zero, "himage が異常です.")

            Dim width As Integer = api.fnFIE_img_get_width(himage)
            Dim height As Integer = api.fnFIE_img_get_height(himage)
            Dim type As Integer = api.fnFIE_img_get_type(himage)
            Dim channels As Integer = api.fnFIE_img_get_channels(himage)
            himaged = api.fnFIE_img_root_alloc(type, channels, width, height)

            ' 画像からリージョンを作成する.
            ' --- オフセット.
            Dim offset As New PNT_T()
            offset.x = 0
            offset.y = 0
            ' --- 作成.
            hreg = api.fnFIE_region_encode(himage, offset)

            ' リージョンオブジェクトの連結性設定.
            Dim connection As Integer = 4
            Dim iCon As Integer = api.fnFIE_region_set_connection(hreg, connection)
            Assert.IsTrue(iCon = CInt(f_err.F_ERR_NONE), "set_connectionでエラーが発生しました。({0})", CType(iCon, f_err))

            ' --- リージョンの演算(リージョン境界点抽出)
            Dim pnum As UInteger = 0
            Dim status As Integer = api.fnFIE_region_calc_boundary(hreg, pnts, pnum)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "calc_boundaryでエラーが発生しました。({0})", CType(status, f_err))

            ' 値の確認.
            Console.WriteLine("pnum={0}", pnum)
            If True Then
                For i As Integer = 0 To CType(pnum, Integer) - 1
                    Console.WriteLine("_pnts[{0}]={1},{2}", i, pnts(i).x, pnts(i).y)
                Next
            End If
        Finally
            hreg.Dispose()
            himage.Dispose()
            himaged.Dispose()
            pnts.Dispose()
        End Try
    End Sub
End Class

See Also