-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathVideo2.cs
89 lines (58 loc) · 2.3 KB
/
Video2.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
79
80
81
82
83
84
85
86
87
88
89
using System;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
namespace MyNamespace
{
class Program
{
/*static void Main(string[] args)
{
Mat pic = CvInvoke.Imread("./img/starrynight.jpg");
Mat resizedPic = new Mat();
int height = pic.Rows;
int width = pic.Cols;
Console.WriteLine($"starry night is : {height} x {width}");
CvInvoke.Resize(pic, resizedPic, new System.Drawing.Size(400, 500));
CvInvoke.Imshow("starry night", pic);
CvInvoke.Imshow("resized night", resizedPic);
CvInvoke.WaitKey();
double angleFourtyFive = 45d;
System.Drawing.PointF center = new System.Drawing.PointF((width - 1) / 2.0f, (height - 1) / 2.0f);
Mat rotationMatrix = new Mat();
CvInvoke.GetRotationMatrix2D(center, angleFourtyFive, 1.0, rotationMatrix);
Mat rotatedPic = new Mat();
CvInvoke.WarpAffine(pic, rotatedPic, rotationMatrix, new System.Drawing.Size(width, height));
CvInvoke.Imshow("rotated night", rotatedPic);
CvInvoke.WaitKey();
Image<Bgr, byte> convertPic = pic.ToImage<Bgr, byte>();
var image = convertPic.InRange(new Bgr(75, 0, 0), new Bgr(255, 125, 125));
for (int i = 0; i < image.Rows; i++)
{
for (int j = 0; j < image.Cols; j++)
{
var num = image[i, j];
if (num.Intensity > 0)
{
convertPic[i, j] = new Bgr(convertPic[i,j].MCvScalar.V0 - 50, convertPic[i,j].MCvScalar.V1 - 50, convertPic[i,j].MCvScalar.V2 + 100);
}
}
}
Mat changedPic = convertPic.Mat;
CvInvoke.Imshow("starry night", pic);
CvInvoke.Imshow("color-shifted night", changedPic);
CvInvoke.WaitKey();
float[,] kernelArray = new float[3, 3] {
{ -1, -1, -1},
{ -1, 8, -1},
{ -1, -1, -1}
};
ConvolutionKernelF kernel = new ConvolutionKernelF(kernelArray);
Mat filteredPic = new Mat();
pic.CopyTo(filteredPic);
CvInvoke.Filter2D(pic, filteredPic, kernel, new System.Drawing.Point(0, 0));
CvInvoke.Imshow("convoluted night", filteredPic);
CvInvoke.WaitKey();
}*/
}
}