中点座標の算出(2点)

Namespace: FVIL.Caliper
Assembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)

Syntax

C#
public static CFviPoint CenterPoint(
	CFviPoint point1,
	CFviPoint point2
)
Visual Basic
Public Shared Function CenterPoint ( 
	point1 As CFviPoint,
	point2 As CFviPoint
) As CFviPoint

Parameters

point1
Type: FVIL.Data..::..CFviPoint
座標1
point2
Type: FVIL.Data..::..CFviPoint
座標2

Return Value

Type: CFviPoint
2点の中点座標を算出して返します。

正常に実行できなかった場合は例外を発行します。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。

エラーコード:

ErrorCode メンバ内容
51FVIL.ErrorCode.LICENSE_ERROR ライセンスキーが見つからない為、実行できません。 または、 FVIL._SetUp.InitVisionLibrary が実行されていません。
11FVIL.ErrorCode.INVALID_PARAMETERパラメータに誤りがあります。

Examples

C# Copy imageCopy
//    $Revision: 1.3 $

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using fvalgcli;    // FvPluginXXXX attribute requires fvalgcli

namespace User.SampleCode
{
    public partial class Caliper
    {
        /// <summary>
        /// 中点座標の算出(2点)の測定.
        /// </summary>
        /// <remarks>
        /// FVIL.Caliper.Function.CenterPoint(FVIL.Data.CFviPoint,FVIL.Data.CFviPoint)
        /// </remarks>
        [FvPluginExecute]
        public void CenterPoint_point_point()
        {
            // 1) 2点の生成.
            FVIL.Data.CFviPoint point1 = new FVIL.Data.CFviPoint(240, 60);
            FVIL.Data.CFviPoint point2 = new FVIL.Data.CFviPoint(80, 140);

            // 2) 計測実行.
            FVIL.Data.CFviPoint point = FVIL.Caliper.Function.CenterPoint(point1, point2);

            // 確認用.
            {
                // 画像、描画表示クラス、オーバーレイのインスタンスの生成.
                FVIL.Data.CFviImage image = new FVIL.Data.CFviImage(320, 240, FVIL.ImageType.UC8, 1);
                FVIL.GDI.CFviDisplay display = new FVIL.GDI.CFviDisplay();
                FVIL.GDI.CFviOverlay overlay = new FVIL.GDI.CFviOverlay();

                {
                    // 描画図形の生成.
                    // 補助線.
                    FVIL.Data.CFviLineSegment line = new FVIL.Data.CFviLineSegment(point1, point2);
                    FVIL.GDI.CFviGdiLineSegment gline1 = new FVIL.GDI.CFviGdiLineSegment(line);
                    gline1.Pen.Color = Color.Green;
                    gline1.Pen.Width = 1;
                    gline1.Pen.Style = FVIL.GDI.PenStyle.Dot;

                    // 入力点1
                    FVIL.GDI.CFviGdiPoint gpoint1 = new FVIL.GDI.CFviGdiPoint(point1);
                    gpoint1.Pen.Color = Color.Green;
                    gpoint1.Pen.Width = 4;

                    // 入力点2
                    FVIL.GDI.CFviGdiPoint gpoint2 = new FVIL.GDI.CFviGdiPoint(point2);
                    gpoint2.Pen.Color = Color.Green;
                    gpoint2.Pen.Width = 4;

                    // 結果点.
                    FVIL.GDI.CFviGdiPoint gpoint3 = new FVIL.GDI.CFviGdiPoint(point);
                    gpoint3.Pen.Color = Color.Red;
                    gpoint3.Pen.Width = 4;

                    // 描画図形の追加.
                    overlay.Figures.Add(gline1);
                    overlay.Figures.Add(gpoint1);
                    overlay.Figures.Add(gpoint2);
                    overlay.Figures.Add(gpoint3);
                    overlay.Enable = true;
                }

                // 画像表示クラスへの追加.
                display.Overlays.Add(overlay);
                display.Image = image;
                display.DisplayRect = image.Window;

                // 描画イメージの保存.
                FVIL.Data.CFviImage dstimage = new FVIL.Data.CFviImage();
                display.SaveImage(dstimage);
                FVIL.File.Function.SaveImageFile(Defs.ResultDir + "/Caliper.CenterPoint_point_point.png", dstimage);
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports System.Drawing
Imports fvalgcli
' FvPluginXXXX attribute requires fvalgcli
Namespace SampleCode
    Public Partial Class Caliper
        ''' <summary>
        ''' 中点座標の算出(2点)の測定.
        ''' </summary>
        ''' <remarks>
        ''' FVIL.Caliper.Function.CenterPoint(FVIL.Data.CFviPoint,FVIL.Data.CFviPoint)
        ''' </remarks>
        <FvPluginExecute> _
        Public Sub CenterPoint_point_point()
            ' 1) 2点の生成.
            Dim point1 As New FVIL.Data.CFviPoint(240, 60)
            Dim point2 As New FVIL.Data.CFviPoint(80, 140)

            ' 2) 計測実行.
            Dim point As FVIL.Data.CFviPoint = FVIL.Caliper.[Function].CenterPoint(point1, point2)

            ' 確認用.
            If True Then
                ' 画像、描画表示クラス、オーバーレイのインスタンスの生成.
                Dim image As New FVIL.Data.CFviImage(320, 240, FVIL.ImageType.UC8, 1)
                Dim display As New FVIL.GDI.CFviDisplay()
                Dim overlay As New FVIL.GDI.CFviOverlay()

                If True Then
                    ' 描画図形の生成.
                    ' 補助線.
                    Dim line As New FVIL.Data.CFviLineSegment(point1, point2)
                    Dim gline1 As New FVIL.GDI.CFviGdiLineSegment(line)
                    gline1.Pen.Color = Color.Green
                    gline1.Pen.Width = 1
                    gline1.Pen.Style = FVIL.GDI.PenStyle.Dot

                    ' 入力点1
                    Dim gpoint1 As New FVIL.GDI.CFviGdiPoint(point1)
                    gpoint1.Pen.Color = Color.Green
                    gpoint1.Pen.Width = 4

                    ' 入力点2
                    Dim gpoint2 As New FVIL.GDI.CFviGdiPoint(point2)
                    gpoint2.Pen.Color = Color.Green
                    gpoint2.Pen.Width = 4

                    ' 結果点.
                    Dim gpoint3 As New FVIL.GDI.CFviGdiPoint(point)
                    gpoint3.Pen.Color = Color.Red
                    gpoint3.Pen.Width = 4

                    ' 描画図形の追加.
                    overlay.Figures.Add(gline1)
                    overlay.Figures.Add(gpoint1)
                    overlay.Figures.Add(gpoint2)
                    overlay.Figures.Add(gpoint3)
                    overlay.Enable = True
                End If

                ' 画像表示クラスへの追加.
                display.Overlays.Add(overlay)
                display.Image = image
                display.DisplayRect = image.Window

                ' 描画イメージの保存.
                Dim dstimage As New FVIL.Data.CFviImage()
                display.SaveImage(dstimage)
                FVIL.File.[Function].SaveImageFile(Defs.ResultDir & "/Caliper.CenterPoint_point_point.png", dstimage)
            End If
        End Sub
    End Class
End Namespace

Exceptions

ExceptionCondition
FVIL..::..CFviExceptionこの例外の原因については、上記のエラーコード表をご参照ください。

See Also