Video Recording in Image Sequence
First form is recording main window and second one is video screen
for this execution we need to Import System.IO file and use following code:
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TotalTime.Enabled = False
TotalTime.Interval = 100
FileDIR.Text = System.IO.Directory.GetDirectoryRoot("\").ToUpper
'TextBox1.Text = TextBox1.Text + "Documents and Settings\" & My.User.Name.Trim & "\My Documents\My Pictures"
FileDIR.Text = FileDIR.Text + My.User.Name.ToUpper & "\IMGSEQ\"
If Directory.Exists(FileDIR.Text) = False Then
Directory.CreateDirectory(FileDIR.Text)
Else
Exit Sub
End If
End Sub
Private Sub RECScreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RECScreen.Tick
If CheckBox1.Checked = False Then
Dim DirectoryA As String = FileDIR.Text
Dim frame0 As String = FileNum.Text
Dim Img0 As String = FileType.Text
FileNum.Text = FileNum.Text + 1
Else
Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim BMPs As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim G As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMPs)
G.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
Dim DirectoryA As String = FileDIR.Text
Dim Frame1 As String = FileNum.Text
Dim Img1 As String = FileType.Text
FileNum.Text = FileNum.Text + 1
BMPs.Save(DirectoryA & Frame1 & Img1)
Form2.PictureBox1.Load(DirectoryA & Frame1 & Img1)
End If
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
If Form2.Visible = True Then
Form2.Visible = False
ToolStripStatusLabel1.Text = "Video Screen On"
Else
Form2.Visible = True
ToolStripStatusLabel1.Text = "Video Screen Off"
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Form2.Visible = True
ToolStripStatusLabel1.Text = "Video Screen On"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Form2.Visible = False
ToolStripStatusLabel1.Text = "Video Screen Off"
End Sub
Private Sub FRP10ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRP10ToolStripMenuItem.Click
FRP10ToolStripMenuItem.Checked = True
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
FPS10ToolStripMenuItem.Checked = True
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
Label1.Text = "100 FPS"
RECScreen.Interval = "10"
End Sub
Private Sub FRP50ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRP50ToolStripMenuItem.Click
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = True
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = True
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
Label1.Text = "20 FPS"
RECScreen.Interval = "50"
End Sub
Private Sub FRP100ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRP100ToolStripMenuItem.Click
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = True
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = True
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
Label1.Text = "10 FPS"
RECScreen.Interval = "100"
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
RECScreen.Enabled = False
ToolStripStatusLabel1.Text = "Recording Stop"
TotalTime.Enabled = False
End Sub
Private Sub FRP250ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRP250ToolStripMenuItem.Click
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = True
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = True
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
Label1.Text = "07 FPS"
RECScreen.Interval = "250"
End Sub
Private Sub FRP500ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRP500ToolStripMenuItem.Click
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = True
FRP1000ToolStripMenuItem.Checked = False
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = True
FPS1000ToolStripMenuItem1.Checked = False
Label1.Text = "05 FPS"
RECScreen.Interval = "500"
End Sub
Private Sub FRP1000ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRP1000ToolStripMenuItem.Click
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = True
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = True
Label1.Text = "01 FPS"
RECScreen.Interval = "1000"
End Sub
Private Sub REC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles REC.Click
'Me.WindowState = FormWindowState.Minimized
RECScreen.Enabled = True
FileNum.Text = "0"
ToolStripStatusLabel1.Text = "Recording..."
TotalTime.Enabled = True
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Me.WindowState = FormWindowState.Minimized
RECScreen.Enabled = True
FileNum.Text = "0"
ToolStripStatusLabel1.Text = "Recording..."
TotalTime.Enabled = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim FileOpn As New FolderBrowserDialog
FileOpn.ShowDialog()
FileDIR.Text = FileOpn.SelectedPath & "\"
End Sub
Private Sub STP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STP.Click
RECScreen.Enabled = False
ToolStripStatusLabel1.Text = "Recording Stop"
TotalTime.Enabled = False
End Sub
Private Sub FPS10ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPS10ToolStripMenuItem.Click
FPS10ToolStripMenuItem.Checked = True
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
FRP10ToolStripMenuItem.Checked = True
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
Label1.Text = "100 FPS"
RECScreen.Interval = "10"
End Sub
Private Sub FPS50ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPS50ToolStripMenuItem.Click
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = True
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = True
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
Label1.Text = "20 FPS"
RECScreen.Interval = "50"
End Sub
Private Sub FPS100ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPS100ToolStripMenuItem.Click
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = True
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = True
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
Label1.Text = "10 FPS"
RECScreen.Interval = "100"
End Sub
Private Sub FPS250ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPS250ToolStripMenuItem.Click
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = True
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = False
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = True
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = False
Label1.Text = "07 FPS"
RECScreen.Interval = "250"
End Sub
Private Sub FPS500ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPS500ToolStripMenuItem.Click
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = True
FPS1000ToolStripMenuItem1.Checked = False
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = True
FRP1000ToolStripMenuItem.Checked = False
Label1.Text = "05 FPS"
RECScreen.Interval = "500"
End Sub
Private Sub FPS1000ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPS1000ToolStripMenuItem1.Click
FPS10ToolStripMenuItem.Checked = False
FPS50ToolStripMenuItem.Checked = False
FPS100ToolStripMenuItem.Checked = False
FPS250ToolStripMenuItem.Checked = False
FPS500ToolStripMenuItem.Checked = False
FPS1000ToolStripMenuItem1.Checked = True
FRP10ToolStripMenuItem.Checked = False
FRP50ToolStripMenuItem.Checked = False
FRP100ToolStripMenuItem.Checked = False
FRP250ToolStripMenuItem.Checked = False
FRP500ToolStripMenuItem.Checked = False
FRP1000ToolStripMenuItem.Checked = True
Label1.Text = "01 FPS"
RECScreen.Interval = "1000"
End Sub
Private Sub StartRecordingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartRecordingToolStripMenuItem.Click
Me.WindowState = FormWindowState.Minimized
RECScreen.Enabled = True
FileNum.Text = "0"
ToolStripStatusLabel1.Text = "Recording..."
TotalTime.Enabled = True
End Sub
Private Sub StopRecordingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopRecordingToolStripMenuItem.Click
RECScreen.Enabled = False
ToolStripStatusLabel1.Text = "Recording Stop"
TotalTime.Enabled = False
End Sub
Private Sub ExitApplicationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitApplicationToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.CheckState = CheckState.Checked Then
ToolStripStatusLabel1.Text = "I/O File-Rec On"
ElseIf CheckBox1.CheckState = CheckState.Unchecked Then
ToolStripStatusLabel1.Text = "I/O File-Rec Off"
End If
End Sub
Private Sub TotalTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TotalTime.Tick
TotalTime.Enabled = True
ToolSec.Text = Val(ToolSec.Text) + 1
If ToolSec.Text = 60 Then
ToolMin.Text = Val(ToolMin.Text) + 1
ToolSec.Text = 0
End If
If ToolMin.Text = 60 Then
ToolHrs.Text = Val(ToolHrs.Text) + 1
ToolMin.Text = 0
End If
End Sub
End Class
No comments:
Post a Comment