To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Article :: Building Dynamic Systems with Expressions in .NET
How Is XML Like An Interface?
Understanding Covariance and Contravariance
Print VS 2010 Keyboard Shortcut References in Letter (8.5x11in) and A4 (210×297mm) Sizes
Updated Productivity Power Tools



Go Back   VBForums > VBForums CodeBank > CodeBank - Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Jun 13th, 2005, 05:28 PM   #1
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
[Vb.Net] WebCam Class (ICam)

Ok I Wrote this class to get to grips with the .NET enviroment so the coding may not be the best but it works. I've also attatached a project which uses the class its all simple enough

The class will make it easy for your app to view a webcamera set FPS etc.

Ok the class,

First 3 variables which can be changed within the class are,

Code:
    Private CamFrameRate As Integer = 15
    Private OutputHeight As Integer = 240
    Private OutputWidth As Integer = 360

CamFrameRate
- Starting frame rate how much of a gap there is between frames 15ms (About 65 FPS) NOTE - You can changes the FPS through a sub this is just the initial frame rate.

OutputHeight/OutputWidth
- Fairly self explanitory, just sets the dimensions of output.

VB Code:
  1. Public iRunning As Boolean

This can be called at anytime and will return if the camera is running or not

VB Code:
  1. Messagebox.show Mycam.Irunning

How To Use The Class

VB Code:
  1. Private myCam As iCam
  2. Set myCam = New iCam

From here you can call a range of functions using the syntax,

VB Code:
  1. mycam.[Function Name]

Functions

initCam(ByVal parentH As Integer)
- This is where it all starts you must call this to set the camera up first
ParentH is where we want to prievew, so if we have a pictureBox on our form, named picoutput.

VB Code:
  1. myCam.initCam(Me.picOutput.Handle.ToInt32)

resetCam()
- If you need to reset the camera call this function, you most proberly wont but its here incase you do

VB Code:
  1. MyCam.ResetCam()

setFrameRate(ByVal iRate As Long)
- Here you can set the frame rate by passing FPS it will then be converted into how much time between frames.

VB Code:
  1. myCam.setFrameRate(25)

closeCam()

- Allways call when closing the application, just clears things up.

VB Code:
  1. myCam.CloseCam()

copyFrame(ByVal src As PictureBox, ByVal rect As RectangleF)

- This sub returns an image of the current frame. You need to pass to it the source picture box (Where the camera image is) and then a rectangle specifying size dimensions.

VB Code:
  1. Me.picStill.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _
  2.                             Me.picOutput.Width, Me.picOutput.Height))

FPS()
- This sub returns the current FPS
VB Code:
  1. MessageBox.Show MyCam.Fps()


As I say code may not be great but it works good, and i just hope sompeople may find it useful. I'd appriciate people not replying here but Pm'ing me with any problems since i'd like to keep this thread as clean as possible!

Pino
Attached Files
File Type: zip iCam Class.zip (1.5 KB, 32863 views)
File Type: zip WebCamViewer.zip (28.6 KB, 20875 views)

Last edited by Hack; Jan 13th, 2006 at 09:00 AM.
Pino is offline   Reply With Quote
Old Jun 29th, 2005, 04:54 AM   #2
nightkids31
Junior Member
 
Join Date: Jun 05
Posts: 24
nightkids31 is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Is there a motion detection function included?..
nightkids31 is offline   Reply With Quote
Old Jun 29th, 2005, 05:01 AM   #3
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
Re: [Vb.Net] WebCam Class (ICam)

Quote:
I'd appriciate people not replying here but Pm'ing me with any problems since i'd like to keep this thread as clean as possible!
No motion detection, but it can copy a frame so you just need to compare 2 frames. Please Pm me with any furthor problems
Pino is offline   Reply With Quote
Old Nov 30th, 2005, 12:05 PM   #4
Wokawidget
Super Moderator
 
Wokawidget's Avatar
 
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)
Re: [Vb.Net] WebCam Class (ICam)

OK, this is my conversion, it's in 2005. The only difference I think is the Running property as 2003 doesn't support Public and Friend property with the same name.
VB Code:
  1. Imports System.Windows.Forms
  2. Imports System.Drawing
  3. Public Class WebCamera
  4. #Region "Api/constants"
  5.     Private Const WS_CHILD As Integer = &H40000000
  6.     Private Const WS_VISIBLE As Integer = &H10000000
  7.     Private Const SWP_NOMOVE As Short = &H2S
  8.     Private Const SWP_NOZORDER As Short = &H4S
  9.     Private Const WM_USER As Short = &H400S
  10.     Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_USER + 10
  11.     Private Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_USER + 11
  12.     Private Const WM_CAP_SET_VIDEOFORMAT As Integer = WM_USER + 45
  13.     Private Const WM_CAP_SET_PREVIEW As Integer = WM_USER + 50
  14.     Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_USER + 52
  15.     Private Const WM_CAP_GET_FRAME As Long = 1084
  16.     Private Const WM_CAP_COPY As Long = 1054
  17.     Private Const WM_CAP_START As Long = WM_USER
  18.     Private Const WM_CAP_STOP As Long = (WM_CAP_START + 68)
  19.     Private Const WM_CAP_SEQUENCE As Long = (WM_CAP_START + 62)
  20.     Private Const WM_CAP_SET_SEQUENCE_SETUP As Long = (WM_CAP_START + 64)
  21.     Private Const WM_CAP_FILE_SET_CAPTURE_FILEA As Long = (WM_CAP_START + 20)
  22.     Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Short, ByVal lParam As String) As Integer
  23.     Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer
  24.     Private Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean
  25.  
  26. #End Region
  27.     Public Event ImageChanged()
  28.     Private _Device As String
  29.     Private _hWnd As Integer
  30.     Private lwndC As Integer
  31.     Public _Running As Boolean
  32.     Private _FramesPerSecond As Integer = 10
  33.     Private OutputHeight As Integer = 240
  34.     Private OutputWidth As Integer = 360
  35.     Private _LoggingFrameSpan As Integer = 0
  36.     Private _LoggingFilename As String = String.Empty
  37.     Private _LoggingCount As Integer = 0
  38.     Private WithEvents _Picture As PictureBox
  39.     Public Property Running() As Boolean
  40.         Get
  41.             Return _Running
  42.         End Get
  43.         Friend Set(ByVal value As Boolean)
  44.             _Running = value
  45.         End Set
  46.     End Property
  47.     Public Property FramesPerSecond() As Integer
  48.         Get
  49.             Return _FramesPerSecond
  50.         End Get
  51.         Set(ByVal value As Integer)
  52.             _FramesPerSecond = value
  53.             ResetCamera()
  54.         End Set
  55.     End Property
  56.     Public ReadOnly Property CurrentImage() As Image
  57.         Get
  58.             Dim CurrentPic As Image = Nothing
  59.             If Not (_Picture Is Nothing) Then
  60.                 Return _Picture.Image
  61.             End If
  62.             Return CurrentPic
  63.         End Get
  64.     End Property
  65.     Public Sub StartFeed()
  66.         If Me.Running Then
  67.             Throw New CameraAlreadyRunningException
  68.         Else
  69.             Try
  70.                 _Picture = New PictureBox
  71.                 _hWnd = capCreateCaptureWindowA(_Device, WS_VISIBLE Or WS_CHILD, 0, 0, OutputWidth, CShort(OutputHeight), _Picture.Handle.ToInt32, 0)
  72.                 SetupCamera()
  73.             Catch Ex As Exception
  74.                 _Picture = Nothing
  75.                 Throw Ex
  76.             End Try
  77.         End If
  78.     End Sub
  79.     Public Sub EndFeed()
  80.         If Me.Running Then
  81.             SendMessage(_hWnd, WM_CAP_DRIVER_DISCONNECT, 0, CType(0, String))
  82.             _Picture = Nothing
  83.             Me.Running = False
  84.         Else
  85.             Throw New CameraNotRunningException
  86.         End If
  87.     End Sub
  88.     Public Sub ResetCamera()
  89.         If _Running Then
  90.             EndFeed()
  91.             Application.DoEvents()
  92.             SetupCamera()
  93.         Else
  94.             Throw New CameraNotRunningException
  95.         End If
  96.     End Sub
  97.     Private Sub SetupCamera()
  98.         If SendMessage(_hWnd, WM_CAP_DRIVER_CONNECT, CType(_Device, Short), CType(0, String)) = 1 Then
  99.             Dim CameraFrameRate As Short = CType(1000 \ _FramesPerSecond, Short)
  100.             SendMessage(_hWnd, WM_CAP_SET_PREVIEWRATE, CameraFrameRate, CType(0, String))
  101.             SendMessage(_hWnd, WM_CAP_SET_PREVIEW, 1, CType(0, String))
  102.             Me.Running = True
  103.         Else
  104.             Me.Running = False
  105.             Throw New CameraSetupFailedException
  106.         End If
  107.     End Sub
  108.     Public Sub StartLogging(ByVal Folder As String, ByVal GroupFilename As String, ByVal FrameSpan As Integer)
  109.         _LoggingFrameSpan = FrameSpan
  110.         Dim Filename As String = Folder
  111.         If Not Filename.EndsWith("\") Then
  112.             Filename &= "\"
  113.         End If
  114.         Filename &= GroupFilename
  115.         _LoggingFilename = Filename
  116.     End Sub
  117.     Public Sub StopLogging()
  118.         _LoggingFrameSpan = 0
  119.         _LoggingFilename = String.Empty
  120.         _LoggingCount = 0
  121.     End Sub
  122.     Private Sub _Picture_BackgroundImageChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles _Picture.BackgroundImageChanged
  123.         If _LoggingFrameSpan > 0 Then
  124.             Dim LogImage As Boolean = _LoggingCount = 0 OrElse (_LoggingCount Mod _LoggingFrameSpan) = 0
  125.             _LoggingCount += 1
  126.             If LogImage Then
  127.                 LogCurrentImage()
  128.             End If
  129.         End If
  130.         RaiseEvent ImageChanged()
  131.     End Sub
  132.     Private Sub LogCurrentImage()
  133.         CurrentImage.Save(_LoggingFilename & _LoggingCount.ToString)
  134.     End Sub
  135. End Class
I also created some custom exceptions:
VB Code:
  1. Public Class CameraNotRunningException
  2.     Inherits Exception
  3.     Public Sub New()
  4.         MyBase.New("Camera is not currently running")
  5.     End Sub
  6. End Class
  7. Public Class CameraSetupFailedException
  8.     Inherits Exception
  9.     Public Sub New()
  10.         MyBase.New("Camera setup failed")
  11.     End Sub
  12. End Class
  13. Public Class CameraAlreadyRunningException
  14.     Inherits Exception
  15.     Public Sub New()
  16.         MyBase.New("Camera is already running")
  17.     End Sub
  18. End Class
Now to use this code you need to do something like:
VB Code:
  1. Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
  2.         _Camera = New WebCamLib.WebCamera
  3.         _Camera.StartFeed()
  4.     End Sub
  5.     Private Sub btnEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnd.Click
  6.         If _Camera.Running Then
  7.             _Camera.EndFeed()
  8.         End If
  9.         _Camera = Nothing
  10.     End Sub
  11.     Private Sub _Camera_ImageChanged() Handles _Camera.ImageChanged
  12.         Dim NewImage As Image = _Camera.CurrentImage
  13.         'display image on form
  14.     End Sub
I haven't had time to really test this, it's merely an alpha release. As you can see you can start logging at any time by using the StartLogging sub.
The logging I hope to seperate into a seperate class that deals soley with logging.

ANyways, have a play, tell me where I have gone wrong.

Woof
__________________
My .NET Tutorials:
Silverlight Enabled WebPart in WSS

My VB.NET Code Examples:
Create IIS Virtual DirectoryValidate Login Against Active DirectoryAutomatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET

My ASP.NET Code Examples:
Login To Website (Forms Authentication)Login To Website (Custom Authentication)

My VB6 Code Projects:
Multithreading In VB6Custom TooltipsMulti Language SupportItem Selector ControlAnnimated Systray IconSimple Effective Graph ControlDownload From WebLiveUpdate, download application updates from the web automaticallySystray Notification MessagesSkin A FormAPI TimerBadger Messenger, an MSN clone that uses the MSN NetworkWokawidgets VB6 Component Suite
Wokawidget is offline   Reply With Quote
Old Apr 26th, 2006, 09:37 AM   #5
edid
New Member
 
Join Date: Apr 06
Posts: 9
edid is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Hi,
I changed WebCamViewer to get the real frame rate using the CallBack function and I get about 6 frames per second.
Can you really have a 25 frames/s ?
edid is offline   Reply With Quote
Old Apr 26th, 2006, 10:33 AM   #6
Wokawidget
Super Moderator
 
Wokawidget's Avatar
 
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)
Re: [Vb.Net] WebCam Class (ICam)

What did u change? Pino's vb6 version, or my .NET conversion?

Woof
__________________
My .NET Tutorials:
Silverlight Enabled WebPart in WSS

My VB.NET Code Examples:
Create IIS Virtual DirectoryValidate Login Against Active DirectoryAutomatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET

My ASP.NET Code Examples:
Login To Website (Forms Authentication)Login To Website (Custom Authentication)

My VB6 Code Projects:
Multithreading In VB6Custom TooltipsMulti Language SupportItem Selector ControlAnnimated Systray IconSimple Effective Graph ControlDownload From WebLiveUpdate, download application updates from the web automaticallySystray Notification MessagesSkin A FormAPI TimerBadger Messenger, an MSN clone that uses the MSN NetworkWokawidgets VB6 Component Suite
Wokawidget is offline   Reply With Quote
Old Apr 26th, 2006, 10:37 AM   #7
edid
New Member
 
Join Date: Apr 06
Posts: 9
edid is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

I changed .Net code.
edid is offline   Reply With Quote
Old Apr 26th, 2006, 01:04 PM   #8
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
Re: [Vb.Net] WebCam Class (ICam)

Woka!

My Code was .net!

My code was .Net 2003 wokas is .net 2005
Pino is offline   Reply With Quote
Old Aug 22nd, 2006, 02:11 AM   #9
ini_hendry
Member
 
Join Date: Jul 06
Location: Taiwan
Posts: 37
ini_hendry is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

are these code applicable to all webcam ?
i'm using logitech quickcam express

woka's code consist of WebCamLib ?
what is it ? i got an error when debugging
ini_hendry is offline   Reply With Quote
Old Jan 9th, 2007, 10:07 AM   #10
lalala
New Member
 
Join Date: Jan 07
Posts: 2
lalala is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

If another application is using the web cam and we start our application, a selection device window apears, what can I do to not see this window? (sorry for my english, is not perfect) I been waiting for a solution for this problem for like two weeks, can someone help me?
lalala is offline   Reply With Quote
Old Jan 11th, 2007, 03:33 AM   #11
edid
New Member
 
Join Date: Apr 06
Posts: 9
edid is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Hi,
I get the solution, after a long an hard job !
See VB.NET sources here : http://edid.free.fr/shared/webcam/index.php
Solution is in the registry database.

Last edited by edid; Jan 11th, 2007 at 05:57 AM.
edid is offline   Reply With Quote
Old Jan 11th, 2007, 05:39 AM   #12
Wokawidget
Super Moderator
 
Wokawidget's Avatar
 
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)
Re: [Vb.Net] WebCam Class (ICam)

Nice code...just looking at it now.
Although he's used the VisualBasic namespace I believe, and the code in certain places is a little left to be desired Could really do with going through and tidying all the lose ends etc.

I actually cannot get it to work either...but am still working on that.

Woka
__________________
My .NET Tutorials:
Silverlight Enabled WebPart in WSS

My VB.NET Code Examples:
Create IIS Virtual DirectoryValidate Login Against Active DirectoryAutomatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET

My ASP.NET Code Examples:
Login To Website (Forms Authentication)Login To Website (Custom Authentication)

My VB6 Code Projects:
Multithreading In VB6Custom TooltipsMulti Language SupportItem Selector ControlAnnimated Systray IconSimple Effective Graph ControlDownload From WebLiveUpdate, download application updates from the web automaticallySystray Notification MessagesSkin A FormAPI TimerBadger Messenger, an MSN clone that uses the MSN NetworkWokawidgets VB6 Component Suite
Wokawidget is offline   Reply With Quote
Old Jan 11th, 2007, 05:58 AM   #13
edid
New Member
 
Join Date: Apr 06
Posts: 9
edid is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

I'll be happy you give me advices.
edid is offline   Reply With Quote
Old Jan 11th, 2007, 06:10 AM   #14
Wokawidget
Super Moderator
 
Wokawidget's Avatar
 
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)Wokawidget is a jewel in the rough (300+)
Re: [Vb.Net] WebCam Class (ICam)

Well remove the VisualBasic reference from the project.

Then slowly convert the code to "proper" .NET, ie:

VB Code:
  1. strText = Len(strUsername)
would change to:
VB Code:
  1. strText = strUsername.Length

Others include:

VB Code:
  1. Err.raise(-1, "Class Name", "Err Description")
changes to:
VB Code:
  1. Throw New Exception("Err Description")
and
VB Code:
  1. MsgBox("Hello!")
to
VB Code:
  1. MessageBox.Show("Hello!")

The code itself isn't the neatest. Poor error handling, poor variable naming and the code construction isn't the best.

An example of this would be:
VB Code:
  1. Module MTools
  2.     Public Function MREG_GetRoot(ByVal psNom As String, Optional ByVal pbReadOnly As Boolean = False) As Microsoft.Win32.RegistryKey
  3.         Dim lRegRoot As Microsoft.Win32.RegistryKey
  4.         Dim lsRegRoot As String
  5.         lsRegRoot = UCase(psNom.Split("\")(0))
  6.         Select Case UCase(lsRegRoot)
  7.             Case "HKEY_CURRENT_USER"
  8.                 MREG_GetRoot = Microsoft.Win32.Registry.CurrentUser
  9.             Case "HKEY_LOCAL_MACHINE"
  10.                 MREG_GetRoot = Microsoft.Win32.Registry.LocalMachine
  11.             Case "HKEY_CLASSES_ROOT"
  12.                 MREG_GetRoot = Microsoft.Win32.Registry.ClassesRoot
  13.             Case "HKEY_CURRENT_CONFIG"
  14.                 MREG_GetRoot = Microsoft.Win32.Registry.CurrentConfig
  15.             Case "HKEY_USERS"
  16.                 MREG_GetRoot = Microsoft.Win32.Registry.Users
  17.             Case Else
  18.                 Err.Raise(-1, "MREG_GetRoot", "Unknown root : " & psNom)
  19.         End Select
  20.         If InStr(psNom, "\") > 0 Then
  21.             lsRegRoot = psNom.Substring(InStr(psNom, "\"))
  22.             If lsRegRoot <> "" Then
  23.                 MREG_GetRoot = MREG_GetRoot.OpenSubKey(lsRegRoot, Not pbReadOnly)
  24.             End If
  25.         End If
  26.     End Function
  27. End Module
This should be changed to:
VB Code:
  1. Public Class MTools
  2.     Public Shared Function MREG_GetRoot(ByVal psNom As String, Optional ByVal pbReadOnly As Boolean = False) As Microsoft.Win32.RegistryKey
  3.        
  4.     Dim lsRegRoot As String = (psNom.Split("\")(0)).ToUpper()
  5.     Dim regKey As Microsoft.Win32.RegistryKey     
  6.     Select Case lsRegRoot
  7.             Case "HKEY_CURRENT_USER"
  8.                 regKey = Microsoft.Win32.Registry.CurrentUser
  9.             Case "HKEY_LOCAL_MACHINE"
  10.                 regKey = Microsoft.Win32.Registry.LocalMachine
  11.             Case "HKEY_CLASSES_ROOT"
  12.                 regKey = Microsoft.Win32.Registry.ClassesRoot
  13.             Case "HKEY_CURRENT_CONFIG"
  14.                 regKey = Microsoft.Win32.Registry.CurrentConfig
  15.             Case "HKEY_USERS"
  16.                 regKey = Microsoft.Win32.Registry.Users
  17.             Case Else
  18.                 Throw New Exception("Unknown root : " & psNom)
  19.         End Select
  20.         If psNom.Contains("\") Then
  21.             lsRegRoot = psNom.Substring(psNom.IndexOf("\"))
  22.             If lsRegRoot.Length > 0 Then
  23.                 regKey = regKey.OpenSubKey(lsRegRoot, Not pbReadOnly)
  24.             End If
  25.         End If
  26.     return regKey
  27.        
  28.     End Function
  29. End Class
Just daft things like that throughout the entire code, makes it hard to follow. Still can't get it working on my pc. I keep getting object not set errors.

Will take a few hours to convert completely, and then a few more to iron out all the bugs.

Hope that helps.

WOka
__________________
My .NET Tutorials:
Silverlight Enabled WebPart in WSS

My VB.NET Code Examples:
Create IIS Virtual DirectoryValidate Login Against Active DirectoryAutomatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET

My ASP.NET Code Examples:
Login To Website (Forms Authentication)Login To Website (Custom Authentication)

My VB6 Code Projects:
Multithreading In VB6Custom TooltipsMulti Language SupportItem Selector ControlAnnimated Systray IconSimple Effective Graph ControlDownload From WebLiveUpdate, download application updates from the web automaticallySystray Notification MessagesSkin A FormAPI TimerBadger Messenger, an MSN clone that uses the MSN NetworkWokawidgets VB6 Component Suite
Wokawidget is offline   Reply With Quote
Old Aug 10th, 2007, 07:57 AM   #15
Matt_4
New Member
 
Join Date: Aug 07
Posts: 1
Matt_4 is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

I want to save each 10 Sekonds a new picture.
In the following function i don´t know how I can pass the new picture form the cam to bmp.
The bmp.Save function is running correctly, I already tested it.


Private Sub Save()
Me.Show()
Dim myCam As New iCam
Dim i As Integer = 0
Dim numerOfPicture As String
Dim bmp As Bitmap
numerOfPicture = i.ToString
bmp = '**********this line is the problem**********
bmp.Save("C:\Pictures\Picture" + numerOfPicture + ".bmp")
i = i + 1
Me.Close()
End Sub



I tried to use the origin code by change it a little, but I got a big Problem.
The following changes work correctly if I click the button every 10 Sekonds.
Now the problem: If I let the Button click by software, in the pictureBox is no longer the picture but a part of the
desktop which is seen right behind the pictureBox.

Private myCam As iCam

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.picOutput.SizeMode = PictureBoxSizeMode.StretchImage
myCam = New iCam
myCam.initCam(Me.picOutput.Handle.ToInt32)
End Sub

Private Sub cmdViewStill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdViewStill.Click
If myCam.iRunning Then
Dim a As FrmImage
a = New FrmImage

a.picImage.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _
Me.picOutput.Width, Me.picOutput.Height))
Me.Show()
Else
MessageBox.Show("Camera Is Not Running!")
End If
End Sub

Now I want to save the picture:

Private Sub Save()
Me.Show()
Dim myCam As New iCam
Dim i As Integer = 0
Dim numerOfPicture As String
Dim bmp As Bitmap
numerOfPicture = i.ToString
bmp = CType(picImage.Image, Bitmap)
bmp.Save("C:\Pictures\Picture" + numerOfPicture + ".bmp")
i = i + 1
Me.Close()
End Sub

and this works If I click the button who is starting Save(), but If I let the Button click by software,
in the pictureBox is no longer the picture but a part of the
desktop which is seen right behind the pictureBox.
So I thought don´t use a button but a funtion wich starts without a button to take a picture every 10 Sekonds.
-> The same result:In the pictureBox is the desktop which is seen right behind the pictureBox.
-> And in the file it is also.

Could somebody show me a line of code with wich I can save the taken picture of the cam directly in a bitmap.
Then I could simply save the bitmap.

That means to replace these 2 lines:

a.picImage.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _
Me.picOutput.Width, Me.picOutput.Height))

in something like:

Dim bmp as Bitmap
bmp = '*****here should the cam pass one picture to bmp so I can save bmp direktly*****

I would be obliged if somebody could help me.

I use WinXP and
VisualBasic Express
Matt_4 is offline   Reply With Quote
Old Oct 1st, 2007, 07:52 PM   #16
jinx101
New Member
 
Join Date: Oct 07
Posts: 4
jinx101 is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

I downloaded the original source for VS2003 Framework 1.1 and it appeared to work fine. I wanted to use the 2005 Framework 2.0 copy that Wokawidget posted though. I put it into VS2005 and it compiled without errors. I can start and stop the webcam (the green light goes on and off) however the ImageChanged event never seems to fire even when the cam is on (I put logging in that event in the class to verify it... I also kept tabs on the _Picture variable and it doesn't appear to have anything, like the system isn't returning it).

I know the class is talking to the web cam somewhat because it will turn it on and off, but I can't see to pull the images from it. Thoughts?

Here's the example code from my form that's trying to use the class:

vb Code:
  1. Private WithEvents _Camera As WebCamera
  2.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  3.         _Camera = New WebCamera
  4.         _Camera.StartFeed()
  5.     End Sub
  6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7.         _Camera = New WebCamera
  8.         _Camera.StartFeed()
  9.     End Sub
  10.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  11.         If _Camera.Running Then
  12.             _Camera.EndFeed()
  13.         End If
  14.     End Sub
  15.     Private Sub _Camera_ImageChanged() Handles _Camera.ImageChanged
  16.         Me.Text = "Changed at " & Now().ToString
  17.         Dim NewImage As Image = _Camera.CurrentImage
  18.         PictureBox1.Image = NewImage
  19.         NewImage.Dispose()
  20.         NewImage = Nothing
  21.     End Sub
jinx101 is offline   Reply With Quote
Old Jan 22nd, 2008, 10:09 AM   #17
gonkowonko
New Member
 
Join Date: Dec 06
Location: Cornwall, England
Posts: 1
gonkowonko is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

thanks for this code its ace.

One little problem i have found, im using VS 2008 and have managed to get an application to work on my laptop which opens up a 348x270 capture window, enables to user to press "Take Photo" and save. Perfect yeah...

Well now ive tried transferring the application it to another PC i only get half of the picture box showing (capture frame) and the other half is the form behind coming through, as if the window isnt redrawing corrrectly so you dont get a proper image being viewed let alone saved? Does that make sense?

Any suggestions?

Last edited by gonkowonko; Jan 22nd, 2008 at 10:13 AM.
gonkowonko is offline   Reply With Quote
Old Jan 27th, 2008, 11:42 PM   #18
yz4now
New Member
 
Join Date: Feb 07
Posts: 14
yz4now is an unknown quantity at this point (<10)
Thumbs up Re: [Vb.Net] WebCam Class (ICam)

Hello,
This code is amazing
I as wondering if there would be a way to add effects to the webcam stream. Like black and white, filters etc.

Let me know.

Thanks, Adam.
yz4now is offline   Reply With Quote
Old Jan 28th, 2008, 09:08 AM   #19
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
Re: [Vb.Net] WebCam Class (ICam)

I'm not too sure if you can add any affects to the stream. I'll have a look into it if I get a few minutes!

Pino is offline   Reply With Quote
Old Jan 30th, 2008, 10:49 AM   #20
Didius
New Member
 
Join Date: Jan 08
Posts: 1
Didius is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Thanks for the great code.

I am trying to modify the code so that I can capture the image not just with a button, but also when the user presses the button on the webcam.

Any suggestions?

Thanks,
Didius
Didius is offline   Reply With Quote
Old Jan 30th, 2008, 10:54 AM   #21
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
Re: [Vb.Net] WebCam Class (ICam)

Didius,

Thanks! As for your question, I'm not too sure that would involve looking at the hardware you are using.

Thanks
Pino is offline   Reply With Quote
Old Apr 5th, 2008, 04:01 AM   #22
makko
Member
 
Join Date: Nov 07
Posts: 58
makko is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Ok ... i managed to capture images from webcam ... but I need to send those images to another computer ... like an livestream ... how can I do that ?
makko is offline   Reply With Quote
Old Apr 6th, 2008, 03:16 AM   #23
jaguar22
New Member
 
Join Date: Apr 08
Posts: 1
jaguar22 is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

I took the time to register for the forum just so that I could properly thank pino for this code. it was precisely what I need for a project I'm working on. this was after trying several others that didn't work or didn't work well. thanks!
jaguar22 is offline   Reply With Quote
Old Apr 6th, 2008, 05:18 AM   #24
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
Re: [Vb.Net] WebCam Class (ICam)

Quote:
Originally Posted by jaguar22
I took the time to register for the forum just so that I could properly thank pino for this code. it was precisely what I need for a project I'm working on. this was after trying several others that didn't work or didn't work well. thanks!
Thats really great to hear!

Good luck with the project!

Pino
Pino is offline   Reply With Quote
Old Apr 7th, 2008, 04:18 AM   #25
makko
Member
 
Join Date: Nov 07
Posts: 58
makko is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

well jaguar ...

I think too the pino's code is great ... but too advanced for what I need right now ...

a great code that works can be found at http://www.webtropy.com/articles/art7-2.asp ... it's easy to use too

pino thanks for the code
makko is offline   Reply With Quote
Old Apr 7th, 2008, 04:27 AM   #26
Pino
Super Moderator
 
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)Pino is a jewel in the rough (200+)
Re: [Vb.Net] WebCam Class (ICam)

Quote:
Originally Posted by makko
well jaguar ...

I think too the pino's code is great ... but too advanced for what I need right now ...

a great code that works can be found at http://www.webtropy.com/articles/art7-2.asp ... it's easy to use too

pino thanks for the code
Too advanced? The code above uses the exact same method. My class just provides a simple interface.

Pino

Last edited by Pino; Apr 7th, 2008 at 04:32 AM.
Pino is offline   Reply With Quote
Old May 18th, 2008, 11:14 AM   #27
OuTa-SyNc
New Member
 
Join Date: May 08
Location: Kent, England
Posts: 4
OuTa-SyNc is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

great webcam code, by far the best way of doing it in VB, I've added motion detection to it, pic below, this is my first attempt at motion detection so the code maybe very grude.



I will post the source later when I've cleaned it up a little.

I thought i would add the motion detection with a visual twist, you can see what motion has been picked up by the green indicator. I also added track bars which control how sensitive it is, and also the object size it responds to. Might be handy for a security thing, you can set the size to only go off to people and not a cat for example.

Kind Regards,
OuTa-SyNc
OuTa-SyNc is offline   Reply With Quote
Old May 19th, 2008, 09:34 AM   #28
Mark Lloyd Duatin
New Member
 
Join Date: May 08
Posts: 5
Mark Lloyd Duatin is an unknown quantity at this point (<10)
Talking Re: [Vb.Net] WebCam Class (ICam)

Quote:
Originally Posted by OuTa-SyNc
great webcam code, by far the best way of doing it in VB, I've added motion detection to it, pic below, this is my first attempt at motion detection so the code maybe very grude.



I will post the source later when I've cleaned it up a little.

I thought i would add the motion detection with a visual twist, you can see what motion has been picked up by the green indicator. I also added track bars which control how sensitive it is, and also the object size it responds to. Might be handy for a security thing, you can set the size to only go off to people and not a cat for example.

Kind Regards,
OuTa-SyNc






Sir i was Looking for this type of application can you please post a draft here or email me perhaps. I need this for my thesis im gonna add sms features to it and post it here. please please please .....
Mark Lloyd Duatin is offline   Reply With Quote
Old May 19th, 2008, 12:38 PM   #29
OuTa-SyNc
New Member
 
Join Date: May 08
Location: Kent, England
Posts: 4
OuTa-SyNc is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

here you go...full source iCam with Motion detection

ignore the commented out lines, these are for a project I'm working on. Like I said the method I used may be grude but it works...and at the same speed as the webcam. It uses 2 timers, each is set with an interval the same as the frame rate (i.e. if the cam is set to 30 FPS then the timer interval would be 33) but I changed it to 30.

If anyone can improve it please post back, as I would like an optimised version myself
OuTa-SyNc is offline   Reply With Quote
Old May 19th, 2008, 01:02 PM   #30
Mark Lloyd Duatin
New Member
 
Join Date: May 08
Posts: 5
Mark Lloyd Duatin is an unknown quantity at this point (<10)
Talking Re: [Vb.Net] WebCam Class (ICam)

Quote:
Originally Posted by OuTa-SyNc
here you go...full source iCam with Motion detection

ignore the commented out lines, these are for a project I'm working on. Like I said the method I used may be grude but it works...and at the same speed as the webcam. It uses 2 timers, each is set with an interval the same as the frame rate (i.e. if the cam is set to 30 FPS then the timer interval would be 33) but I changed it to 30.

If anyone can improve it please post back, as I would like an optimised version myself

thnx so much i will be working with this.. well as i can see you used the lockbits. i saw that in c# and add me up in YM macrulz2004.. haha.. il add saving of image when motion detected plus sms sending when motion detected plus email.. i did it back in vb6,0.. thanx so much dont forget to add me. we can work with this together haha thnx
Mark Lloyd Duatin is offline   Reply With Quote
Old May 19th, 2008, 02:27 PM   #31
OuTa-SyNc
New Member
 
Join Date: May 08
Location: Kent, England
Posts: 4
OuTa-SyNc is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

does anyone know how I can hide the cam picturebox and display only the output produced from the motion detection?

If I set the cam picturebox to visible = false nothing works because the camera output is not being produced, basically I want to get the frames from the camera, add my motion detection method to it and display the results in the output picturebox only. I've tried rendering over the image set in the cam picturebox but with no luck.

Not sure if anyone has noticed but if you place anything in front of the picturebox with the cam running then it is treader as output produced from the cam???

Thanks in advance
OuTa-SyNc is offline   Reply With Quote
Old May 22nd, 2008, 06:00 AM   #32
Mark Lloyd Duatin
New Member
 
Join Date: May 08
Posts: 5
Mark Lloyd Duatin is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

hey since you helped me haha im helping you too here i solved the problem and added a feature where you can select the device where the program will get the image.


do re upload your webcam motion detection using my code here. i used copying from the clipboard and retrieving it..

if anyone can optimize this please do so thnx
Attached Files
File Type: rar problemsolved.rar (53.8 KB, 1746 views)
Mark Lloyd Duatin is offline   Reply With Quote
Old Sep 3rd, 2008, 05:21 AM   #33
jhnoh
New Member
 
Join Date: Sep 08
Posts: 1
jhnoh is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Hello,
a simply great class.
How can I get a second camera? I'm testing it now with two cameras.

Thanks.
jhnoh is offline   Reply With Quote
Old Sep 13th, 2008, 01:22 PM   #34
alikh
New Member
 
Join Date: Sep 08
Posts: 1
alikh is an unknown quantity at this point (<10)
Lightbulb Re: [Vb.Net] WebCam Class (ICam)

hi every body this class is a develop on icam
and can capture image with no problem even when the window is minimized
no problem .with time adding .auto capturing and ......
Attached Files
File Type: zip CWNP.zip (441.4 KB, 2042 views)
alikh is offline   Reply With Quote
Old Sep 19th, 2008, 04:56 PM   #35
Holm76
New Member
 
Join Date: Sep 08
Posts: 2
Holm76 is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Hi guys

If I was to use this class without using a picturebox to show the webcam feed all the time but rather initiate the camera and then when buttons are clicked grab a picture then how would I go about doing that?

I can only initiate the camera with a handle to a picturebox as of now
Holm76 is offline   Reply With Quote
Old Sep 21st, 2008, 05:49 AM   #36
Holm76
New Member
 
Join Date: Sep 08
Posts: 2
Holm76 is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

Ok so I found a somewhat workable solution to my own problem.

As wrote if I placed the picturebox outside the form the GrabIt picture is black also if I make the picturebox 0,0 in size the picture would be black.

So what I did was to leave the picturebox at 1,1 in size and place it somewhere on the main form where it is unnoticed and I can now GrabIt and get perfect webcam shot when buttons are clicked.
Holm76 is offline   Reply With Quote
Old Feb 13th, 2009, 03:09 PM   #37
dudemon
New Member
 
Join Date: Feb 09
Posts: 1
dudemon is an unknown quantity at this point (<10)
Exclamation Re: [Vb.Net] WebCam Class (ICam)

Quote:
Originally Posted by OuTa-SyNc
here you go...full source iCam with Motion detection

ignore the commented out lines, these are for a project I'm working on. Like I said the method I used may be grude but it works...and at the same speed as the webcam. It uses 2 timers, each is set with an interval the same as the frame rate (i.e. if the cam is set to 30 FPS then the timer interval would be 33) but I changed it to 30.

If anyone can improve it please post back, as I would like an optimised version myself
Can someone please re-attach the BBIC.zip? The website is no-longer.

Thanks,

D.M
dudemon is offline   Reply With Quote
Old Feb 14th, 2009, 03:01 PM   #38
OuTa-SyNc
New Member
 
Join Date: May 08
Location: Kent, England
Posts: 4
OuTa-SyNc is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

I didn't realise that I deleted from my server

iCam with Motion detection
OuTa-SyNc is offline   Reply With Quote
Old Mar 15th, 2009, 04:28 AM   #39
jamesnguyen_anewtech
New Member
 
Join Date: Mar 09
Posts: 2
jamesnguyen_anewtech is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

This is simpe webcam code. You create simple user interface with startrecord, stoprecord, and stopcam, one listbox contain webcam device.
change name of button according to name in sourcecode and you can use this code to record webcam
vb.net Code:
  1. Public Class Form1
  2.     Const WM_CAP_START = &H400S
  3.     Const WS_CHILD = &H40000000
  4.     Const WS_VISIBLE = &H10000000
  5.     Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
  6.     Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
  7.     Const WM_CAP_EDIT_COPY = WM_CAP_START + 30
  8.     Const WM_CAP_SEQUENCE = WM_CAP_START + 62
  9.     Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
  10.     Const WM_CAP_SET_SCALE = WM_CAP_START + 53
  11.     Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
  12.     Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
  13.     Const SWP_NOMOVE = &H2S
  14.     Const SWP_NOSIZE = 1
  15.     Const SWP_NOZORDER = &H4S
  16.     Const HWND_BOTTOM = 1
  17.     Dim count As Integer = 0
  18.     '--The capGetDriverDescription function retrieves the version
  19.     ' description of the capture driver--
  20.     Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _
  21.        (ByVal wDriverIndex As Short, _
  22.         ByVal lpszName As String, ByVal cbName As Integer, _
  23.         ByVal lpszVer As String, _
  24.         ByVal cbVer As Integer) As Boolean
  25.     '--The capCreateCaptureWindow function creates a capture window--
  26.     Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
  27.        (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
  28.         ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
  29.         ByVal nHeight As Short, ByVal hWnd As Integer, _
  30.         ByVal nID As Integer) As Integer
  31.     '--This function sends the specified message to a window or windows--
  32.     Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
  33.        (ByVal hwnd As Integer, ByVal Msg As Integer, _
  34.         ByVal wParam As Integer, _
  35.        <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer
  36.     '--Sets the position of the window relative to the screen buffer--
  37.     Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
  38.        (ByVal hwnd As Integer, _
  39.         ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
  40.         ByVal y As Integer, _
  41.         ByVal cx As Integer, ByVal cy As Integer, _
  42.         ByVal wFlags As Integer) As Integer
  43.     '--This function destroys the specified window--
  44.     Declare Function DestroyWindow Lib "user32" _
  45.        (ByVal hndw As Integer) As Boolean
  46.     '---used to identify the video source---
  47.     Dim VideoSource As Integer
  48.     '---used as a window handle---
  49.     Dim hWnd As Integer
  50.     Private Sub Form1_Load( _
  51.        ByVal sender As System.Object, _
  52.        ByVal e As System.EventArgs) Handles MyBase.Load
  53.         btnStartRecording.Enabled = True
  54.         btnStopRecording.Enabled = False
  55.         '---list all the video sources---
  56.         ListVideoSources()
  57.         VideoSource = 0
  58.         PreviewVideo(pbctrl)
  59.        
  60.     End Sub
  61.     Private Sub ListVideoSources()
  62.         Dim DriverName As String = Space(80)
  63.         Dim DriverVersion As String = Space(80)
  64.         For i As Integer = 0 To 9
  65.             If capGetDriverDescriptionA(i, DriverName, 80, _
  66.                DriverVersion, 80) Then
  67.                 lstVideoSources.Items.Add(DriverName.Trim)
  68.             End If
  69.         Next
  70.     End Sub
  71.     '---list all the video sources---
  72.     Private Sub lstVideoSources_SelectedIndexChanged( _
  73.        ByVal sender As System.Object, ByVal e As System.EventArgs) _
  74.        Handles lstVideoSources.SelectedIndexChanged
  75.         '---check which video source is selected---
  76.         VideoSource = lstVideoSources.SelectedIndex
  77.         '---preview the selected video source
  78.         PreviewVideo(pbCtrl)
  79.     End Sub
  80.     '---preview the selected video source---
  81.     Private Sub PreviewVideo(ByVal pbCtrl As PictureBox)
  82.         hWnd = capCreateCaptureWindowA(VideoSource, _
  83.             WS_VISIBLE Or WS_CHILD, 0, 0, 0, _
  84.             0, pbCtrl.Handle.ToInt32, 0)
  85.         If SendMessage( _
  86.            hWnd, WM_CAP_DRIVER_CONNECT, _
  87.            VideoSource, 0) Then
  88.             '---set the preview scale---
  89.             SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
  90.             '---set the preview rate (ms)---
  91.             SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0)
  92.             '---start previewing the image---
  93.             SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
  94.             '---resize window to fit in PictureBox control---
  95.             SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _
  96.                pbCtrl.Width, pbCtrl.Height, _
  97.                SWP_NOMOVE Or SWP_NOZORDER)
  98.         Else
  99.             '--error connecting to video source---
  100.             DestroyWindow(hWnd)
  101.         End If
  102.     End Sub
  103.     '---stop the preview window---
  104.     Private Sub btnStopCamera_Click( _
  105.        ByVal sender As System.Object, _
  106.        ByVal e As System.EventArgs) _
  107.        Handles btnStopCamera.Click
  108.         StopPreviewWindow()
  109.     End Sub
  110.     '--disconnect from video source---
  111.     Private Sub StopPreviewWindow()
  112.         SendMessage(hWnd, WM_CAP_DRIVER_DISCONNECT, VideoSource, 0)
  113.         DestroyWindow(hWnd)
  114.     End Sub
  115.     '---Start recording the video---
  116.     Private Sub btnStartRecording_Click( _
  117.        ByVal sender As System.Object, _
  118.        ByVal e As System.EventArgs) _
  119.        Handles btnStartRecording.Click
  120.         btnStartRecording.Enabled = False
  121.         btnStopRecording.Enabled = True
  122.         '---start recording---
  123.         SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0)
  124.     End Sub
  125.     '---stop recording and save it on file---
  126.     Private Sub btnStopRecording_Click( _
  127.        ByVal sender As System.Object, _
  128.        ByVal e As System.EventArgs) _
  129.        Handles btnStopRecording.Click
  130.         btnStartRecording.Enabled = True
  131.         btnStopRecording.Enabled = False
  132.         '---save the recording to file---
  133.         SendMessage(hWnd, WM_CAP_FILE_SAVEAS, 0, "C:\Users\Public\Videos\Sample Videos\recordedvideo.avi")
  134.     End Sub
End Class
jamesnguyen_anewtech is offline   Reply With Quote
Old Apr 1st, 2009, 10:08 AM   #40
^Clark^
New Member
 
Join Date: Apr 09
Posts: 3
^Clark^ is an unknown quantity at this point (<10)
Re: [Vb.Net] WebCam Class (ICam)

very nice class...

however i think this will be great if there is a record functionality.
^Clark^ is offline   Reply With Quote
Reply

Go Back   VBForums > VBForums CodeBank > CodeBank - Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:55 PM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.