Vous êtes sur la page 1sur 17

Signal compare: Imports System.IO Imports System.IO.DirectoryInfo Public Class frmCompare Inherits System.Windows.Forms.Form Private dirinfo As IO.

DirectoryInfo Private dirinfo1 As IO.DirectoryInfo Private dir As String Private dir1 As String Private fil As IO.FileInfo Dim grph As System.Drawing.Bitmap Dim temp As String Public WithEvents Label3 As System.Windows.Forms.Label Dim st(8) As String #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call

End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Public WithEvents Frame1 As System.Windows.Forms.GroupBox Public WithEvents Picture1 As System.Windows.Forms.PictureBox Public WithEvents cmdCheck As System.Windows.Forms.Button Public WithEvents cmdMake As System.Windows.Forms.Button Public WithEvents cmdHome As System.Windows.Forms.Button Public WithEvents Frame2 As System.Windows.Forms.GroupBox Public WithEvents cmdBrowse As System.Windows.Forms.Button Friend WithEvents openFileDlg As System.Windows.Forms.OpenFileDialog Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmCompare)) Me.Frame1 = New System.Windows.Forms.GroupBox Me.Picture1 = New System.Windows.Forms.PictureBox Me.cmdCheck = New System.Windows.Forms.Button Me.cmdMake = New System.Windows.Forms.Button Me.cmdHome = New System.Windows.Forms.Button Me.Frame2 = New System.Windows.Forms.GroupBox Me.cmdBrowse = New System.Windows.Forms.Button Me.openFileDlg = New System.Windows.Forms.OpenFileDialog Me.PictureBox1 = New System.Windows.Forms.PictureBox Me.Label3 = New System.Windows.Forms.Label Me.Frame1.SuspendLayout() CType(Me.Picture1, System.ComponentModel.ISupportInitialize).BeginInit() Me.Frame2.SuspendLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Frame1 ' Me.Frame1.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.Frame1.Controls.Add(Me.Picture1)

Me.Frame1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Frame1.ForeColor = System.Drawing.Color.Red Me.Frame1.Location = New System.Drawing.Point(248, 160) Me.Frame1.Name = "Frame1" Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Frame1.Size = New System.Drawing.Size(304, 264) Me.Frame1.TabIndex = 11 Me.Frame1.TabStop = False Me.Frame1.Text = "Capture Area" ' 'Picture1 ' Me.Picture1.BackColor = System.Drawing.SystemColors.Window Me.Picture1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Picture1.Cursor = System.Windows.Forms.Cursors.Default Me.Picture1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Picture1.ForeColor = System.Drawing.SystemColors.WindowText Me.Picture1.Location = New System.Drawing.Point(16, 16) Me.Picture1.Name = "Picture1" Me.Picture1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Picture1.Size = New System.Drawing.Size(272, 232) Me.Picture1.TabIndex = 4 Me.Picture1.TabStop = False

' 'cmdCheck ' Me.cmdCheck.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.cmdCheck.Cursor = System.Windows.Forms.Cursors.Default Me.cmdCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.cmdCheck.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdCheck.ForeColor = System.Drawing.Color.Red Me.cmdCheck.Image = CType(resources.GetObject("cmdCheck.Image"), System.Drawing.Image) Me.cmdCheck.Location = New System.Drawing.Point(264, 16) Me.cmdCheck.Name = "cmdCheck" Me.cmdCheck.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdCheck.Size = New System.Drawing.Size(73, 49) Me.cmdCheck.TabIndex = 8 Me.cmdCheck.Text = "Check" Me.cmdCheck.TextAlign = System.Drawing.ContentAlignment.BottomCenter Me.cmdCheck.UseVisualStyleBackColor = False ' 'cmdMake ' Me.cmdMake.BackColor = System.Drawing.SystemColors.ActiveCaptionText

Me.cmdMake.Cursor = System.Windows.Forms.Cursors.Default Me.cmdMake.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.cmdMake.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdMake.ForeColor = System.Drawing.Color.Red Me.cmdMake.Image = CType(resources.GetObject("cmdMake.Image"), System.Drawing.Image) Me.cmdMake.Location = New System.Drawing.Point(179, 16) Me.cmdMake.Name = "cmdMake" Me.cmdMake.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdMake.Size = New System.Drawing.Size(73, 49) Me.cmdMake.TabIndex = 7 Me.cmdMake.Text = "Make" Me.cmdMake.TextAlign = System.Drawing.ContentAlignment.BottomCenter Me.cmdMake.UseVisualStyleBackColor = False ' 'cmdHome ' Me.cmdHome.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.cmdHome.Cursor = System.Windows.Forms.Cursors.Default Me.cmdHome.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.cmdHome.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdHome.ForeColor = System.Drawing.Color.Red

Me.cmdHome.Image = CType(resources.GetObject("cmdHome.Image"), System.Drawing.Image) Me.cmdHome.Location = New System.Drawing.Point(8, 16) Me.cmdHome.Name = "cmdHome" Me.cmdHome.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdHome.Size = New System.Drawing.Size(73, 49) Me.cmdHome.TabIndex = 6 Me.cmdHome.Text = "Home" Me.cmdHome.TextAlign = System.Drawing.ContentAlignment.BottomCenter Me.cmdHome.UseVisualStyleBackColor = False ' 'Frame2 ' Me.Frame2.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.Frame2.Controls.Add(Me.cmdBrowse) Me.Frame2.Controls.Add(Me.cmdCheck) Me.Frame2.Controls.Add(Me.cmdMake) Me.Frame2.Controls.Add(Me.cmdHome) Me.Frame2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText Me.Frame2.Location = New System.Drawing.Point(232, 440) Me.Frame2.Name = "Frame2" Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Frame2.Size = New System.Drawing.Size(345, 73)

Me.Frame2.TabIndex = 12 Me.Frame2.TabStop = False ' 'cmdBrowse ' Me.cmdBrowse.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.cmdBrowse.Cursor = System.Windows.Forms.Cursors.Default Me.cmdBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.cmdBrowse.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdBrowse.ForeColor = System.Drawing.Color.Red Me.cmdBrowse.Image = CType(resources.GetObject("cmdBrowse.Image"), System.Drawing.Image) Me.cmdBrowse.Location = New System.Drawing.Point(94, 16) Me.cmdBrowse.Name = "cmdBrowse" Me.cmdBrowse.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdBrowse.Size = New System.Drawing.Size(73, 49) Me.cmdBrowse.TabIndex = 9 Me.cmdBrowse.Text = "Browse" Me.cmdBrowse.TextAlign = System.Drawing.ContentAlignment.BottomCenter Me.cmdBrowse.UseVisualStyleBackColor = False ' 'PictureBox1 '

Me.PictureBox1.Location = New System.Drawing.Point(32, 176) Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Size = New System.Drawing.Size(200, 184) Me.PictureBox1.TabIndex = 24 Me.PictureBox1.TabStop = False ' 'Label3 ' Me.Label3.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.Label3.Cursor = System.Windows.Forms.Cursors.Default Me.Label3.Font = New System.Drawing.Font("Times New Roman", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.ForeColor = System.Drawing.Color.Blue Me.Label3.Image = CType(resources.GetObject("Label3.Image"), System.Drawing.Image) Me.Label3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft Me.Label3.Location = New System.Drawing.Point(161, 25) Me.Label3.Name = "Label3" Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label3.Size = New System.Drawing.Size(312, 112) Me.Label3.TabIndex = 25 Me.Label3.Text = "Comparasion Form" Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'frmCompare '

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.ActiveCaptionText Me.ClientSize = New System.Drawing.Size(666, 559) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.PictureBox1) Me.Controls.Add(Me.Frame2) Me.Controls.Add(Me.Frame1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "frmCompare" Me.Text = "Compare Form" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Frame1.ResumeLayout(False) CType(Me.Picture1, System.ComponentModel.ISupportInitialize).EndInit() Me.Frame2.ResumeLayout(False) CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click

openFileDlg.InitialDirectory = Application.StartupPath & "\brainsignalimages" openFileDlg.Filter = "Jpeg (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|AllFiles (*.*)| *.*" openFileDlg.Title = "Open brain signals" If openFileDlg.ShowDialog = DialogResult.OK Then Picture1.Image = System.Drawing.Image.FromFile(openFileDlg.FileName) End If cmdMake.Enabled = True End Sub Private Sub cmdMake_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMake.Click dir1 = Application.StartupPath & "\temp" & " " grph = New Bitmap(Picture1.Image) Dim S As String Dim i As Integer, j As Integer Dim path As String = Application.StartupPath & "\temp" If Not (Directory.Exists(path)) Then MsgBox("Directory not exists") Dim di As DirectoryInfo = Directory.CreateDirectory(path) End If Dim sw As StreamWriter = New StreamWriter(dir1 & "\temp.txt", False) For i = 0 To 2 st(i) = "" sw.WriteLine(st(i)) Next

For i = 0 To grph.Height - 1 S = "" For j = 0 To grph.Width - 1 Dim h As Integer h = grph.GetPixel(j, i).ToArgb If grph.GetPixel(j, i).ToArgb < -1 Then S=S&1 Else S=S&0 End If Next j sw.WriteLine(S) Next i MsgBox("Completed") sw.Close() cmdCheck.Enabled = True End Sub Private Sub cmdCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCheck.Click Dim i, j As Int16 Dim c As Byte Dim d As Byte Dim ch As String Dim dh As String Dim count As Double

Dim nop As Int16 Dim ans, ans1, ans2 As Double Dim per As Single Dim det(8) As String Dim fname As String Dim frmresult As New frmResult dir = Application.StartupPath & "\brain" & " " dir1 = Application.StartupPath & "\temp" & " " dirinfo = New DirectoryInfo(dir) dirinfo1 = New DirectoryInfo(dir1) Dim files As IEnumerator files = dirinfo.GetFiles().GetEnumerator Do While files.MoveNext Dim z1 As Integer Dim st1(8) As String fil = files.Current Dim fs As FileStream = New FileStream(fil.FullName, FileMode.OpenOrCreate) Dim fs1 As FileStream = New FileStream(dir1 & "\temp.txt", FileMode.OpenOrCreate) Dim w As StreamWriter = New StreamWriter(fs) Dim w1 As StreamWriter = New StreamWriter(fs1) w.BaseStream.Seek(0, SeekOrigin.End) w.BaseStream.Seek(0, SeekOrigin.End)

Dim r As StreamReader = New StreamReader(fs) Dim r2 As StreamReader = New StreamReader(fs) r2.BaseStream.Seek(0, SeekOrigin.Begin) r2.BaseStream.Seek(0, SeekOrigin.Current) For z1 = 0 To 3 st1(z1) = r2.ReadLine() Next r.BaseStream.Seek(0, SeekOrigin.Begin) Dim r1 As StreamReader = New StreamReader(fs1) r1.BaseStream.Seek(0, SeekOrigin.Begin) Dim z As Int16 Dim st As String r.BaseStream.Seek(0, SeekOrigin.Current) st = r.ReadLine For i = 0 To 199 While r.Peek() > -1 And r1.Peek() > -1 r.BaseStream.Seek(0, SeekOrigin.Current) ch = r.ReadLine() r1.BaseStream.Seek(0, SeekOrigin.Current) dh = r1.ReadLine() For j = 1 To 199 c = Val(Mid(ch, j, 1)) d = Val(Mid(dh, j, 1)) If Val(d) = 1 Then count = count + 1

If j = 1 Then If Val(c) = 1 Or Val(Mid(ch, j + 1, 1)) = 1 Then nop = nop + 1 End If ElseIf j = 100 Then If Val(c) = 1 Or Val(Mid(ch, j - 1, 1)) = 1 Then nop = nop + 1 End If Else If Val(c) = 1 Or Val(Mid(ch, j + 1, 1)) = 1 Or Val(Mid(ch, j 1, 1)) = 1 Then nop = nop + 1 End If End If End If Next End While Next r.Close() r1.Close() r2.Close() ans = nop If ans1 < ans Then ans1 = ans ans2 = count per = (ans1 / ans2) * 100

fname = fil.Name If per = 100 Then det(0) = st1(0) det(1) = st1(1) det(2) = st1(2) det(3) = st1(3) det(4) = st1(4) End If End If count = 0 nop = 0 Loop If per = 100 Then MsgBox("Matched ") frmresult._Text1_0.Text = det(0) frmresult._Text1_1.Text = det(1) frmresult._Text1_2.Text = det(2) frmresult.TextBox1.Text = per frmresult.Show() Else MsgBox("Not Matched") End If End Sub Private Sub cmdHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdHome.Click

Me.Visible = False Dim frmmain As New FrmMain frmmain.Show() End Sub Private Sub frmCompare_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load cmdCheck.Enabled = False cmdMake.Enabled = False End Sub

End Class

Vous aimerez peut-être aussi