/
VP_Morphology.cs
63 lines (62 loc) · 1.9 KB
/
VP_Morphology.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenCvSharp;
using QGR.Utility;
namespace VisionProcessor
{
/// <summary>
/// method: MorphTypes
/// shape: MorphShapes
/// ksize: Size
/// anchor: Point
/// iterations: int
/// borderType: BorderTypes
/// </summary>
public class VP_Morphology:VisionTestCase
{
public MorphTypes method;
public MorphShapes shape;
public Size ksize;
public Point anchor;
public int iterations;
public BorderTypes borderType;
public VP_Morphology():base()
{
TestName = "morphology";
}
public override bool run()
{
try
{
method = (MorphTypes)getValue("method");
shape = (MorphShapes)getValue("shape");
ksize = (Size)getValue("ksize");
anchor = (Point)getValue("anchor");
iterations = (int)getValue("iterations");
borderType = (BorderTypes)getValue("borderType");
Mat element = Cv2.GetStructuringElement(shape, ksize);
switch (method)
{
case MorphTypes.Dilate:
dst = src.Dilate(element, anchor, iterations, borderType, null);
break;
case MorphTypes.Erode:
dst = src.Erode(element, anchor, iterations, borderType, null);
break;
default:
dst = src.MorphologyEx(method, element, anchor, iterations, borderType, null);
break;
}
TestName = method.ToString();
}
catch (Exception ex)
{
throw ex;
}
return true;
}
}
}