-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
80 lines (71 loc) · 2.28 KB
/
Program.cs
File metadata and controls
80 lines (71 loc) · 2.28 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using System.Drawing;
using System.Runtime.InteropServices;
namespace cv
{
public class SMat : Mat
{
protected long sizeInBytes;
public void updateMemoryPressure()
{
var newSizeInBytes = Step * Rows;
if (newSizeInBytes > sizeInBytes)
{
GC.AddMemoryPressure(newSizeInBytes - sizeInBytes);
}
else if (newSizeInBytes < sizeInBytes)
{
GC.RemoveMemoryPressure(sizeInBytes - newSizeInBytes);
}
sizeInBytes = newSizeInBytes;
}
public SMat(int rows, int cols, DepthType type, int channels) : base(rows, cols, type, channels)
{
sizeInBytes = Step * Rows;
GC.AddMemoryPressure(sizeInBytes);
}
protected override void DisposeObject()
{
base.DisposeObject();
if (_ptr == IntPtr.Zero)
{
GC.RemoveMemoryPressure(sizeInBytes);
}
}
}
}
namespace emgu_ex1
{
class Program
{
static void Main(string[] args)
{
//print_line("Hello, PInvoke!");
//Create a 3 channel image of 400x200
using (var img = new cv.SMat(400, 400, DepthType.Cv8U, 3))
{
img.SetTo(new Bgr(255, 0, 0).MCvScalar); // set it to Blue color
img.updateMemoryPressure();
//var ptr = img.DataPointer;
set_color(img);
////Draw "Hello, world." on the image using the specific font
//CvInvoke.PutText(
// img,
// "Hello, world",
// new System.Drawing.Point(10, 80),
// FontFace.HersheyComplex,
// 1.0,
// new Bgr(0, 255, 0).MCvScalar);
////Show the image using ImageViewer from Emgu.CV.UI
//ImageViewer.Show(img, "Test Window");
}
Console.WriteLine("here");
}
[DllImport("nativelib.dll")]
private static extern void set_color(IntPtr data);
}
}