-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLeNetObservationForm.cs
More file actions
93 lines (78 loc) · 3.38 KB
/
LeNetObservationForm.cs
File metadata and controls
93 lines (78 loc) · 3.38 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
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AdvancedOCR
{
partial class LeNetObservationForm : Form
{
PictureBox[] firstConvolutions;
PictureBox[] firstSubsampling;
PictureBox[] secondConvolutions;
PictureBox[] secondSubsampling;
public LeNetObservationForm(LeNetSnapshot snapshot)
{
InitializeComponent();
this.Snapshot = snapshot;
firstConvolutions = CreateHorizontalPictureBoxes(28*3, snapshot.FirstConvolutions.Length);
firstConvolutionsContainer.Controls.AddRange(firstConvolutions);
firstSubsampling = CreateHorizontalPictureBoxes(28 * 3, snapshot.FirstSubsampling.Length);
firstSubsamplingContainer.Controls.AddRange(firstSubsampling);
secondConvolutions = CreateHorizontalPictureBoxes(28 * 3, snapshot.SecondConvolutions.Length);
secondConvolutionsContainer.Controls.AddRange(secondConvolutions);
secondSubsampling = CreateHorizontalPictureBoxes(28 * 3, snapshot.SecondSubsampling.Length);
secondSubsamplingContainer.Controls.AddRange(secondSubsampling);
inputPicture.Paint += inputPicture_Paint;
Snapshot.Updated += Snapshot_Updated;
Snapshot.RequestUpdate();
}
const int pictureBoxSpacing = 5;
private PictureBox[] CreateHorizontalPictureBoxes(int width, int number)
{
Size size = new Size(width + pictureBoxSpacing * 2, width + pictureBoxSpacing * 2);
PictureBox[] result = new PictureBox[number];
for (int i = 0; i < number; i++)
{
PictureBox box = new PictureBox();
box.Size = size;
box.SizeMode = PictureBoxSizeMode.StretchImage;
box.Padding = new Padding(pictureBoxSpacing);
result[i] = box;
}
return result;
}
void Snapshot_Updated(object sender, EventArgs e)
{
if (IsHandleCreated && !Disposing)
{
this.BeginInvoke(new Action(SnapshotUpdated));
}
}
private void SnapshotUpdated()
{
this.SuspendLayout();
for (int i = 0; i < firstConvolutions.Length; i++)
firstConvolutions[i].Image = Snapshot.FirstConvolutions[i].OutputBitmap;
for (int i = 0; i < firstSubsampling.Length; i++)
firstSubsampling[i].Image = Snapshot.FirstSubsampling[i].OutputBitmap;
for (int i = 0; i < secondConvolutions.Length; i++)
secondConvolutions[i].Image = Snapshot.SecondConvolutions[i].OutputBitmap;
for (int i = 0; i < secondSubsampling.Length; i++)
secondSubsampling[i].Image = Snapshot.SecondSubsampling[i].OutputBitmap;
consolidationPicture.Image = Snapshot.Consolidation.OutputBitmap;
outputPicture.Image = Snapshot.Output.OutputBitmap;
inputPicture.Image = Snapshot.Input.OutputBitmap;
this.ResumeLayout();
}
void inputPicture_Paint(object sender, PaintEventArgs e)
{
Snapshot.RequestUpdate();
}
public readonly LeNetSnapshot Snapshot;
}
}