📄 frmfacerec.frm
字号:
VERSION 5.00
Begin VB.Form frmFaceRecNeural
BackColor = &H00000000&
Caption = "Neural Face Location System - (c) Sluggish Software 2001"
ClientHeight = 4740
ClientLeft = 60
ClientTop = 345
ClientWidth = 10215
Icon = "frmFaceRec.frx":0000
LinkTopic = "Form1"
ScaleHeight = 4740
ScaleWidth = 10215
StartUpPosition = 3 'Windows Default
Begin VB.Frame Frame2
BackColor = &H00000000&
Caption = "Train Face Recogniser"
ForeColor = &H00FFFFFF&
Height = 4455
Left = 120
TabIndex = 5
Top = 120
Width = 2535
Begin VB.CommandButton cmdTest
Caption = "Test Recognition"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 10
Top = 3840
Width = 2295
End
Begin VB.PictureBox pic
Height = 660
Index = 0
Left = 960
Picture = "frmFaceRec.frx":0442
ScaleHeight = 57.971
ScaleMode = 0 'User
ScaleWidth = 49.181
TabIndex = 9
Top = 360
Width = 510
End
Begin VB.CommandButton cmdStart
Caption = "Begin Training"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 8
Top = 2640
Width = 2295
End
Begin VB.CommandButton cmdStop
Caption = "Stop Training"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 7
Top = 3240
Width = 2295
End
Begin VB.TextBox txtTrainingSuccess
Alignment = 2 'Center
Enabled = 0 'False
Height = 285
Left = 1080
TabIndex = 6
Text = "0"
Top = 2160
Width = 1335
End
Begin VB.Label Label1
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Input Image"
ForeColor = &H00FFC0C0&
Height = 255
Left = 120
TabIndex = 13
Top = 1080
Width = 2295
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "Accuracy"
ForeColor = &H00FFC0C0&
Height = 255
Left = 120
TabIndex = 12
Top = 2160
Width = 975
End
Begin VB.Label lblisaface
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "This is a face"
ForeColor = &H0000FFFF&
Height = 255
Left = 120
TabIndex = 11
Top = 1320
Visible = 0 'False
Width = 2175
End
End
Begin VB.Frame Frame1
BackColor = &H00000000&
Caption = "Test Face Location"
ForeColor = &H00FFFFFF&
Height = 4455
Left = 2760
TabIndex = 0
Top = 120
Width = 7335
Begin VB.PictureBox picScene
Height = 3375
Left = 120
Picture = "frmFaceRec.frx":0922
ScaleHeight = 100
ScaleMode = 0 'User
ScaleWidth = 100
TabIndex = 4
Top = 360
Width = 2295
End
Begin VB.PictureBox picScene2
Height = 3375
Left = 2520
ScaleHeight = 100
ScaleMode = 0 'User
ScaleWidth = 100
TabIndex = 3
Top = 360
Width = 2295
End
Begin VB.PictureBox picScene3
Height = 3375
Left = 4920
ScaleHeight = 100
ScaleMode = 0 'User
ScaleWidth = 100
TabIndex = 2
Top = 360
Width = 2295
End
Begin VB.CommandButton cmdLocate
Caption = "Locate Faces"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2520
TabIndex = 1
Top = 3840
Width = 2295
End
End
End
Attribute VB_Name = "frmFaceRecNeural"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim faces As New ClassFaceRecogniserNeural
Dim finish As Boolean
Const image_width = 25
Const image_height = 25
Private Sub cmdLocate_Click()
Dim filename As String
Me.MousePointer = 11
filename = App.Path & "\facenet.nn"
Call faces.init(image_width, image_height)
Call faces.load(filename)
Call faces.IdentifyWithinPicture(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight)
Call faces.showProbabilities(picScene2)
Call faces.showProbabilityMatrix(picScene3)
Me.MousePointer = 0
End Sub
Private Sub cmdStart_Click()
Dim filename As String
filename = App.Path & "\facenet.nn"
cmdStart.Enabled = False
cmdStop.Enabled = True
Call init
Call faces.load(filename)
finish = False
While (Not finish)
DoEvents
Call faces.Train
txtTrainingSuccess = Int(faces.Success * 100) / 100 & "%"
Wend
Call faces.save(filename)
cmdStart.Enabled = True
End Sub
Private Sub loadFace(index As Integer, picbox As PictureBox)
On Error GoTo loadImages_err
Dim filename As String
filename = App.Path & "\isface" & Trim(CStr(index)) & ".jpg"
If (Dir$(filename) <> "") Then
picbox.Picture = LoadPicture(filename)
End If
loadImages_exit:
Exit Sub
loadImages_err:
MsgBox "frmMain/loadFace/" & Error$(Err)
Resume loadImages_exit
End Sub
Private Sub loadNonFace(index As Integer, picbox As PictureBox)
On Error GoTo loadImages_err
Dim filename As String
filename = App.Path & "\nonface" & Trim(CStr(index)) & ".jpg"
If (Dir$(filename) <> "") Then
picbox.Picture = LoadPicture(filename)
End If
loadImages_exit:
Exit Sub
loadImages_err:
MsgBox "frmMain/loadNonFace/" & Error$(Err)
Resume loadImages_exit
End Sub
Private Sub init()
Dim i As Integer
Call faces.init(image_width, image_height)
For i = 0 To 40
Call loadFace(i, pic(0))
Call faces.addFace(pic(0))
Next
For i = 0 To 40
Call loadNonFace(i, pic(0))
Call faces.addNonFace(pic(0))
Next
End Sub
Private Sub cmdStop_Click()
finish = True
cmdStop.Enabled = False
End Sub
Private Sub cmdTest_Click()
Dim randomFace As Integer
Dim filename As String
filename = App.Path & "\facenet.nn"
Call faces.init(image_width, image_height)
Call faces.load(filename)
If (Int(Rnd * 2) = 1) Then
randomFace = 40 + Int(Rnd * 20)
Call loadFace(randomFace, pic(0))
Else
randomFace = 40 + Int(Rnd * 10)
Call loadNonFace(randomFace, pic(0))
End If
If (faces.IsaFace(pic(0))) Then
lblisaface.Caption = "This is a face"
Else
lblisaface.Caption = "This is not a face"
End If
lblisaface.Visible = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -