/
Contour.cs
48 lines (44 loc) · 1.35 KB
/
Contour.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
using OpenCV.Net.Native;
namespace OpenCV.Net
{
/// <summary>
/// Represents a polygonal contour.
/// </summary>
public class Contour : Seq
{
/// <summary>
/// Gets the size of the <see cref="Contour"/> header, in bytes.
/// </summary>
public static new int HeaderSize
{
get { return SeqHelper.ContourHeaderSize; }
}
/// <summary>
/// Gets the bounding rectangle of the contour.
/// </summary>
public Rect Rect
{
get
{
unsafe
{
return ((_CvContour*)handle.ToPointer())->rect;
}
}
}
/// <summary>
/// Initializes a new <see cref="Contour"/> instance from a compatible
/// <see cref="Seq"/>.
/// </summary>
/// <param name="seq">A <see cref="Seq"/> instance representing a polygonal contour.</param>
/// <returns>A new <see cref="Contour"/> header for the specified <paramref name="seq"/>.</returns>
public static Contour FromSeq(Seq seq)
{
if (seq == null) return null;
var contour = new Contour();
contour.SetOwnerStorage(seq.Storage);
contour.SetHandle(seq.DangerousGetHandle());
return contour;
}
}
}