Question video capture

lianaent

New member
Joined
Aug 27, 2011
Messages
1
Programming Experience
10+
Hi All,

I have an older vb.net application that captures video using FSFWRAP.dll writen in .Net 3.5 (upgraded from 1.1). However, when I convert the app to VS2010 I get an error, "Could not load file or assembly 'interop.FSFWRAPLib.dll'" despite apparently successful attempts to regsrv32 it. I suspect this has something to do with 32 bit vs. 64 bit (I'm on Windows 7).

I'd love an answer to this point, or else, a newer, better, improved way to do video capture. One of the problems I've always had with FSFWRAP is that it only worked with fire wire. I would like to be able to capture any web cam over USB. My objective is to capture images, 8 frames per second or better, and analyze each image. The analysis part works, but I need a better way to capture the frames.

FSFWRAP goes back to my .Net 1.1 days. I can't believe that there have been no improvements since then, or that there's no built-in method within VS2010. However, I haven't found it.

Anyone?
Thanks!!!

Larry
 
This post is really old but I'll leave a method I use with AFORGE. It takes 10 pictures at once and saves to a folder on desktop.

Introduction:​

In this summary, you will explore a VB.NET application that captures images from a webcam and saves them to a specified directory on the user's desktop. The application utilizes the AForge.NET framework, which provides a robust set of tools for image processing and computer vision tasks. We will break down the code step-by-step to understand its functionality and structure.

Key Concepts:​

Before diving into the code, let's clarify some key concepts:
  • VideoCaptureDevice: This class is part of the AForge.Video namespace and is used to access video input devices, such as webcams.
  • NewFrameEventArgs: This class provides data for the NewFrame event, which is triggered whenever a new frame is captured from the video source.
  • Bitmap: A class that represents an image defined by pixel data, allowing for manipulation and saving of images in various formats.

Code Structure:​

The code is structured into two main parts:
  1. Form1 Class: This class handles the webcam interaction, image capturing, and saving functionality.
  2. Module1: This module serves as the entry point for the application, initiating the Form1 instance.

Key Components of Form1:​

  • videoSource: An instance of VideoCaptureDevice that represents the webcam.
  • imageCounter: An integer that keeps track of the number of images captured.
  • savePath: A string that defines the directory where images will be saved.
AFORGE: CURRENT UPDATED METHOD WEB CAM:
Imports System.IO
Imports AForge.Video
Imports AForge.Video.DirectShow

Public Class Form1
    Private videoSource As VideoCaptureDevice
    Private imageCounter As Integer = 0
    Private savePath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "WebcamImages")

    Public Sub New()
        If Not Directory.Exists(savePath) Then
            Directory.CreateDirectory(savePath)
        End If

        Dim videoDevices As New FilterInfoCollection(FilterCategory.VideoInputDevice)
        If videoDevices.Count > 0 Then
            videoSource = New VideoCaptureDevice(videoDevices(0).MonikerString)
            AddHandler videoSource.NewFrame, AddressOf OnNewFrame
            videoSource.Start()
        End If
    End Sub
    Private Sub OnNewFrame(sender As Object, eventArgs As NewFrameEventArgs)
        Dim image As Bitmap = DirectCast(eventArgs.Frame.Clone(), Bitmap)
        SaveImage(image)
        IncrementImageCounter()

        ' Stop capturing after 10 images
        If ShouldStopCapturing() Then
            StopVideoSource()
        End If
    End Sub

    Private Sub SaveImage(image As Bitmap)
        Dim fileName As String = Path.Combine(savePath, $"Image_{imageCounter}.jpg")
        image.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg)
    End Sub

    Private Sub IncrementImageCounter()
        imageCounter += 1
    End Sub

    Private Function ShouldStopCapturing() As Boolean
        Return imageCounter >= 10
    End Function

    Private Sub StopVideoSource()
        videoSource.SignalToStop()
        videoSource.WaitForStop()
    End Sub


End Class


Public Module Module1
    Public Sub Main()
        Application.Run(New Form1())
    End Sub

End Module
 
Last edited:
Back
Top