You are on page 1of 3

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.
3.  
4. 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.
3.                             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
  iCam Class.zip (1.5 KB, 55155 views)
  WebCamViewer.zip (28.6 KB, 48516 views)

[Vb.Net] WebCam Class (ICam)-VBForums

You might also like