-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathVideo5.cs
78 lines (56 loc) · 2.41 KB
/
Video5.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using Emgu.CV;
using Emgu.CV.Structure;
namespace ourNamespace
{
class Video5
{
/*static void Main(string[] args)
{
var vc = new VideoCapture(0, VideoCapture.API.DShow);
Mat frame = new();
bool pause = false;
Mat myface = new();
Mat templateOutput = new();
Mat frameGray = new();
myface = CvInvoke.Imread("./img/myface.jpg");
CvInvoke.CvtColor(myface, myface, Emgu.CV.CvEnum.ColorConversion.Bgr2Gray);
while(!pause)
{
vc.Read(frame);
/*CvInvoke.CvtColor(frame, frameGray, Emgu.CV.CvEnum.ColorConversion.Bgr2Gray);
CvInvoke.MatchTemplate(frameGray, myface, templateOutput, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed);
CvInvoke.Threshold(templateOutput, templateOutput, 0.85, 1, Emgu.CV.CvEnum.ThresholdType.ToZero);
var matches = templateOutput.ToImage<Gray, byte>();
for (int i = 0; i < matches.Rows; i++)
{
for (int j = 0; j < matches.Cols; j++)
{
if (matches[i, j].Intensity > .8) {
System.Drawing.Point loc = new System.Drawing.Point(j, i);
System.Drawing.Rectangle box = new System.Drawing.Rectangle(loc, myface.Size);
CvInvoke.Rectangle(frame, box, new Emgu.CV.Structure.MCvScalar(0, 255, 0), 2);
}
}
}
Image<Bgr, byte> convertFrame = frame.ToImage<Bgr, byte>();
var image = convertFrame.InRange(new Bgr(75, 0, 0), new Bgr(255, 190, 190));
for (int i = 0; i < image.Rows; i++)
{
for (int j = 0; j < image.Cols; j++)
{
var intensity = image[i, j];
if (intensity.Intensity > 0)
{
convertFrame[i, j] = new Bgr(convertFrame[i,j].MCvScalar.V0 - 50, convertFrame[i,j].MCvScalar.V1 - 50, convertFrame[i,j].MCvScalar.V2 + 100);
}
}
}
CvInvoke.Imshow("video", convertFrame);
int keypressed = CvInvoke.WaitKey(1);
if (keypressed == 27)
pause = true;
}
}*/
}
}