⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmfacerec.frm

📁 优秀的面部识别程序,用VB开发的
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmFaceRecNeural 
   BackColor       =   &H00000000&
   Caption         =   "Neural Face Location System - (c) Sluggish Software 2001"
   ClientHeight    =   6390
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   10665
   Icon            =   "frmFaceRec.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6390
   ScaleWidth      =   10665
   StartUpPosition =   3  'Windows Default
   Begin MSComDlg.CommonDialog Dialog 
      Left            =   840
      Top             =   5040
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      DialogTitle     =   "Open a new Test Image"
   End
   Begin VB.PictureBox pichistogram 
      Height          =   615
      Left            =   4320
      ScaleHeight     =   555
      ScaleWidth      =   1635
      TabIndex        =   16
      Top             =   5760
      Width           =   1695
   End
   Begin VB.CommandButton cmdLocateFaces 
      Caption         =   "Find Faces"
      Height          =   495
      Left            =   2640
      TabIndex        =   15
      Top             =   5880
      Width           =   1455
   End
   Begin VB.PictureBox picSkin 
      Height          =   255
      Left            =   2040
      Picture         =   "frmFaceRec.frx":0442
      ScaleHeight     =   15
      ScaleMode       =   0  'User
      ScaleWidth      =   13
      TabIndex        =   14
      Top             =   5880
      Width           =   255
   End
   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":06EA
         ScaleHeight     =   40
         ScaleMode       =   0  'User
         ScaleWidth      =   30
         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       =   &H00C0C0C0&
      Caption         =   "Test Face Location"
      ForeColor       =   &H00000000&
      Height          =   5295
      Left            =   2760
      TabIndex        =   0
      Top             =   120
      Width           =   7815
      Begin VB.PictureBox picScene 
         BackColor       =   &H00000000&
         Height          =   3375
         Left            =   120
         Picture         =   "frmFaceRec.frx":0BCA
         ScaleHeight     =   100
         ScaleMode       =   0  'User
         ScaleWidth      =   100
         TabIndex        =   4
         Top             =   240
         Width           =   3735
      End
      Begin VB.PictureBox picScene2 
         BackColor       =   &H00000000&
         Height          =   3375
         Left            =   3960
         ScaleHeight     =   202.752
         ScaleMode       =   0  'User
         ScaleWidth      =   173.759
         TabIndex        =   3
         Top             =   240
         Width           =   3735
      End
      Begin VB.PictureBox picScene3 
         BackColor       =   &H00000000&
         Height          =   1455
         Left            =   6120
         ScaleHeight     =   85.321
         ScaleMode       =   0  'User
         ScaleWidth      =   71.631
         TabIndex        =   2
         Top             =   3720
         Width           =   1575
      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            =   2160
         TabIndex        =   1
         Top             =   4680
         Width           =   1815
      End
      Begin MSComctlLib.Slider sldSensitivity 
         Height          =   375
         Left            =   0
         TabIndex        =   17
         Top             =   3840
         Width           =   6135
         _ExtentX        =   10821
         _ExtentY        =   661
         _Version        =   393216
         Min             =   50
         Max             =   99
         SelStart        =   50
         TickFrequency   =   5
         Value           =   50
      End
      Begin VB.Label Label4 
         Alignment       =   1  'Right Justify
         Caption         =   "Fewer detections"
         Height          =   255
         Left            =   4200
         TabIndex        =   19
         Top             =   4320
         Width           =   1815
      End
      Begin VB.Label Label2 
         Caption         =   "More detections"
         Height          =   255
         Left            =   120
         TabIndex        =   18
         Top             =   4320
         Width           =   1695
      End
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuOpen 
         Caption         =   "&Open"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "&Exit"
      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 & "\faces.rec"
  
  Call faces.init(image_Width, image_height)
  Call faces.load(FileName)
  faces.Threshold = Val(sldSensitivity / 100)
  faces.LocatorStepSize = 2
  
  picScene.ScaleWidth = 100
  picScene.ScaleHeight = 100
  picScene2.ScaleWidth = picScene.ScaleWidth
  picScene2.ScaleHeight = picScene.ScaleHeight
  picScene3.ScaleWidth = picScene.ScaleWidth
  picScene3.ScaleHeight = picScene.ScaleHeight
  
  'Call faces.IdentifyWithinPictureLinear(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight, picScene2)
  Call faces.IdentifyWithinPicture(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight, picScene2)
  Call faces.showProbabilities(picScene2)
  Call faces.showProbableAreas(picScene3)
  'Call faces.showProbabilityMatrix(picScene3)
  Me.MousePointer = 0
End Sub


Private Sub cmdLocateFaces_Click()
  Dim FileName As String

  Me.MousePointer = 11
  FileName = App.Path & "\faces.rec"
  
  Call faces.init(image_Width, image_height)
  Call faces.load(FileName)
  
  Call faces.addSkinColourTemplate(picSkin)
  
  Call faces.locateFaces(picScene, 5, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight)
  Call faces.showSkinColourHistogram(pichistogram)
  Call faces.showProbabilityMatrix(picScene3)
  Me.MousePointer = 0
End Sub


Private Sub cmdStart_Click()
  Dim FileName As String

  FileName = App.Path & "\faces.rec"
  
  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 & "%"
    'Call faces.showNNimage(picNN)
  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 85
    Call loadFace(i, pic(0))
    Call faces.addFace(pic(0))
  Next
    
  For i = 0 To 130
    Call loadNonFace(i, pic(0))
    Call faces.addNonFace(pic(0))
  Next
  
  Call faces.updateFaceTemplate
  
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 & "\faces.rec"
  
  Call faces.init(image_Width, image_height)
  Call faces.load(FileName)
  
  If (Int(Rnd * 2) = 1) Then
    randomFace = 1 + Int(Rnd * 70)
    Call loadFace(randomFace, pic(0))
    Else
    randomFace = 1 + Int(Rnd * 70)
    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



Private Sub Form_Load()
  sldSensitivity.value = 95
End Sub



Private Sub mnuOpen_Click()
  Dialog.Filter = "JPEG Files|*.JPG|GIF Files|*.GIF|Bitmaps|*.BMP"
  Dialog.InitDir = "E:\gfx\FaceRec" 'App.Path
  Dialog.FilterIndex = 1
  Dialog.ShowOpen
  If (Dialog.FileName <> "") Then
    picScene.Picture = LoadPicture(Dialog.FileName)
  End If
End Sub

Private Sub sldSensitivity_Change()
  faces.Threshold = sldSensitivity.value / 100
  If (faces.Threshold < 0#) Then
    faces.Threshold = 0#
  End If
  If (faces.Threshold > 0.99) Then
    faces.Threshold = 0.99
  End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -