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:
Public iRunning As Boolean
This can be called at anytime and will return if the camera is running or not
VB Code:
Messagebox.show Mycam.Irunning
How To Use The Class
VB Code:
Private myCam As iCam
Set myCam = New iCam
From here you can call a range of functions using the syntax,
VB Code:
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:
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:
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:
myCam.setFrameRate(25)
closeCam()
- Allways call when closing the application, just clears things up.
VB Code:
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:
Me.picStill.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _
Me.picOutput.Width, Me.picOutput.Height))
FPS()
- This sub returns the current FPS
VB Code:
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!