中点座標の算出(1点と直線)
Namespace: FVIL.CaliperAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
public static CFviPoint CenterPoint(
CFviPoint point,
CFviLine line
) |
Visual Basic |
---|
Public Shared Function CenterPoint (
point As CFviPoint,
line As CFviLine
) As CFviPoint |
Return Value
Type:
CFviPoint
1点と直線の中点座標を算出します。
正常に実行できなかった場合は例外を発行します。
例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。
エラーコード:
値 | ErrorCode メンバ | 内容 |
---|
51 | FVIL.ErrorCode.LICENSE_ERROR |
ライセンスキーが見つからない為、実行できません。
または、 FVIL._SetUp.InitVisionLibrary が実行されていません。
|
11 | FVIL.ErrorCode.INVALID_PARAMETER | パラメータに誤りがあります。 |
29 | FVIL.ErrorCode.NOT_CALCULABLE | 計算不可能です。 |
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_line()
{
FVIL.Data.CFviLine line = new FVIL.Data.CFviLine(0.5, 1, -180);
FVIL.Data.CFviPoint point1 = new FVIL.Data.CFviPoint(100, 60);
FVIL.Data.CFviPoint point = FVIL.Caliper.Function.CenterPoint(point1, line);
{
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.GDI.CFviGdiLine gline1 = new FVIL.GDI.CFviGdiLine(line);
gline1.Pen.Color = Color.Green;
gline1.Pen.Width = 1;
gline1.Pen.Style = FVIL.GDI.PenStyle.Solid;
FVIL.Data.CFviPoint point2 = FVIL.Caliper.Function.CrossPoint(line, FVIL.Caliper.Function.VerticalLine(point, line));
FVIL.Data.CFviLineSegment horz = new FVIL.Data.CFviLineSegment(point1, point2);
FVIL.GDI.CFviGdiLineSegment gline2 = new FVIL.GDI.CFviGdiLineSegment(horz);
gline2.Pen.Color = Color.Green;
gline2.Pen.Width = 1;
gline2.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(point);
gpoint2.Pen.Color = Color.Red;
gpoint2.Pen.Width = 4;
overlay.Figures.Add(gline1);
overlay.Figures.Add(gline2);
overlay.Figures.Add(gpoint1);
overlay.Figures.Add(gpoint2);
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_line.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_line()
Dim line As New FVIL.Data.CFviLine(0.5, 1, -180)
Dim point1 As New FVIL.Data.CFviPoint(100, 60)
Dim point As FVIL.Data.CFviPoint = FVIL.Caliper.[Function].CenterPoint(point1, line)
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 gline1 As New FVIL.GDI.CFviGdiLine(line)
gline1.Pen.Color = Color.Green
gline1.Pen.Width = 1
gline1.Pen.Style = FVIL.GDI.PenStyle.Solid
Dim point2 As FVIL.Data.CFviPoint = FVIL.Caliper.[Function].CrossPoint(line, FVIL.Caliper.[Function].VerticalLine(point, line))
Dim horz As New FVIL.Data.CFviLineSegment(point1, point2)
Dim gline2 As New FVIL.GDI.CFviGdiLineSegment(horz)
gline2.Pen.Color = Color.Green
gline2.Pen.Width = 1
gline2.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(point)
gpoint2.Pen.Color = Color.Red
gpoint2.Pen.Width = 4
overlay.Figures.Add(gline1)
overlay.Figures.Add(gline2)
overlay.Figures.Add(gpoint1)
overlay.Figures.Add(gpoint2)
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_line.png", dstimage)
End If
End Sub
End Class
End Namespace |
Exceptions
See Also