19 พฤษภาคม 2557

Face Detect โดย ใช้ EMGU

' ตอนนี้ผมกำลังศึกษาเพิ่มเติมอยู่หากใครมีส่วน Recognition ก็ขอด้วยครับผมมาได้แค่นี้
Imports Emgu.CV
Imports Emgu.CV.Structure
Imports Emgu.Util
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Runtime.InteropServices

Public Class frmWebcam

    Dim capturez As Capture = New Capture

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        'Dim img As New Image(Of Bgr, Byte)(imgFilename)
        Dim img As Image(Of Bgr, Byte) = capturez.QueryFrame()

        'Load the object detector
        Dim faceDetector As New CascadeClassifier("C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\haarcascade_frontalface_default.xml")

        'Convert the image to Grayscale
        Dim imgGray As Image(Of Gray, Byte) = img.Convert(Of Gray, Byte)()

        For Each face As Rectangle In faceDetector.DetectMultiScale( _
                           imgGray, _
                           1.1, _
                           10, _
                           New Size(20, 20), _
                           Size.Empty)
            img.Draw(face, New Bgr(Color.White), 1)
        Next
        PictureBox1.Image = img.ToBitmap()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
    End Sub

    Private Sub btnCapture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapture.Click
        'PictureBox2.Image = PictureBox1.Image
        Dim imagez As Image(Of Bgr, Byte) = capturez.QueryFrame()
        PictureBox2.Image = imagez.ToBitmap()

    End Sub
End Class

 เจอแล้วละแต่ดูเหมือนผมจะติดอะไรนิดหน่อย
http://www.youtube.com/watch?v=PV5arUlBIkk

ไม่มีความคิดเห็น: