MW.vb
Upload User: wuming6209
Upload Date: 2013-06-06
Package Size: 161k
Code Size: 5k
Category:

Video Capture

Development Platform:

Visual C++

  1. Imports DirectX.Capture
  2. Public Class MW
  3.     Inherits System.Windows.Forms.Form
  4. #Region " C骴igo generado por el Dise馻dor de Windows Forms "
  5.     Public Sub New()
  6.         MyBase.New()
  7.         'El Dise馻dor de Windows Forms requiere esta llamada.
  8.         InitializeComponent()
  9.         'Call to AddCam to select an available camera
  10.         Dim AddCamera As New AddCam()
  11.         AddCamera.ShowDialog(Me)
  12.         CaptureInformation.CaptureInfo.PreviewWindow = Me.videoBoard
  13.         'Define RefreshImage as event handler of FrameCaptureComplete
  14.         AddHandler CaptureInformation.CaptureInfo.FrameCaptureComplete, AddressOf RefreshImage
  15.         CaptureInformation.Counter = 1
  16.         CaptureInformation.CounterFrames = 1
  17.         Me.Show()
  18.         'Initialization of ConfWindow
  19.         CaptureInformation.ConfWindow = New CW()
  20.         CaptureInformation.ConfWindow.Refresh()
  21.         CaptureInformation.ConfWindow.Show()
  22.     End Sub
  23.     'Form reemplaza a Dispose para limpiar la lista de componentes.
  24.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  25.         If disposing Then
  26.             If Not (components Is Nothing) Then
  27.                 components.Dispose()
  28.             End If
  29.         End If
  30.         MyBase.Dispose(disposing)
  31.     End Sub
  32.     'Requerido por el Dise馻dor de Windows Forms
  33.     Private components As System.ComponentModel.IContainer
  34.     'NOTA: el Dise馻dor de Windows Forms requiere el siguiente procedimiento
  35.     'Puede modificarse utilizando el Dise馻dor de Windows Forms. 
  36.     'No lo modifique con el editor de c骴igo.
  37.     Friend WithEvents videoBoard As System.Windows.Forms.Panel
  38.     Friend WithEvents cmdFrame As System.Windows.Forms.Button
  39.     Friend WithEvents cmdStart As System.Windows.Forms.Button
  40.     Friend WithEvents cmdStop As System.Windows.Forms.Button
  41.     Friend WithEvents pcbFrame As System.Windows.Forms.PictureBox
  42.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  43.         Me.videoBoard = New System.Windows.Forms.Panel()
  44.         Me.cmdFrame = New System.Windows.Forms.Button()
  45.         Me.cmdStart = New System.Windows.Forms.Button()
  46.         Me.cmdStop = New System.Windows.Forms.Button()
  47.         Me.pcbFrame = New System.Windows.Forms.PictureBox()
  48.         Me.SuspendLayout()
  49.         '
  50.         'videoBoard
  51.         '
  52.         Me.videoBoard.Location = New System.Drawing.Point(2, 0)
  53.         Me.videoBoard.Name = "videoBoard"
  54.         Me.videoBoard.Size = New System.Drawing.Size(320, 240)
  55.         Me.videoBoard.TabIndex = 0
  56.         '
  57.         'cmdFrame
  58.         '
  59.         Me.cmdFrame.Location = New System.Drawing.Point(432, 256)
  60.         Me.cmdFrame.Name = "cmdFrame"
  61.         Me.cmdFrame.TabIndex = 1
  62.         Me.cmdFrame.Text = "Frame"
  63.         '
  64.         'cmdStart
  65.         '
  66.         Me.cmdStart.Location = New System.Drawing.Point(56, 256)
  67.         Me.cmdStart.Name = "cmdStart"
  68.         Me.cmdStart.TabIndex = 2
  69.         Me.cmdStart.Text = "Start"
  70.         '
  71.         'cmdStop
  72.         '
  73.         Me.cmdStop.Enabled = False
  74.         Me.cmdStop.Location = New System.Drawing.Point(184, 256)
  75.         Me.cmdStop.Name = "cmdStop"
  76.         Me.cmdStop.TabIndex = 3
  77.         Me.cmdStop.Text = "Stop"
  78.         '
  79.         'pcbFrame
  80.         '
  81.         Me.pcbFrame.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right)
  82.         Me.pcbFrame.Location = New System.Drawing.Point(334, 0)
  83.         Me.pcbFrame.Name = "pcbFrame"
  84.         Me.pcbFrame.Size = New System.Drawing.Size(320, 240)
  85.         Me.pcbFrame.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
  86.         Me.pcbFrame.TabIndex = 4
  87.         Me.pcbFrame.TabStop = False
  88.         '
  89.         'MW
  90.         '
  91.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  92.         Me.ClientSize = New System.Drawing.Size(656, 289)
  93.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.pcbFrame, Me.cmdStop, Me.cmdStart, Me.cmdFrame, Me.videoBoard})
  94.         Me.MaximizeBox = False
  95.         Me.MinimizeBox = False
  96.         Me.Name = "MW"
  97.         Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  98.         Me.Text = "Main Window"
  99.         Me.ResumeLayout(False)
  100.     End Sub
  101. #End Region
  102.     Public Sub RefreshImage(ByVal Frame As System.Windows.Forms.PictureBox)
  103.         Dim s() As String
  104.         s = CaptureInformation.PathVideo.Split(".")
  105.         Me.pcbFrame.Image = Frame.Image
  106.         Me.pcbFrame.Image.Save(s(0) + CStr(CaptureInformation.CounterFrames) + ".png")
  107.         CaptureInformation.CounterFrames += 1
  108.         Me.pcbFrame.Refresh()
  109.     End Sub
  110.     Private Sub cmdFrame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFrame.Click
  111.         CaptureInformation.CaptureInfo.CaptureFrame()
  112.     End Sub
  113.     Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
  114.         CaptureInformation.CaptureInfo.Start()
  115.         cmdStart.Enabled = False
  116.         cmdStop.Enabled = True
  117.     End Sub
  118.     Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click
  119.         CaptureInformation.CaptureInfo.Stop()
  120.         ConfParamCam()
  121.         PrepareCam(CaptureInformation.PathVideo)
  122.         cmdStart.Enabled = True
  123.         cmdStop.Enabled = False
  124.     End Sub
  125. End Class