dr i made this modifcation it debeugs but it runs an exception

'''''

          Imports AForge
     Imports AForge.Video
            Imports AForge.Video.DirectShow
       Imports System.IO

       Public Class Form1
       Dim CAMERA As VideoCaptureDevice
       Dim bmp As Bitmap
          Dim e As EventArgs

Public Sub Captured(sender As Object, EventArgs As NewFrameEventArgs)
    bmp = DirectCast(EventArgs.Frame.Clone(), Bitmap)
    PictureBox1.Image = DirectCast(EventArgs.Frame.Clone(), Bitmap)
End Sub
'
'Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'
'   End Sub
'Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button2.Click
'   SaveFileDialog1.DefaultExt = ".jpg"
'If SaveFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
'       PictureBox2.Image.Save(SaveFileDialog1.FileName, Imaging.ImageFormat.Jpeg)
'End If
'End Sub

Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
    CAMERA.Stop()
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Timer1.Enabled = True
    Me.Timer1.Start()
    Me.Timer1.Interval = 2000
    Dim cameras As VideoCaptureDeviceForm = New VideoCaptureDeviceForm
    If cameras.ShowDialog = System.Windows.Forms.DialogResult.OK Then
        CAMERA = cameras.VideoDevice
        AddHandler CAMERA.NewFrame, New NewFrameEventHandler(AddressOf Captured)
        CAMERA.Start()
    End If
End Sub

Private Sub Timer1_Tick(sender As Object, EventArgs As NewFrameEventArgs) Handles Timer1.Tick
    Try
        bmp = DirectCast(EventArgs.Frame.Clone(), Bitmap)
        PictureBox1.Image = DirectCast(EventArgs.Frame.Clone(), Bitmap)
        PictureBox2.Image = PictureBox1.Image

        ' SaveFileDialog1.DefaultExt = ".jpg"
        'If SaveFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
        'PictureBox2.Image.Save(SaveFileDialog1.FileName, Imaging.ImageFormat.Jpeg)
        PictureBox1.Image.Save("C:\Users\Karl\Desktop\Screenshot\filename.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
    ' End If
End Sub

End Class

df.png

   with this code it run like this ( every 2 seconds it displays message ) 
     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Try

        Captured(sender, e)

        'bmp = DirectCast(EventArgs.Frame.Clone(), Bitmap)
        'PictureBox1.Image = DirectCast(EventArgs.Frame.Clone(), Bitmap)
        PictureBox2.Image = PictureBox1.Image

     ![hjj.png](/attachments/large/4/b86b26ac2d5fbc317d7c2d629618eafd.png "align-center")

ok dr i will see

   hi, dr do you have an explanation for this message : 
     ![excep.png](/attachments/large/4/fcaa19cab24c2ea6b25fc74d9ff235b4.png "align-center") 
    ![save.png](/attachments/large/4/c89bd1dc48b94ce0fe1110554a852fce.png "align-center") 
    i think i instanciated all object 

     Imports AForge
   Imports AForge.Video
    Imports AForge.Video.DirectShow
      Imports System.IO

    Public Class Form1
Dim CAMERA As VideoCaptureDevice
Dim bmp As Bitmap

Public Sub Captured(sender As Object, EventArgs As NewFrameEventArgs)
    bmp = CType(EventArgs.Frame.Clone(), Bitmap)
    PictureBox1.Image = CType(EventArgs.Frame.Clone(), Bitmap)
End Sub
'
'Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'   End Sub
'Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button2.Click
'   SaveFileDialog1.DefaultExt = ".jpg"
'If SaveFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
'       PictureBox2.Image.Save(SaveFileDialog1.FileName, Imaging.ImageFormat.Jpeg)
'End If
'End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
    CAMERA.Stop()
End Sub

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

    Dim cameras As VideoCaptureDeviceForm = New VideoCaptureDeviceForm
    If cameras.ShowDialog = System.Windows.Forms.DialogResult.OK Then
        CAMERA = cameras.VideoDevice
        AddHandler CAMERA.NewFrame, New NewFrameEventHandler(AddressOf Captured)
        CAMERA.Start()
    End If
    Me.Timer1.Start()
    Me.Timer1.Interval = 2000
End Sub

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

    PictureBox2.Image = PictureBox1.Image
    PictureBox1.Image.Save("C:\Users\Soft\Desktop\TUNIPAK\yosri", System.Drawing.Imaging.ImageFormat.Jpeg)

End Sub

    End Class

no i think that it is not a Aforge issue, it miss an object that is not instanciated

If you didn't instanciate an object and that's an Aforge object, back to them on how to do that.
Remember there are so many ways to skin this cat which is why I noted a search above.
It's a shame you haven't got the image capture step working. Why not forget Aforge and read how others captured images with a timer?

PS. I think this is a shame since all the fun stuff you want to do is not in the capture step. The capture step is so well discussed (I supplied a google) that you should have had that working in a hour or two. Here we are and you are fussing with Aforge and it's not working for you and apparently Aforge won't help and/or doesn't have working examples (I didn't check, you do that.)

So all the good stuff I learned in product development about motion detection isn't happening because I think you are being stubborn. It's like you dug a well and it's dry. You keep on digging.

commented: That's the first rule of holes. If you're in one, stop digging. +14

thank you for your help dr, finally i come to solve it using Aforge.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.