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_bounding_rotated_rect_pos(
	FHANDLE hreg,
	double theta,
	DPNT_T_PTR points
)
Visual Basic
Public Shared Function fnFIE_region_calc_bounding_rotated_rect_pos ( 
	hreg As FHANDLE,
	theta As Double,
	points As DPNT_T_PTR
) As Integer

Parameters

hreg
Type: fvalgcli..::..FHANDLE
REGIONハンドル
theta
Type: System..::..Double
外接長方形の角度(外接長方形のある一辺とx軸がなす角度)単位:ラジアン
points
Type: fvalgcli..::..DPNT_T_PTR
外接長方形の4頂点の点列の出力先配列。要素数 4 の配列を予め確保してください。

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_OBJECT不正なハンドル
F_ERR_CALC_IMPOSSIBLE計算不能
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Examples

C# Copy imageCopy
using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFIE_region_calc_bounding_rotated_rect_pos()
        {
            var himage = FHANDLE.Zero;
            var hreg = FHANDLE.Zero;
            var points = DPNT_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 が異常です.");

                // 画像からリージョンを作成する.
                var offset = PNT_T.init(0, 0);
                hreg = api.fnFIE_region_encode(himage, offset);
                Assert.IsTrue(hreg != FHANDLE.Zero, "hreg が異常です.");

                // 外接長方形の4頂点の点列の出力先の配列.
                points = DPNT_T_PTR.alloc(4);
                Assert.IsTrue(points != DPNT_T_PTR.Zero, "points が異常です.");

                // リージョン特徴量:外接長方形の頂点.
                double theta = 90 * defs.PI / 180;
                int status = api.fnFIE_region_calc_bounding_rotated_rect_pos(hreg, theta, points);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_region_calc_bounding_rotated_rect_pos でエラーが発生しました。({0})", (f_err)status);

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


Visual Basic Copy imageCopy
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_region_calc_bounding_rotated_rect_pos()
        Dim himage As FHANDLE = FHANDLE.Zero
        Dim hreg As FHANDLE = FHANDLE.Zero
        Dim points As DPNT_T_PTR = DPNT_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 offset As PNT_T = PNT_T.init(0, 0)
            hreg = api.fnFIE_region_encode(himage, offset)
            Assert.IsTrue(hreg <> FHANDLE.Zero, "hreg が異常です.")

            ' 外接長方形の4頂点の点列の出力先の配列.
            points = DPNT_T_PTR.alloc(4)
            Assert.IsTrue(points <> DPNT_T_PTR.Zero, "points が異常です.")

            ' リージョン特徴量:外接長方形の頂点.
            Dim theta As Double = 90 * defs.PI / 180
            Dim status As Integer = api.fnFIE_region_calc_bounding_rotated_rect_pos(hreg, theta, points)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_region_calc_bounding_rotated_rect_pos でエラーが発生しました。({0})", CType(status, f_err))

            ' 値の確認.
            Console.WriteLine("fnFIE_region_calc_bounding_rotated_rect_pos")
            For i As Integer = 0 To 3
                Console.WriteLine("points[{0}]={1},{2}", i, points(i).x, points(i).y)
            Next
        Finally
            himage.Dispose()
            hreg.Dispose()
            points.Dispose()
        End Try
    End Sub
End Class

See Also