中点座標の算出(2点)
Namespace: FVIL.CaliperAssembly: 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 |
Return Value
Type:
CFviPoint
2点の中点座標を算出して返します。
正常に実行できなかった場合は例外を発行します。
例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。
エラーコード:
値 | ErrorCode メンバ | 内容 |
---|
51 | FVIL.ErrorCode.LICENSE_ERROR |
ライセンスキーが見つからない為、実行できません。
または、 FVIL._SetUp.InitVisionLibrary が実行されていません。
|
11 | FVIL.ErrorCode.INVALID_PARAMETER | パラメータに誤りがあります。 |
Examples
C# | Copy |
---|
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using fvalgcli;
namespace User.SampleCode
{
public partial class Caliper
{
[FvPluginExecute]
public void CenterPoint_point_point()
{
FVIL.Data.CFviPoint point1 = new FVIL.Data.CFviPoint(240, 60);
FVIL.Data.CFviPoint point2 = new FVIL.Data.CFviPoint(80, 140);
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;
FVIL.GDI.CFviGdiPoint gpoint1 = new FVIL.GDI.CFviGdiPoint(point1);
gpoint1.Pen.Color = Color.Green;
gpoint1.Pen.Width = 4;
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 |
---|
Imports System.Collections.Generic
Imports System.Text
Imports System.Drawing
Imports fvalgcli
Namespace SampleCode
Public Partial Class Caliper
<FvPluginExecute> _
Public Sub CenterPoint_point_point()
Dim point1 As New FVIL.Data.CFviPoint(240, 60)
Dim point2 As New FVIL.Data.CFviPoint(80, 140)
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
Dim gpoint1 As New FVIL.GDI.CFviGdiPoint(point1)
gpoint1.Pen.Color = Color.Green
gpoint1.Pen.Width = 4
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
See Also