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

📄 frmtesting.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 frmTesting 
   BackColor       =   &H00000000&
   Caption         =   "Test the face location algorithm"
   ClientHeight    =   5415
   ClientLeft      =   165
   ClientTop       =   450
   ClientWidth     =   7800
   Icon            =   "frmTesting.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5415
   ScaleWidth      =   7800
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   5415
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7815
      Begin VB.CommandButton cmdLocateEyes 
         Caption         =   "Locate Eyes"
         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            =   1200
         TabIndex        =   7
         Top             =   4680
         Visible         =   0   'False
         Width           =   1815
      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            =   3120
         TabIndex        =   3
         Top             =   4680
         Width           =   1815
      End
      Begin VB.PictureBox picScene2 
         BackColor       =   &H00000000&
         Height          =   3375
         Left            =   3960
         ScaleHeight     =   100
         ScaleMode       =   0  'User
         ScaleWidth      =   100
         TabIndex        =   2
         Top             =   240
         Width           =   3735
      End
      Begin VB.PictureBox picScene 
         BackColor       =   &H00000000&
         Height          =   3375
         Left            =   120
         Picture         =   "frmTesting.frx":0442
         ScaleHeight     =   100
         ScaleMode       =   0  'User
         ScaleWidth      =   100
         TabIndex        =   1
         Top             =   240
         Width           =   3735
      End
      Begin MSComctlLib.Slider sldSensitivity 
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   3840
         Width           =   7575
         _ExtentX        =   13361
         _ExtentY        =   661
         _Version        =   393216
         Min             =   50
         Max             =   99
         SelStart        =   50
         TickFrequency   =   5
         Value           =   50
      End
      Begin VB.Label Label2 
         Caption         =   "More detections"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   4320
         Width           =   1695
      End
      Begin VB.Label Label4 
         Alignment       =   1  'Right Justify
         Caption         =   "Fewer detections"
         Height          =   255
         Left            =   5760
         TabIndex        =   5
         Top             =   4320
         Width           =   1815
      End
   End
   Begin MSComDlg.CommonDialog Dialog 
      Left            =   0
      Top             =   5040
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      DialogTitle     =   "Open a new Test Image"
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuOpen 
         Caption         =   "&Open"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "&Exit"
      End
   End
   Begin VB.Menu mnuRecognition 
      Caption         =   "&Recognition"
      Begin VB.Menu mnuTraining 
         Caption         =   "&Training"
      End
      Begin VB.Menu mnuCamera 
         Caption         =   "&Video"
      End
   End
   Begin VB.Menu mnuShow 
      Caption         =   "&Show"
      Begin VB.Menu mnuShowFaces 
         Caption         =   "Faces"
      End
      Begin VB.Menu mnuTestCard 
         Caption         =   "Test &Card"
      End
      Begin VB.Menu mnuHistogram 
         Caption         =   "S&pectrograph"
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "&Help"
      Begin VB.Menu mnuAbout 
         Caption         =   "&About"
      End
   End
End
Attribute VB_Name = "frmTesting"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim faces As New ClassFaceRecogniser
Dim finish As Boolean

Const image_Width = 30
Const image_height = 40


Private Sub showFaces()
  Me.MousePointer = 11
  cmdLocate.Enabled = False
  
  Set faces = Nothing
  Call faces.init
  Call faces.load
  Call faces.setRecognitionThreshold(Val(sldSensitivity / 100))
  
  picScene.ScaleWidth = 100
  picScene.ScaleHeight = 100
  picScene2.ScaleWidth = picScene.ScaleWidth
  picScene2.ScaleHeight = picScene.ScaleHeight
  
  'Call faces.IdentifyWithinPictureLinear(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight, picScene2)
  Call faces.IdentifyFaceWithinPicture(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight, picScene2)
  Call faces.showFaceProbabilities(picScene2)
  'Call faces.showProbabilityMatrix(picScene2)
  Call faces.Free
  Me.MousePointer = 0
  cmdLocate.Enabled = True
End Sub


Private Sub showEyes()
  Me.MousePointer = 11
  cmdLocateEyes.Enabled = False
  
  Set faces = Nothing
  Call faces.init
  Call faces.load
  Call faces.setRecognitionThreshold(Val(sldSensitivity / 100))
  
  picScene.ScaleWidth = 150
  picScene.ScaleHeight = 100
  picScene2.ScaleWidth = picScene.ScaleWidth
  picScene2.ScaleHeight = picScene.ScaleHeight
  
  'Call faces.IdentifyWithinPictureLinear(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight, picScene2)
  Call faces.IdentifyEyesWithinPicture(picScene, 0, 0, picScene.ScaleWidth, picScene.ScaleHeight, picScene2)
  Call faces.showEyeProbabilities(picScene2)
  Call faces.Free
  Me.MousePointer = 0
  cmdLocateEyes.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 cmdLocate_Click()
  Call showFaces
End Sub




Private Sub showTestCard()
  Dim testcard As New classImageProcessing
  
  Call testcard.init(1, 1)
  Call testcard.showTestCard(picScene2)
  Set testcard = Nothing
End Sub




Private Sub cmdLocateEyes_Click()
  Call showEyes
End Sub


Private Sub Form_Load()
  sldSensitivity.Value = 98
End Sub


Private Sub mnuAbout_Click()
  frmAbout.show 1
End Sub


Private Sub mnuCamera_Click()
  On Error GoTo mnuCamera_Click_err
  
  frmTesting.MousePointer = 11
  Unload frmTesting
  frmVideoCapture.show
  
mnuCamera_Click_exit:
  Exit Sub
mnuCamera_Click_err:
  If (Err = 364) Then  'object was unloaded
    Resume mnuCamera_Click_exit
  End If
  
  MsgBox Error$(Err) & "  " & Err, , "Error"
  Resume mnuCamera_Click_exit
End Sub


Private Sub mnuExit_Click()
  End
End Sub


Private Sub mnuHistogram_Click()
  Call showHistogram
End Sub


Public Sub showHistogram()
  Set faces = Nothing
  Call faces.init
  Call faces.load
  Call faces.showSkinColourHistogram(picScene2, 0)
  Call faces.Free
End Sub


Private Sub mnuOpen_Click()
  Dialog.Filter = "JPEG Files|*.JPG|GIF Files|*.GIF|Bitmaps|*.BMP"
  Dialog.InitDir = "c:\my documents"  '"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 mnuShowFaces_Click()
  Call showFaces
End Sub

Private Sub mnuTestCard_Click()
  Call showTestCard
End Sub

Private Sub mnuTraining_Click()
  frmTraining.show
  Unload frmTesting
End Sub


Private Sub sldSensitivity_Change()
  Call faces.setRecognitionThreshold(sldSensitivity.Value / 100)
End Sub

⌨️ 快捷键说明

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